6 Replies Latest reply on May 9, 2011 10:08 AM by vali_iva

    <a4j:repeat> issue values aren't dynamically updated in backing bean

    vali_iva

      Hi all,

       

      I'm using a numberInputSlider inside of a repeat element, which value attribute points to a backing bean's List<myObject> attribute. But the value inside myObject from the list isn't updated when I slide. If a change the value attribute to point to a regular variable (meaning not the variable from myObject from list) it works. But that's not what I need.

       

      Here is the code:

       

       

       

      <a4j:outputPanel header="Selector" id="selector" >
          <a4j:repeat  value="#{testBackingBean.targetInd}"  <!-- points to List<myObject> -->
                    var="item" >
               <rich:inputNumberSlider value="#{item.minRange}"  <!-- this value isn't updated when I slide -->
                         showInput="false" 
                         showBoundaryValues="false" 
                         minValue="#{item.min}"
                         maxValue="#{item.max}" >
                    <a4j:support event="onchange" reRender="companiesTable"/> 
              <rich:inputNumberSlider>
              <rich:inputNumberSlider value="#{testBackingBean.maxRange}" <!-- here I used a regular variable and is working -->
                             showInput="false"
                             showBoundaryValues="false"
                        minValue="#{item.min}"
                        maxValue="#{item.max}" >
                         <a4j:support event="onchange" reRender="companiesTable" /> 
              </rich:inputNumberSlider>
         </a4j:repeat>
      </a4j:outputPanel>
      
      

       

       

      This is happening in another part of my application, but instead of a slider, I have a checkbox.

      So what's going on with the List. Why isn't working? Which is the right approch the get the result I want?

       

      Thanks.

       

      Vali

        • 1. Values aren't dynamically updated in backing bean
          vali_iva

          Oh, and instead of event="onchange" I used olso event="onslide". But the result is the same. Not updating.

           

          <a4j:support event="onslide" reRender="companiesTable" />

          • 2. Re: Values aren't dynamically updated in backing bean
            vali_iva

            I still haven't solved my problem, but I come with an update.

             

            I added a repeater binding: binding="#{testBackingBean.repeater}" to my <a4j:repeat> and added an action to the ajax support  to manually change the value from my list.

            This is the new code:

             

             

            <a4j:outputPanel header="Selector" id="selector" >
                 <a4j:repeat  value="#{testBackingBean.targetInd}" binding="#{testBackingBean.repeater}"
                           var="item" >
                      <rich:inputNumberSlider value="#{item.minRange}" 
                                     showInput="false" 
                                     showBoundaryValues="false" 
                                     minValue="#{item.min}"
                                     maxValue="#{item.max}" >
                           <a4j:support immediate="true" action="#{testBackingBean.updateMinRangeValue}" event="onchange" reRender="companiesTable"/> 
                    </rich:inputNumberSlider>
                 <rich:inputNumberSlider value="#{item.maxRange}"
                                            showInput="false"
                                showBoundaryValues="false"
                                minValue="#{item.min}"
                                maxValue="#{item.max}" >
                            <a4j:support immediate="true" action="#{testBackingBean.updateMaxRangeValue}" event="onchange" reRender="companiesTable" /> 
                    </rich:inputNumberSlider>
                 </a4j:repeat>
            </a4j:outputPanel>
            
            

             

             

            Olso added the method to the testBackingBean:

             

             

            public String updateMinRangeValue(){
                 targetInd.get(getRepeater().getRowIndex()).setMinRange(0.0); // here I need to set to the current value of the slider
                 getRepeater().getRowData(); // ????
                 return null;
            }
            
            

             

             

            This methos is not complete because I don't know how to get current value of the slider from the current row.

            Now I need to know if this is the right approch??? If yes, how do I get value of the slider? getRepeater().getRowData() ??? And then.. ??

             

             

            Thanks in advanced.

             

            Vali

            • 3. <a4j:repeat> issue values aren't dynamically updated in backing bean
              nbelaevski

              Hi Valentin,

               

              What is the scope of testBackingBean bean?

              • 4. Re: <a4j:repeat> issue values aren't dynamically updated in backing bean
                vali_iva

                Hi Nick, thanks for the reply.

                 

                It is in session scope.

                 

                But I made some changes from my last post.

                I modified <a4j:support>, setted immediate="false" and completed my method. Now it it looks like this:

                 

                 

                public String updateMaxRangeValue(){
                     SelectIndicator selectedRow = (SelectIndicator) getRepeater().getRowData();
                     int i = getRpeater().getRowIndex();
                     targetInd.get(i).setMaxRange(selectedRow.getMaxRange());
                }
                

                 

                Bbut still not working like it shuld. Now, when I slide, the value gets changed, but with it all the other slides values inside the repeater get reseted

                to the values I manually set them in testBackingBean constructor. This is weared, I'm sure that the bean is in session scope.

                 

                Thanks again.

                 

                Vali

                • 5. Re: <a4j:repeat> issue values aren't dynamically updated in backing bean
                  ilya_shaikovsky

                  I believe should works without any immediate and bindings used. Please replace the rich:inputNumberSlider on the initial source with h:inputText just to check ow it will works.

                   

                  Minor hints

                  1) please add layout=block to outputPanel. in orther case you will have non-valid htrml generated (slider consist of block elements and outputPanel renders as span by default)

                  2) please use phaseTracker to look through lifecycle execution. If there will be difference for just inputText and slider used?

                  • 6. Re: <a4j:repeat> issue values aren't dynamically updated in backing bean
                    vali_iva

                    Hi Illya,

                     

                    I made all the modification you suggested. But still not working. Not even with the inputText.

                    This is the output of my phaseTracker both for inputText and for slider:

                     

                     

                    May 9, 2011 5:04:14 PM org.apache.catalina.core.ApplicationContext log
                    INFO: BEFORE - RESTORE_VIEW 1
                    May 9, 2011 5:04:14 PM org.apache.catalina.core.ApplicationContext log
                    INFO: AFTER - RESTORE_VIEW 1
                    May 9, 2011 5:04:14 PM org.apache.catalina.core.ApplicationContext log
                    INFO: BEFORE - APPLY_REQUEST_VALUES 2
                    May 9, 2011 5:04:14 PM org.apache.catalina.core.ApplicationContext log
                    INFO: AFTER - APPLY_REQUEST_VALUES 2
                    May 9, 2011 5:04:14 PM org.apache.catalina.core.ApplicationContext log
                    INFO: BEFORE - PROCESS_VALIDATIONS 3
                    May 9, 2011 5:04:14 PM org.apache.catalina.core.ApplicationContext log
                    INFO: AFTER - PROCESS_VALIDATIONS 3
                    May 9, 2011 5:04:14 PM org.apache.catalina.core.ApplicationContext log
                    INFO: BEFORE - UPDATE_MODEL_VALUES 4
                    May 9, 2011 5:04:14 PM org.apache.catalina.core.ApplicationContext log
                    INFO: AFTER - UPDATE_MODEL_VALUES 4
                    May 9, 2011 5:04:14 PM org.apache.catalina.core.ApplicationContext log
                    INFO: BEFORE - INVOKE_APPLICATION 5
                    May 9, 2011 5:04:14 PM org.apache.catalina.core.ApplicationContext log
                    INFO: AFTER - INVOKE_APPLICATION 5
                    May 9, 2011 5:04:14 PM org.apache.catalina.core.ApplicationContext log
                    INFO: BEFORE - RENDER_RESPONSE 6
                    May 9, 2011 5:04:14 PM org.apache.catalina.core.ApplicationContext log
                    INFO: AFTER - RENDER_RESPONSE 6
                    
                    

                     

                     

                    Thanks,

                    Vali