如何在后备bean中隐藏基于布尔值的h:ouputLink

对于禁用,我想这样:

<h:commandButton disabled="#{backing.property}" />


但是我怎么能完全隐藏呢?

最佳答案

带有:

<h:commandButton id="myComponent" rendered="#{backing.property}" />


对不起,我的错。您正在搜索h:outputLink。因为h:outputLink和h:commandButton都从UIComponentBase派生,所以两个派生类都具有方法isRendered(),您无需将commandLink包装在某种面板中。

<h:outputLink rendered="#{backing.property}" />


更新资料

由于不会呈现myComponent,因此它将被“隐藏”。
不呈现myComponent意味着您需要围绕myComponent的UIComponent进行更新(例如,使用ajax请求),如下所示:

<h:panelGrid id="myPanelGrid">
  ....
  <h:outputLink id="myComponent" rendered="#{backing.property}" />
  ....
<h:panelGrid>

<h:commandButton value="show" action="#{backing.setPropertyToTrueMethod}" update="myPanelGrid" />


请参阅API规范:JavaTM Platform, Enterprise Edition 6 API Specification

07-24 18:48