Jsf 如何将commandButton与复选框连接

Jsf 如何将commandButton与复选框连接,jsf,Jsf,在html页面中,我有一个h:commandButton,我想让它与h:selectBooleanCheckbox一起工作,因此每次按下按钮,复选框都会被选中,否则 可以直接在html中而不是在其背后的java代码中这样做吗 <h:commandButton value="#{userBean.buttonText()}" action="#{userBean.changeOutput()}"/> <h:panelGrid columns="4" render

在html页面中,我有一个
h:commandButton
,我想让它与
h:selectBooleanCheckbox
一起工作,因此每次按下按钮,复选框都会被选中,否则

可以直接在html中而不是在其背后的java代码中这样做吗

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

`

如果您使用的是JSF2,则必须使用标记更新包含复选框的区域

你可以在stackoverflow中找到很多例子,看看这个例子,只需隐藏/显示一个div:


希望有帮助。

我想在这里建立连接,而不是在其背后的代码中。与使用渲染属性显示和隐藏panelGrid的方式相同。