<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
的上下文中找到它答案 0 :(得分:5)
因为<f:subview>
是NamingContainer
。
只需使用<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>