加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-16 02:51:25 所属栏目:百科 来源:网络整理
导读:如何通过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:rep
如何通过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>

解决方法

你的代码看起来很好.虽然它只有在< h:panelGroup id =“rehreshthistoo”>在另一个UINamingContainer组件中,并且如果您还没有将默认的JSF命名容器分隔符更改为:其他内容(如_或 – ),则它本身并不存在.

最终的答案应该在JSF生成的HTML源代码中找到.在浏览器中打开页面,右键单击并查看源代码,找到生成的< span> < h:panelGroup id =“rehreshthistoo”>的元素在那里,然后在你的< f:ajax渲染>中使用它的ID使用命名容器分隔符作为前缀.如果它包含某个UINamingContainer父级的自动生成的ID,那么您也应该为该父组件提供固定的ID.

也可以看看:

> Communication in JSF 2.0 – Ajax rendering of content outside form

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读