How to refresh parent jsf page from richfaces popup

偶尔善良 提交于 2019-12-04 09:13:42

Just move the rich:popupPanel out of the main form, and give it it's own form. If you then submit the form that's in the dialog, the entire page will re-render.

Since the backing bean is view scoped, the previously user data will be retained and only the user name will be updated with whatever you entered in the dialog.

Additionally, you can submit the form via AJAX, give the main form an ID and re-render that.

E.g.

<rich:popupPanel id="popup" modal="true" resizeable="true" onmaskclick="#{rich:component('popup')}.hide()">
    <f:facet name="header">Simple popup panel</f:facet>
    <h:form id="form2">
         <h:outputLabel for="username2" value="Username"/>
         <h:inputText id="username2" value="#{register.user.username}" required="true"/>
         <a4j:commandButton value="do" action="#{register.update}" render="form" oncomplete="#{rich:component('popup')}.hide()"/>                 
     </h:form>
</rich:popupPanel>

I used the A4J commandButton here which has a convenient oncomplete attribute. You can do a similar thing with the onevent attribute on the standard ajax tag, but using slightly more code.

Do note that if the main form has validation errors, it's without any counter measures impossible to update from the other form (if you run into that, you'd best open a new question for that particular situation).

It's already answered but I had a similar problem. My view has a <rich:dataTable> to show data and I want to filter the results with chosen items in a <rich:popupPanel>. I had the same problem: choosing an option didn't update the table (using <a4j:ajax> event).

The popups are, by default attached to the <body> tag. So, I added domElementAttachment="form" to the <rich:popupPanel> and it worked.

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