如何在jsf2中使用h:command ajax刷新表单外的元素?

发布于 2024-12-16 11:40:39 字数 522 浏览 2 评论 0原文

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

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

How can I refresh an element outside the form through ajax render .

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

街角卖回忆 2024-12-23 11:40:39

你的代码看起来不错。尽管它 本身尚未位于另一个 中时才起作用UINamingContainer 组件,如果您尚未将 : 的默认 JSF 命名容器分隔符更改为其他内容,例如 _-

最终的答案应该在 JSF 生成的 HTML 源代码中找到。在浏览器中打开页面,右键单击并查看源代码,找到生成的 元素 在那里,然后在 中准确使用它的 ID,并以命名容器分隔符作为前缀。如果它包含某个 UINamingContainer 父组件的自动生成 ID,那么您也应该为该父组件指定一个固定 ID。

另请参阅:

Your code looks fine. Although it would only work if the <h:panelGroup id="rehreshthistoo"> is not already by itself in another UINamingContainer component and also if you haven't changed the default JSF naming container separator of : to something else such as _ or -.

The ultimate answer should be found in the JSF-generated HTML source. Open the page in the browser, rightclick and View Source, locate the generated <span> element of <h:panelGroup id="rehreshthistoo"> in there and then use exactly its ID in your <f:ajax render> with the naming container separator as prefix. If it contains an auto-generated ID of some UINamingContainer parent, then you should give that parent component a fixed ID as well.

See also:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文