因为<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>
也可以看看: