使用<p:command>和<p:outputpanel>隐藏/显示面板

时间:2016-05-04 05:58:43

标签: jsf primefaces

我是jsf和primefaces的新手。我希望实现这一点,同时点击按钮两个链接应该启用,同时再次点击同一个按钮,两个链接被禁用。我创建了一个使用<h:commandButton>和java bean来隐藏节目的示例但不知道<p:commandButton><p:outputPanel>

我已经实现了这一点,点击链接时将启用2链接。

问题是再次点击它必须被禁用哪个无法正常工作

1 个答案:

答案 0 :(得分:1)

如果我理解你:

<h:form id="mainform">
    <p:commandButton value="#{testBean.enabled ? 'Hide' : 'Show'}" action="#{testBean.toggle()}" update="links, @this"/>
    <p:outputPanel id="links">
        <p:link value="link1" href="http://www.stackoverflow.com" rendered="#{testBean.enabled}"/>
        <p:spacer width="10"/>
        <p:link value="link2" href="http://www.stackoverflow.com" rendered="#{testBean.enabled}"/>
    </p:outputPanel>
</h:form>

豆:

private Boolean enabled = false; // + getter/setter
public void toggle() {
    enabled = !enabled;
}
相关问题