【问题标题】:Why <h:panelGroup> id is not found when I access through <f:subview> tag?为什么通过 <f:subview> 标签访问时找不到 <h:panelGroup> id?
【发布时间】:2013-05-16 06:18:00
【问题描述】:
 <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 的上下文中找到它

【问题讨论】:

    标签: jsf-2


    【解决方案1】:

    因为&lt;f:subview&gt;NamingContainer

    另见:


    只需使用&lt;h:panelGroup&gt;

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

    &lt;ui:fragment&gt;(开销只有一点点)

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

    另见:

    【讨论】:

      猜你喜欢
      • 2012-10-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-01
      • 2021-01-09
      • 1970-01-01
      相关资源
      最近更新 更多