如何在jsf2中使用h:command ajax刷新表单外的元素?
如何通过 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的代码看起来不错。尽管它仅在
本身尚未位于另一个中时才起作用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 anotherUINamingContainer
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 someUINamingContainer
parent, then you should give that parent component a fixed ID as well.See also: