gpt4 book ai didi

java - 如何隐藏 h :outputLink conditionally?

转载 作者:行者123 更新时间:2023-12-02 07:27:59 26 4
gpt4 key购买 nike

如何根据支持 bean 中的 boolean 值隐藏 h:ouputLink

为了禁用它,我会像这样:

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

但是我怎样才能完全隐藏呢?

最佳答案

与:

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

对不起,是我的错。您正在搜索 h:outputLink。因为 h:outputLinkh: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

关于java - 如何隐藏 h :outputLink conditionally?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13291132/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com