2 Replies Latest reply on Jan 18, 2012 9:50 AM by Harald Höhn

    h:selectBooleanCheckbox rerender problem

    Harald Höhn Newbie

      Hi,

       

      I have a problem with "h:selectBooleanCheckbox". After rerender of this element the value is always false. My checkbox is part of an complex dataform, and some components must be rerender other components for corect work. if any component trigger a rerender of a checkbox, this checkbox is always unselected.

       

      Here an example to reproduce the problem.

       

      <h:selectBooleanCheckbox id="check1_id" value="#{MyBean.check1}"/>

      <h:selectBooleanCheckbox id="check2_id" value="true"/>

      <a4j:commandButton id="Refresh_id1" value="Refresh1" reRender="check1_id"/>

      <a4j:commandButton id="Refresh_id2" value="Refresh2" reRender="check2_id"/>

       

      Each time you press one of the buttons the checkbox is always unselected. How can i keep a "selected" checkbox after rerender?

        • 1. Re: h:selectBooleanCheckbox rerender problem
          Vitaliy Pavlov Novice

          Hi, Harald

           

          May be next code be helpful

           

           

          <h:form>

               <h:selectBooleanCheckbox id="check1_id" value="#{myBeen.check1}"/>

               <a4j:commandButton id="Refresh_id1" actionListener="#{myBeen.check1Change}" value="Refresh1" render="check1_id"/>

          </h:form>

           

           

           

          import javax.faces.bean.ManagedBean;

          import javax.faces.bean.SessionScoped;

          import javax.faces.event.ActionEvent;

           

          @ManagedBean

          @SessionScoped

          public class MyBeen {

           

              public void check1Change(ActionEvent event){

                  check1 = !check1;

              }

           

           

              public Boolean getCheck1() {

                  return check1;

              }

           

              public void setCheck1(Boolean check1) {

                  this.check1 = check1;

              }

          }

           

          Regards, Vitaliy

          • 2. Re: h:selectBooleanCheckbox rerender problem
            Harald Höhn Newbie

            Thanks for your answer/solution. That fix the problem. But i think its only a workaround but it works.