How to rerender part of page with form in JSF 2.0?

戏子无情 提交于 2019-12-03 14:57:01
BalusC

This is related to partial state saving. If you ajax-update a component which in turn contains a form as one of its children, then its view state will get lost. Every 1st ajax request inside that form will fail because there's no view state. But if that ajax request is re-rendering the form itself, then it will work.

To fix this, you need to explicitly include the ID of the other form(s) in ajax render/update attribute next to outerDiv whenever it's invoked from another form.

E.g.

<h:form>
    <h:commandButton value="Update other forms">
        <f:ajax render="outerDiv form1 form2" />
    </h:commandButton>
</h:form>
<h:panelGroup id="outerDiv">
    <h:form id="form1">...</h:form>
    <h:form id="form2">...</h:form>
</h:panelGroup>

No, this will not result in an ajax response with duplicate components. It will just trigger JSF to prepare and save the state of those other forms.

See also:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!