为什么< h:panelGroup>通过< f:subview>访问时未找到ID标签? [英] Why <h:panelGroup> id is not found when I access through <f:subview> tag?

查看:47
本文介绍了为什么< h:panelGroup>通过< f:subview>访问时未找到ID标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am getting the error as: cannot locate it in the context of the component j_idt26

推荐答案

因为<f:subview>

  • 如何找出要进行Ajax更新/渲染的组件的客户端ID?找不到表达式为"foo"的组件;引用自"bar"
  • 只需使用<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>
    

    或在此特定示例中,直接在命令按钮上(请确保您的情况比这更复杂)

    or in this specific example just directly on command button (surely your case is more complex than that)

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

    另请参见:

    • 替代ui:JSF中的fragment
    • 非JSF组件的条件渲染(普通的HTML和模板文本)
    • See also:

      • Alternative to ui:fragment in JSF
      • Conditional rendering of non-JSF components (plain vanilla HTML and template text)
      • 这篇关于为什么&lt; h:panelGroup&gt;通过&lt; f:subview&gt;访问时未找到ID标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    相关文章
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆