Reputation: 660
I've an html page(editprofile.xhtml), which shows the data saved in database. Problem I'm facing is when i edit some data in the screen and click on update button the data which is edited is not going to the bean, its being null thereby resulting an error.
<h:form id="editProfileForm">
<f:facet name="label">
<h:outputText value="Edit User Profile" />
</f:facet>
<rich:panel header="Edit User Profile" style="font-size:10pt" >
<rich:simpleTogglePanel switchType="client" opened="true">
<f:facet name="header">Registration Details</f:facet>
<table>
<tbody>
<tr>
<td>Login Name</td>
<td>
<h:inputText size="15" id="loginName" required="true"
value="#{EditUserProfileBean.loginName}">
<rich:ajaxValidator event="onblur" />
</h:inputText>
</td>
<td></td>
<td>Password</td>
<td><h:inputSecret size="12" id="password" required="true"
value="#{EditUserProfileBean.password}" >
<rich:ajaxValidator event="onblur" />
</h:inputSecret>
</td>
<td>Confirm Password</td>
<td><h:inputSecret size="12" id="confirmpassword" required="true"
value="#{EditUserProfileBean.confirmpassword}" >
<rich:ajaxValidator event="onblur" />
</h:inputSecret>
</td>
</tr>
</rich:simpleTogglePanel>
<h:commandButton id="editProfile" action="#{EditUserProfileBean.saveEditProfileAction}" immediate="true" value="Update Profile" />
</rich:panel>
</h:form>
The above page is filled with the existing data on load, but if i edit and say update the value is being null
Upvotes: 0
Views: 1604
Reputation:
the immediate = true let you to submit your form without validtaing. and for solving your problem you do like this.
in your saveEditProfileAction of command button get the current user object that means the edited object and call the save method ..the framework will automatically call the update or insert method of the service class.so your service class must contain inser , update , delete methods .
saveEditProfileAction{
super.save(getUserObject());
}
so while calling save method the control will goes to the inser or update method of the service class based on the form status.
Upvotes: 0
Reputation: 6442
Remove immediate="true" attribute from your commandButton.
It skips jsf application lifecycle's updateModel phase, which is responsible for calling setters on your properties defined in bean, thus not updating the bean values.
Read more information on how immediate attributes affects JSF lifecycle. -written by @BalusC on 27/09/2006
Upvotes: 2