gpt4 book ai didi

java - JSF/RichFaces 4 问题 : initiating component while rendering is false

转载 作者:行者123 更新时间:2023-12-02 05:57:54 25 4
gpt4 key购买 nike

我有一个组件隐藏在 rendered="false" 后面。该组件仍然会被初始化并启动一些资源浪费过程。如何确保组件在其区域/组件/面板具有 rendered="false" 时不会被初始化?

源代码:

XHTML:

<a4j:region rendered="false">
<h:panelGroup rendered="false">
<rich:dropDownMenu binding="#{textBlockBean.textBlockMenu}" rendered="false" />
</h:panelGroup>
</a4j:region>

JAVA:

public UIComponent getTextBlockMenu() {
if (textblockMenu == null) {
textblockMenu = createTextBlok();
}
textblockMenuComponent = textblockMenu.build();
return textblockMenuComponent;
}

如何预防

<rich:dropDownMenu binding="#{textBlockBean.textBlockMenu}"/>

避免在需要之前被触发。

提前致谢!

最佳答案

问题

当 EL 处理器到达该标签时,决定不构建 UIComponent 已经太晚了。标签绑定(bind)到的实例,即一旦 EL 处理器到达 <rich:dropDownMenu/> ,它将调用 getTextBlockMenu()rendered属性是一个 View 渲染时间标志,它只是决定是否显示组件。

解决

必须在查看构建期间使用 <c:if/> 决定是否构建组件。 JSTL 标签:

<a4j:region rendered="false">
<h:panelGroup rendered="false">
<c:if test="#{textBlockBean.renderCondition}">
<rich:dropDownMenu binding="#{textBlockBean.textBlockMenu}" rendered="false" />
</c:if>
</h:panelGroup>
</a4j:region>

哪里renderCondition是确定组件可用性的支持 bean 标志

关于java - JSF/RichFaces 4 问题 : initiating component while rendering is false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22911012/

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