Search code examples
javascriptjsfrichfacesajax4jsf

How disable a <h:selectBooleanCheckbox> pressing a <a4j:commandButton> in jsf


<a4j:form id="formNC">
    <rich:panel style="width: 100%">       
       <h:selectBooleanCheckbox value="#{crearCitaMB.booleanCheck">
       <a4j:commandButton value="DisableCheck" action="#{testBean.methodCalculate}" />
    </rich:panel>
</a4j:form>

my question is simple: can I "disable" not "hide" selectBooleanCheckbox when I press commandButton ... I do not know how make this yet. Can this be done with aj4:support or javascript?


Solution

  • try this...

    in page:

    <a4j:form id="formNC">
        <rich:panel style="width: 100%">
           <h:selectBooleanCheckbox disabled="#{testBean.disableFlag"} 
                value="#{crearCitaMB.booleanCheck"}>
           <a4j:commandButton value="DisableCheck" 
                action="#{testBean.methodCalculate}" render="formNC" />
        </rich:panel>
    </a4j:form>
    

    in testBean:

    private boolean disableFlag;
    
    public boolean isDisableFlag()
    {
        return disableFlag;
    }
    
    public void methodCalculate()
    {
        disableFlag = true;
        ...
    }