Failed to get value <h: selectBooleanCheckbox> inside my managed bean method

JSF view code:

<f:view>
    <h:form>
        <h:panelGrid>
            <h:inputText id="key" value="#{myManagedBean.key}"/>
            <h:selectBooleanCheckbox id="rerun" value="#{myManagedBean.rerun}" rendered="#{myManagedBean.displayRerun}"/>
            <h:commandButton id="check" action="#{myManagedBean.check}"/>
        </h:panelGrid>
    </h:form>
<f:view>

JSF Model Code:

public class MyManagedBean {

    private boolean displayRerun;


    public void setDisplayRerun(boolean aDisplayRerun) {
       this.displayRerun = aDisplayRerun        }

    public boolean getDisplayRerun() {
       return this.displayRerun;
    }

   private String key;


    public void setKey(String aKey) {
       this.key = aKey
    }

    public String getKey() {
       return this.key;
    }
    private boolean rerun;


    public void setRerun(boolean arerun) {
       this.rerun = arerun
    }

    public boolean getRerun() {
       return this.rerun;
    }

    public String check() {
        //do data validation
        setDisplayRerun(true);
        System.out.println(getRerun());
    }

}

It always prints falsewhether or not the checkbox is checked.

Additional information about my requirement:

Nick/BalusC, bean . , . , . bean, ( , .) , , singleBooleanCheckBox, . managedbean ( , ).

, .

selectBooleanCheckbox ( , ). @action actionbean. , , . , "" .

6 . .

.

+3
1

, rendered ( ), bean - ( , ). , false .

, rendered, . : bean , Tomahawk t:saveState h:inputHidden bean binding. .

+1

Source: https://habr.com/ru/post/1773115/


All Articles