3 Replies Latest reply on Aug 25, 2009 10:13 AM by giunad

    s:selectItems inside a h:selectManyCheckbox

    giunad

      hi


      I'm seeing a strange behaviour of s:selectItems inside a h:selectManyCheckbox



      in detail there is a form




      <a:form id="idForm" ajaxRendered="true">
      
      A<h:outputText id="rawList" value="#{myForm.selectedTags}"/>
      
      B<h:selectManyCheckbox id="boxList" value="#{myForm.todelTags}" layout="pageDirection">
         <s:selectItems value="#{myForm.selectedTags}" var="_tag" label="#{_tag}"/>
      </h:selectManyCheckbox>
      
      <a:commandButton id="delete" value="delete" action="#{myForm.doDeleteTag}" reRender="boxList, rawList" />
      
      </a:form>





      doDeleteTag code is


      public void doDeleteTag() {
              selectedTags.removeAll(todelTags);
              todelTags = null;
              todelTags = new ArrayList<String>();
      }




      everything is very simple:
      there is a list of tags. every tag has a checkbox (point A)
      user can select several checkboxes and delete them.


      after delete, the list is re-rendered to show the new list


      the problem is that after user clicks on commandButton, boxList is the same as before. no change.


      as test, I added an h:outputText with same value (point B).
      rawList works correctly.


      in few words


      before I click I see:


      A[tag1, tag2, tag3]

      B

      checkbox tag1

      checkbox tag2

      checkbox tag3


      suppose I select tag2 and click,
      now I see:


      A[tag1, tag3] <--correct!

      B

      checkbox tag1

      checkbox tag2 <--why??

      checkbox tag3



      what's wrong?????
      why checkbox tag2 is still there??


      thanks for any help.

        • 1. Re: s:selectItems inside a h:selectManyCheckbox
          giunad

          just to be complete


          my environment is:



          • richfaces 3.2.2.SR1

          • jboss-seam-2.1.1.GA

          • jboss-4.2.3.GA

          • 2. Re: s:selectItems inside a h:selectManyCheckbox
            kahlua

            Hi,



            From my memories the lifecycle is something like that :



            • restore view phase : component initialized with the model values

            • invoke application : model values modified.

            • render response : it checked the equality with the value initialized during the restore view.



            At this point, the object are the same (same reference) between restore view and render response so to avoid useless treatment the component doesn't generate a new set of selectedItems from the model values and used the previous entries.


            I ididn't check out but that's what I'm thinking about the UIOutput :
            The output component display the right value because its internal behavior is more basic than the one of the selectitems tag.
            Check if the component compute the value for each call ?



            You can check my post about this problem too. No reply so far (except yours).


            My problem was resvoled using a quick and dirty fix : the value atrtibute of the Selectitems component points to a method which returns a new List with the model values each time.


            If someone can validate or invalidate my explanation (what is right and what is wrong) ?


            thanks in advance.
            François

            • 3. Re: s:selectItems inside a h:selectManyCheckbox
              giunad