How to connect a commandButton with CheckBoxAsk Question

问题:

In a html page I have a h:commandButton that I want to make it to work in combination with a h:selectBooleanCheckbox, so every time I press the button the checkbox will be checked and otherwise.

Is it possible to do that directly in the html, and not in the java code behind it?

<h:commandButton  value="#{userBean.buttonText()}" action="#{userBean.changeOutput()}"/>        
<h:panelGrid columns="4" rendered="#{userBean.details}" styleClass="clicked" >
    <h:outputText .... />
    <h:outputText ..../>
</h:panelGrid>`

回答1:


If you are using JSF 2, you have to update the area that include your checkbox, using f:ajax tag.

You can find a lot of examples here in stackoverflow, look this example just hide/show a div: After showing / hiding a JSF element with AJAX how to hide the triggering element?

Hope it helps.

标签:
© 2014 TuiCode, Inc.