【问题标题】:How to refresh an element outside form with h:command ajax in jsf2?如何在 jsf2 中使用 h:command ajax 刷新表单外的元素?
【发布时间】:2011-12-31 17:03:17
【问题描述】:

如何通过ajax渲染刷新表单外的元素。

<ui:repeat var="o">
    <h:form>
        <h:panelGroup id="someid">
       ...
        </h:panelGroup>

        <div>
            <h:commandButton action="#{o.doSomething}">
                <f:ajax event="action" render="someid :rehreshthistoo" />
            </h:commandButton>
        </div>
    <h:form>
</ui:repeat>

 <h:panelGroup id="rehreshthistoo">
       ...
 </h:panelGroup>

【问题讨论】:

    标签: ajax jsf-2


    【解决方案1】:

    您的代码看起来不错。虽然它&lt;h:panelGroup id="rehreshthistoo"&gt; 本身不在另一个 UINamingContainer 组件中并且如果您没有更改默认的JSF命名容器分隔符的情况下才起作用: 到其他东西,例如 _-

    最终答案应该在 JSF 生成的 HTML 源代码中找到。在浏览器中打开页面,右键单击并查看源代码,在其中找到生成的&lt;h:panelGroup id="rehreshthistoo"&gt; 元素&lt;span&gt;,然后在您的&lt;f:ajax render&gt; 中使用其ID,并以命名容器分隔符作为前缀.如果它包含某个 UINamingContainer 父组件的自动生成 ID,那么您也应该为该父组件指定一个固定 ID。

    另见:

    【讨论】:

      猜你喜欢
      • 2013-08-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多