5 Replies Latest reply on Aug 9, 2007 5:11 AM by Ilya Shaikovsky

    how to prevent page changing in datascroller

    kui kui Newbie

      Hi all,

      Currently I am using the <rich:datascroller> to display a list of account information of our system which allow user to do some changes on particular account... now what I am trying to do is I would like to do a validation for the changes that the user made BEFORE a new page is clicked. If the validation is failed, the datascroller will still remain on the current page and displayed the error message.

      For example: The user has made some invalid changes on page 1 and then clicked on page 3 on the datascroller. The system will display the error message and remain on page 1.

      Is there any way to achieve this? I will appreicate if there's any advice. Thanks

        • 1. Re: how to prevent page changing in datascroller
          Ilya Shaikovsky Master

          just set ajaxSingle="false" on your dataScroller component and all the components in the same region will be also processed while pages changing. So validation for the table will be used while switching.

          • 2. Re: how to prevent page changing in datascroller
            kui kui Newbie

            Thanks for your help, but what I really want to know is how can I STOP the page changing... the scenario is:

            page 1 -> change something on page 1 -> click page 3 -> display error message saying that the change made on page 1 is wrong -> stay at page 1 (which means NOT going to page 3)

            The way you suggested me can perform validation but the page will still move to page 3 and I really want to find a way for the datascroller NOT changing page even people click on other page number.

            • 3. Re: how to prevent page changing in datascroller
              Ilya Shaikovsky Master

              So. I'm using

              <h:form>
               <rich:messages/>
               <rich:dataTable value="#{capitalsBean.capitals}" var="cap" rows="5">
               <rich:column>
               <h:inputText value="#{cap.name}" required="true"/>
               </rich:column>
               <f:facet name="footer">
               <rich:datascroller pageIndexVar="pageIndex" pagesVar="pages" ajaxSingle="false">
               </rich:datascroller>
               </f:facet>
               </rich:dataTable>
               </h:form>
              


              So in this simlpe case - if I din't fill the form - pages will not be switched for me. Did you mean something like this?

              • 4. Re: how to prevent page changing in datascroller
                kui kui Newbie

                Thanks a lot and sorry for the late reply... Your solution is quite similar to what I am asking but there's still something different from my situation.
                Currently I am using Javascript to validate the inputs in the dataTable, and I would like to alert an error message and using javascript to stop the datascroller changing the page.
                I tried putting ajaxSingle="false" and onclick attribute in the rich:datascroller but the page will still changing to other page once the user clicks on other page number.
                Do you have any other suggestions which can allow me to accomplish this with Javascript involved? Thanks again for your help.

                • 5. Re: how to prevent page changing in datascroller
                  Ilya Shaikovsky Master

                  ok... I've used server validation, and you - client one..

                  To acomplish this for this simple example you may look again on my example and add your validation JS to parent form onsubmit attribute.