如何通过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>
答案 0 :(得分:6)
您的代码看起来很好。如果<h:panelGroup id="rehreshthistoo">
在另一个 UINamingContainer
组件中已经单独使用,并且如果您尚未更改默认的JSF,那么仅会工作将:
的容器分隔符命名为其他内容,例如_
或-
。
最终的答案应该在JSF生成的HTML源代码中找到。在浏览器中打开页面,右键单击查看源,在其中找到<span>
生成的<h:panelGroup id="rehreshthistoo">
元素,然后在<f:ajax render>
中使用其完整ID命名容器分隔符作为前缀。如果它包含某个UINamingContainer
父项的自动生成ID,那么您也应该为该父组件提供固定ID。