11 Replies Latest reply on Nov 22, 2007 9:42 AM by ilya_shaikovsky

    problem with DataScroller and h:commandLink (reRender)

      Hi,
      I get a problem when I try to rerender the rich:DataScroller and the rich:DataTAble.

      Situation:

      I have a h:commandButton that calls a search method. This method changes the DataTable content. After clicking in the button, the new content is rerendered in the rich:DataTable (ok), but the DataScroller doesn't change according to DataTable.
      For example, I have 2 pages in my rich:DataTable and the after clicking, the return of method is 3 pages. The rich:dataScroller keeps 2 pages. In the second request, if I click again, the DataScroller changes correctly.

      My commandButton has "<a4j:support event="onclick" reRender="DataTableID,DataScrollerID"""

        • 1. Re: problem with DataScroller and h:commandLink (reRender)
          moldovan

          Why are you using <h:commandButton>-Tag? You don't need normal commandButton with aj4:support, use a4j:commandButton.

          Try it with <a4j:commandButton action="#{...}" reRender="TableId, ScrollerId">

          And for debugging: put a4j:log component into your page

          • 2. Re: problem with DataScroller and h:commandLink (reRender)

            The reason is:

            - When I use <a4j:commandButton> and the method doesn't have return the 'rerender' doesn't work. The table should be empty, but It keeps the old content.

            - When I use <h:commandButton> with "<a4j:support>", it works.

            • 3. Re: problem with DataScroller and h:commandLink (reRender)

              Hmm...give us more infos please. Versions of used libraries and so on.

              • 4. Re: problem with DataScroller and h:commandLink (reRender)

                Futher, with a4j:commandButton the same problem happens. I have just tested.

                The rerender only works in second click.

                Thanks.

                • 5. Re: problem with DataScroller and h:commandLink (reRender)

                  the versions are:

                  jsf1.2_04-api.jar
                  jsf1.2_04-impl.jar

                  richfaces-api-3.1.2.GA.jar
                  richfaces-impl-3.1.2.GA.jar
                  richfaces-ui-3.1.2.GA.jar

                  • 6. Re: problem with DataScroller and h:commandLink (reRender)

                    It would be very helpful a) to know your used versions and b) to look at a minimal code snippet where the problem appears. So we can test your code directly.

                    • 7. Re: problem with DataScroller and h:commandLink (reRender)

                      Ah sorry, I was to fast. So forget a) of the last post ;-)

                      • 8. Re: problem with DataScroller and h:commandLink (reRender)

                        Ok, the code below is a simplification of my problem. (only relevant code)
                        If you test, you will see that the Scroller just rerenders in the second request.

                        Jsp

                        <h:form id="myTestForm">
                         <h:inputText value="#{test.searchContent}" />
                         <br />
                         <h:commandButton value="Search" action="#{test.search}">
                         <a4j:support event="onclick" reRender="myRichDataTable1,myDataScroller1" />
                         </h:commandButton>
                         <br />
                         <a4j:outputPanel ajaxRendered="true" id="myAjaxOutputPanel1">
                         <rich:datascroller ajaxSingle="false" id="myDataScroller1" for="myRichDataTable1" immediate="true" />
                         <rich:dataTable rows="10" id="myRichDataTable1" var="myLocalList" value="#{test.listNames}">
                         <f:facet name="header">
                         <rich:columnGroup id="candidateLocalColumnGroup1">
                         <rich:column>
                         <h:outputText value="Name" />
                         </rich:column>
                         </rich:columnGroup>
                         </f:facet>
                         <rich:column>
                         <h:outputText value="#{myLocalList.name}" />
                         </rich:column>
                         </rich:dataTable>
                         </a4j:outputPanel>
                        </h:form>


                        ManagedBean
                        public List getListNames()
                         {
                         Collection myTestList = new ArrayList();
                         if (searchContent != null)
                         {
                         if ( searchContent.equals( "a" ) )
                         {
                         for ( int i = 0; i < 5; i++ )
                         {
                         TestDTO testDTO = new TestDTO();
                         testDTO.setName( "a" + i );
                         myTestList.add( testDTO );
                         }
                         } else if ( searchContent.equals( "b" ) )
                         {
                         for ( int i = 0; i < 15; i++ )
                         {
                         TestDTO testDTO = new TestDTO();
                         testDTO.setName( "b" + i );
                         myTestList.add( testDTO );
                         }
                         } else if ( searchContent.equals( "c" ) )
                         {
                         for ( int i = 0; i < 25; i++ )
                         {
                         TestDTO testDTO = new TestDTO();
                         testDTO.setName( "c" + i );
                         myTestList.add( testDTO );
                         }
                         } else
                         {
                         myTestList = null;
                         }
                         }
                         return (List) myTestList;
                         }
                        
                         public String search()
                         {
                         //some validations
                         getListNames();
                         //workarround to set DataTable page = 1
                         return null;
                         }


                        • 9. Re: problem with DataScroller and h:commandLink (reRender)
                          ilya_shaikovsky

                           

                          <rich:dataTable value="#{capitalsBean.capitals}" var="cap" rows="8" rowKeyVar="rowKey" id="table">
                           <rich:column>
                           <h:outputText value="#{cap.name}"> </h:outputText>
                           </rich:column>
                           <f:facet name="footer">
                           <rich:datascroller id="scroller"/>
                           </f:facet>
                           </rich:dataTable>
                           <a4j:commandButton value="add capital" action="#{capitalsBean.addEmptyCapital}" reRender="table, scroller"></a4j:commandButton>
                          


                          This code just worked for me.
                          B.t.w. I use 3.1.3 SNAPSHOTS.JSF 1.2 and facelets 1.1.14


                          B.t.w. Again I need to mention.. It's more usefull to understand the usage way before using the framework.

                          1) You should not use h:command* with support inside. Or you just need in duplicated submits?? But nobody will check the result because the usage is wrong.
                          2) You have ajaxRendered Panel and use reRender. Isn't a mistake but after such constructions I'll ask you to read docs again.

                          • 10. Re: problem with DataScroller and h:commandLink (reRender)

                            I understand and I thank you for the post.

                            The ajaxRendered Panel was used because I was trying to figure out my issue. I know its'nt is 100% correct.

                            My problem was resolved when I put the datascroller inside the dataTable as a footer. The dataScroller had a tag 'for' with the dataTableID and reRender dind't work. I don't know why yet.

                            Now, it's ok.

                            Thanks.

                            • 11. Re: problem with DataScroller and h:commandLink (reRender)
                              ilya_shaikovsky

                              moved scroller from footer above and below the table. Still works... :/