1 Reply Latest reply on May 22, 2008 9:37 PM by stephen

    Outjecting boolean value for use with h:selectBooleanCheckbox

    xena

      I'm trying outject a value to use with a h:selectBooleanCheckbox


      In my Stateful bean I have...


      @Out(required=false)
      private Boolean myBooleanFlag;
      
      @Factory
      public Boolean getMyBooleanFlag() {
        //init method is normally right here
        return myBooleanFlag;
      }
      



      and my select looks like...


      <h:selectBooleanCheckbox disabled="#{readonly}" readonly="#{readonly}" id="myid" value="#{myBooleanFlag}" /><h:outputText> Same as Previous</h:outputText>
      



      The factory method triggers just fine, but the value is never set on a change. So basically I can init it, but I cannot seem to change the value. I'm in the same conversation. I'm stumped - perhaps I'm just overlooking something.


      The value didn't seem to work at all as a boolean vs. Boolean. It also did not work if the factory name was isMyBooleanFlag - it had to be getMyBooleanFlag.


      I'm not sure where to look next. What am I doing wrong here?

        • 1. Re: Outjecting boolean value for use with h:selectBooleanCheckbox
          stephen

          A value binding (read the value attribute of a jsf component) needs a property with a getter and setter like this:



          @Name("myBean")
          public class MyBean implements Serializable {
          
              private Boolean myFlag;
          
              public Boolean getMyFlag() {
                  if(myFlag == null) {
                      // init
                  }
                  return myFlag;
              }
          
              public void setMyFlag(Boolean myFlag) {
                  this.myFlag = myFlag;
              }
          
          





          <h:selectBooleanCheckbox value="#{myBean.myFlag}" ...