[英]How to refresh an element outside form with h:command ajax in jsf2?
How can I refresh an element outside the form through ajax render . 如何通过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>
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 -
. 虽然只有当
<h:panelGroup id="rehreshthistoo">
本身不在另一个 UINamingContainer
组件中时,并且如果你没有将默认的JSF命名容器分隔符更改为:
或者其他诸如_
或-
类的东西,它UINamingContainer
-
。
The ultimate answer should be found in the JSF-generated HTML source. 最终的答案应该在JSF生成的HTML源代码中找到。 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. 在浏览器中打开页面,右键单击并查看源代码 ,在其中找到
<h:panelGroup id="rehreshthistoo">
生成的<span>
元素,然后使用命名容器在<f:ajax render>
使用其ID分隔符作为前缀。 If it contains an auto-generated ID of some UINamingContainer
parent, then you should give that parent component a fixed ID as well. 如果它包含某个
UINamingContainer
父级的自动生成的ID,那么您也应该为该父组件提供固定的ID。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.