3 Replies Latest reply on Jul 29, 2007 1:58 AM by sergeysmirnov

    checkbox state not being reflected

    daedlus

      Hi

      i have select all button to select all checkboxes in a form as shown below.
      the prob is that on server side the selectedItems array is updated but the ticks do not appear on the client side in the checkboxes even though iam rerendering the checkbox. but if i refresh the page using F5 key or navigate to next page and return the checkboxes get ticked.

      i also tried putting <a4j:form> / <A4jregion> but it didnt work

      <h:selectManycheckbox id="xvc" value="#{myBean.selectedItems}">
      <f:selectItems value = "#{myBean.selectItems}"/>
      </h:selectMany checkbox>
      
      <a4j:commandButton event="onclick" action="#{myBean.setAllItemsAsSelected}" reRender="xvc"/>
      


        • 1. Re: checkbox state not being reflected

          show the code snippet when you tried a4j:region please. (do not show the code with a4j:form. it is useless here).

          • 2. Re: checkbox state not being reflected
            daedlus

            like this .

            <a4j:region immediate="true">
            
            <h:selectManycheckbox id="xvc" value="#{myBean.selectedItems}">
            <f:selectItems value = "#{myBean.selectItems}"/>
            </h:selectMany checkbox>
            
            <a4j:commandButton event="onclick" action="#{myBean.setAllItemsAsSelected}" reRender="xvc"/>
            
            </a4j:region>
            



            • 3. Re: checkbox state not being reflected

              this does not make sense because you still submit the selectManyCheckbox when you click the button. JSF believes the value cannot be changed as soon as you just submit it.

              You need to surround with a4j:region only the a4j:commandButton.
              In general , you can have left the immediate="true" is you know why it there.

              a4j:commandButton has no 'event' attribute. So, remove it.

              P.S. do not think about Ajax4jsf how about magic wand. Knowledge is better than hundreds wild attempts.