a4j:ajax , revert datamodel changes
stamar Feb 10, 2012 9:23 AMHi all;
I have a module in my application for user administration. When administrator changes the role of the person (in a popup window), other fields must be rendered .... see the piece of code below:
<h:panelGroup layout="block" styleClass="sie-field">
<h:panelGroup styleClass="popup-row">
<cc:outputLabel forId="entry-role" colon="true" required="true" value="#{msgs.user_Role}" />
</h:panelGroup>
<h:panelGroup>
<rich:select id="entry-role" value="#{administrationBean.person.role}" required="true">
<a4j:ajax render="entry-substituteActive,entry-substitute,entry-substitute-label,entry-auditor,entry-auditor-label" execute="@this" event="selectitem" />
<f:selectItems value="#{administrationBean.dataService.roles}" var="item" itemValue="#{item}" itemLabel="#{item.name}" />
<rich:validator />
</rich:select>
<rich:message for="entry-role" />
</h:panelGroup>
</h:panelGroup>
I have a problem, when administrator edits the person info....so e.g. edited person has set 'role1'. The administrator changes this role to 'role2' (a4j:ajax changes my data model) and he press cancel button. In the model stays value role2 ... and that is the problem.
my cancel button looks as follows:
<a4j:commandButton id="abort-popup" value="#{msgs.buttonAbort}" action="#{applicationBean.refreshView}" immediate="true" oncomplete="#{rich:component('person-popup')}.hide();" />
refreshView method:
public void refreshView() {
FacesContext context = FacesContext.getCurrentInstance();
Application application = context.getApplication();
ViewHandler viewHandler = application.getViewHandler();
UIViewRoot viewRoot = viewHandler.createView(context, context.getViewRoot().getViewId());
context.setViewRoot(viewRoot);
context.renderResponse();
}
This method refreshes everything except the values that were changed by a4j:ajax
Has anyone idea, how to solve it?
Thanks a lot
Martin