为什么< h:panelGroup>通过< f:subview>访问时未找到ID标签? [英] Why <h:panelGroup> id is not found when I access through <f:subview> tag?
问题描述
<h:panelGroup id="userPanel"><f:subview rendered="#{searchView.isUser}">
<h:commandButton value="test" action="#{searchAction.doFindUsers}" >
<f:ajax execute="@this" event="action" render="userPanel" />
</h:commandButton> </f:subview></h:panelGroup>
我收到以下错误消息:无法在组件j_idt26的上下文中找到它
I am getting the error as: cannot locate it in the context of the component j_idt26
推荐答案
因为 只需使用 或 或在此特定示例中,直接在命令按钮上(请确保您的情况比这更复杂) or in this specific example just directly on command button (surely your case is more complex than that)
<f:subview>
是
<h:panelGroup>
<h:panelGroup id="userPanel">
<h:panelGroup rendered="#{searchView.isUser}">
<h:commandButton value="test" action="#{searchAction.doFindUsers}">
<f:ajax execute="@this" event="action" render="userPanel" />
</h:commandButton>
</h:panelGroup>
</h:panelGroup>
<ui:fragment>
(开销少一点)<h:panelGroup id="userPanel">
<ui:fragment rendered="#{searchView.isUser}">
<h:commandButton value="test" action="#{searchAction.doFindUsers}">
<f:ajax execute="@this" event="action" render="userPanel" />
</h:commandButton>
</ui:fragment>
</h:panelGroup>
<h:panelGroup id="userPanel">
<h:commandButton value="test" action="#{searchAction.doFindUsers}" rendered="#{searchView.isUser}">
<f:ajax execute="@this" event="action" render="userPanel" />
</h:commandButton>
</h:panelGroup>
另请参见:
See also:
- Alternative to ui:fragment in JSF
- Conditional rendering of non-JSF components (plain vanilla HTML and template text)
这篇关于为什么< h:panelGroup>通过< f:subview>访问时未找到ID标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!