当我通过<f:subview>标签访问时,为什么找不到<h:panelgroup> id?</f:subview> </h:panelgroup>

时间:2013-05-21 13:03:20

标签: jsf-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

的上下文中找到它

1 个答案:

答案 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>

另见: