2
 <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 的上下文中找到它

4

1 回答 1

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>

也可以看看:

于 2013-05-21T17:32:05.013 回答