11 Replies Latest reply on Apr 16, 2007 3:00 AM by juanignaciosl

    Sending form fields when paging

    juanignaciosl

      Hi,

      I have a working rich:dataTable and rich:datascroller within a h:form. The form has a h:inputText. When I move through the pages it doesn't get sent, even it's in the same f:view (I have defined no regions yet). How can I send it triggered by a datascoller?

      Thanks in advance!

        • 1. Re: Sending form fields when paging

          page code snippet will be helpful here for any further discussions

          • 2. Re: Sending form fields when paging
            juanignaciosl

             

            "SergeySmirnov" wrote:
            page code snippet will be helpful here for any further discussions


            Here's my current JSF code:

            <a4j:form id="paginadorConvocatoriasForm" ajaxSubmit="true">
             <a4j:support event="oncomplete" reRender="convocatoriasRiFa" />
             <a4j:region id="paginadorConvocatoriasRegion" >
             <h:inputText value="#{convocatoriaPaginadorBean.modelo.titulo}" id="titulo" required="true">
             <a4j:support event="onchange" reRender="convocatoriasRiFa"/>
             </h:inputText>
            
            (...)
            
             <rich:dataTable id="convocatoriasRiFa" var="convocatoria" binding="#{convocatoriaPaginadorBean.datos}" value="#{convocatoriaPaginadorBean.modelo.value}" rows="#{convocatoriaPaginadorBean.modelo.rows}" rowClasses="oddRow, evenRow" headerClass="tableHeader">
            
            (...)
            
             </rich:dataTable>
             <rich:datascroller id="convocatoriasRiFaScroller" for="convocatoriasRiFa" fastStep="#{convocatoriaPaginadorBean.elementosAvanceRapido}" styleClass="scroller" > </rich:datascroller>
            
             <a4j:status startText="a Performing Request" stopText="a Request Done" for="paginadorConvocatoriasRegion">
             </a4j:status>
            
             </a4j:region>
            </a4j:form>


            This way I can send an AJAX request when I change "titulo" ("title"), but I don't know how to tell the datatable to update. In the server side I'm using the PageableListDataModel from tomahawk examples.

            • 3. Re: Sending form fields when paging
              juanignaciosl

              One more thing: as "titulo" is not sent when I press a page button, it gets lost if it doesn't saved in session scope

              • 4. Re: Sending form fields when paging
                ilya_shaikovsky

                Try onkeyup instead of onchange. input must loose focus to fire onchange event.

                • 5. Re: Sending form fields when paging
                  juanignaciosl

                   

                  "ilya_shaikovsky" wrote:
                  Try onkeyup instead of onchange. input must loose focus to fire onchange event.


                  Thanks, but I already know that. There's no problem with the inputText, since aj4:support does the trick. My only problem by now is sending the inputText value when you press a button at the scroller, in order to not being forced to store it in session.

                  This is the code so far:

                  (...)
                  <a4j:form id="paginadorConvocatoriasForm" ajaxSubmit="true">
                   <a4j:region id="paginadorConvocatoriasRegion">
                  (...)
                   <h:inputText value="#{convocatoriaPaginadorBean.modelo.titulo}" id="titulo" required="true">
                   <a4j:support event="onkeypress" reRender="convocatoriasRiFaScroller,convocatoriasRiFa" requestDelay="500" />
                   </h:inputText>
                  (...)
                   <rich:dataTable id="convocatoriasRiFa" var="convocatoria" binding="#{convocatoriaPaginadorBean.datos}" value="#{convocatoriaPaginadorBean.modelo.value}" rows="#{convocatoriaPaginadorBean.modelo.rows}" rowClasses="oddRow, evenRow" headerClass="tableHeader">
                  (...)
                   </rich:dataTable>
                  
                   <rich:datascroller id="convocatoriasRiFaScroller" for="convocatoriasRiFa" fastStep="#{convocatoriaPaginadorBean.elementosAvanceRapido}" styleClass="scroller"></rich:datascroller>
                  
                   <a4j:status startText="a Performing Request" stopText="a Request Done" for="paginadorConvocatoriasRegion"> </a4j:status>
                   </a4j:region>
                  </a4j:form>


                  • 6. Re: Sending form fields when paging

                    The form field will be submitted if you set ajaxSingle to false. I.e:
                    <rich:datascroller ajaxSingle="false" .... />

                    Be careful there. If validation is failed, the scrolling will be not perform.

                    • 7. Re: Sending form fields when paging
                      juanignaciosl

                      Ok, thank you, that worked.

                      Now I have another problem: how can I tell the page to "reload"? I'm trying with a "changed" flag, but my datamodel (an extension from PageableListDataModel from tomahawk cars example) goes into an infinite loop. Is there any example of the server side code I should use?

                      Thanks in advance

                      • 8. Re: Sending form fields when paging

                        What does it mean " page to "reload"" in your case?

                        • 9. Re: Sending form fields when paging
                          juanignaciosl

                          I'm sorry, I didn't realize that was such a confusing sentence composition :D

                          It means "paged table to update". Used datamodel (PageableListDataModel) doesn't have something like update(), and when I try to add the flag, it falls into an endless loop. Is there any other implementation of a paged table model? RichFaces documentation is really great at tag level, but JSF also involves beans, its configuration, and data models, and for inexperienced people like me it's not that easy.

                          Thank you for your help and patience

                          • 10. Re: Sending form fields when paging

                            why did you use a4j:form ajaxSubmit="true" . I hardly understand what might be the motivation.

                            • 11. Re: Sending form fields when paging
                              juanignaciosl

                              I thought it might be neccesary. Removing...