8 Replies Latest reply on Aug 14, 2009 6:16 AM by nbelaevski

    Why rich:dataScroller doesn't call

    vhmolinar

      Hello guys.
      I've a project using JSF, Seam and RichFaces for control and view layers.
      And my bad is being the component rich:dataScroller. Because actually when I click on a button from this component, a request is sent to the action and the "set" methods from the ManagedBean attributes are not being called.

      The attributes values that I want to send for my managed bean are:

      <h:selectOneMenu value="#{clogBean.SAno}" style="float:left;">
       <f:selectItems value="#{clogBean.years}"/>
      </h:selectOneMenu>
      
      <h:selectOneMenu value="#{clogBean.SMes}" style="float:left;margin-left:5px;">
       <f:selectItems value="#{clogBean.months}"/>
      </h:selectOneMenu>
      


      Bellow these selectOneMenu components I have an a4j:commandButton and a rich:dataTable that is bind to myDataScroller.

      Ps: all of my components above are inside an a4j:form and an a4j:region.

      So my doubt is:
      Why the rich:dataScroller request doesn't call the set methods of my variables "years" and "months" when I click on a button from this one?

      Here is my action code:
       @Factory("listChangeLog")
       public void loadChangesLog(){
       Calendar initialDate = new GregorianCalendar();
       initialDate.set(Calendar.MONTH, sMes);
       initialDate.set(Calendar.YEAR, sAno);
       initialDate.set(Calendar.DAY_OF_MONTH, 1);
      
       Calendar finalDate = new GregorianCalendar();
       finalDate.set(Calendar.MONTH, sMes);
       finalDate.set(Calendar.YEAR, sAno);
       int lastDay;
       switch (sMes) {
       case 0:
       case 2:
       case 4:
       case 6:
       case 7:
       case 9:
       case 11:
       lastDay = 31;
       break;
       case 1:
       lastDay = (finalDate.get(Calendar.YEAR) % 4 == 0) ? 29 : 28;
       break;
       default:
       lastDay = 30;
       break;
       }
       finalDate.set(Calendar.DAY_OF_MONTH, lastDay);
      
       try{
       listChangeLog = clDao.getChangesByParameter(initialDate, finalDate);
       }catch(HibernateException e){e.printStackTrace();}
       }
      


      and here is my ArrayList declaration:
       @DataModel
       private List<ChangesLog> listChangeLog;
      



      I would appreciate a help.

        • 1. Re: Why rich:dataScroller doesn't call
          vhmolinar

          Correction:

          I want that rich:dataScroller request invoke the set methods of my variables :

          SAno and SMes that are used by "h:selectOneMenu"


          from my managedBean.

          • 2. Re: Why rich:dataScroller doesn't call
            vhmolinar

            I've tried to use 'ajaxSingle' property of my rich:dataScroller and now it calls 'set' methods correctly, but it's setting the attributes only after action calling.


            Please guys, what can I do for solve it?

            • 3. Re: Why rich:dataScroller doesn't call
              yyq2009

              Hi, can you give more page code?

              • 4. Re: Why rich:dataScroller doesn't call
                vhmolinar

                Ok, my page code:

                <a4j:region>
                 <a4j:form style="margin-top:10px;">
                 <h:selectOneMenu value="#{clogBean.SAno}" style="float:left;">
                 <f:selectItems value="#{clogBean.years}"/>
                 </h:selectOneMenu>
                
                 <h:selectOneMenu value="#{clogBean.SMes}" style="float:left;margin-left:5px;">
                 <f:selectItems value="#{clogBean.months}"/>
                 </h:selectOneMenu>
                
                 <a4j:commandButton action="#{clogBean.loadChangesLog}" value="Carregar Dados..." reRender="clogTable,clogScroller" style="clear:left;float:left; margin: 5px 0 10px 0;"/>
                
                 <rich:dataTable var="c" value="#{listChangeLog}" rendered="#{not empty listChangeLog}" id="clogTable" style="clear:left;" rows="20">
                 <rich:column width="140">
                 <f:facet name="header">
                 User
                 </f:facet>
                 <div style="text-align:center;">
                 <h:outputText value="#{c.admin.username}" />
                 </div>
                 </rich:column>
                
                 <rich:column>
                 <f:facet name="header">
                 Date
                 </f:facet>
                 <div style="padding: 4px">
                 <h:outputText value="#{c.horaModificacao.time}">
                 <f:convertDateTime type="date" pattern="dd/MM/yyyy" />
                 </h:outputText>
                 </div>
                 </rich:column>
                
                 <rich:column>
                 <f:facet name="header">
                 Description
                 </f:facet>
                 <div style="padding: 4px">
                 <h:outputText value="#{c.descricao}" />
                 </div>
                 </rich:column>
                 </rich:dataTable>
                 <rich:datascroller for="clogTable" id="clogScroller" reRender="clogTable" ajaxSingle="false"/>
                 </a4j:form>
                </a4j:region>


                • 5. Re: Why rich:dataScroller doesn't call
                  ilya_shaikovsky

                   

                  and now it calls 'set' methods correctly, but it's setting the attributes only after action calling.


                  describe in details pelase.

                  • 6. Re: Why rich:dataScroller doesn't call
                    vhmolinar

                     


                    describe in details pelase.



                    The request made when I click on a button at rich:dataScroller invokes my action

                    @Factory("listChangeLog")
                     public void loadChangesLog(){
                    


                    before calling getters and setters.

                    Therefore I need that the request sets my variable values before calling action.
                    The variables that I want to be updated before action calling are:
                    SAno and SMes

                    These are being used by h:selectOneMenu components:

                    <h:selectOneMenu value="#{clogBean.SAno}" style="float:left;">
                     <f:selectItems value="#{clogBean.years}"/>
                    </h:selectOneMenu>
                    




                    • 7. Re: Why rich:dataScroller doesn't call
                      yyq2009

                      Maybe another ajaxSigle="true" problem.
                      Just remove the attribute of <rich:datascroller/>

                      • 8. Re: Why rich:dataScroller doesn't call
                        nbelaevski

                        Hi,

                        That's because this

                        @Factory("listChangeLog")
                         public void loadChangesLog(){
                        
                        is not a JSF action, but Seam factory method that returns data for data table. When request is processed, data table iterates over its children to decode them and that's causing factory creation. Possible fixes: change bean scope so that factory is executed only once per request - e.g. page or use "process" attribute of rich:datascroller to target processing for inputs only and skip data table.