Update Profile
This facility is used for updating user information in the database. Such as login id, name, password, email address etc. When user wishes to change their information, he may proceed by clicking on Update Profile Menu, all the information is fetched from the database and set in the update form. then used can change their personal information.
In this section at first we see how the update form is developed after this we will discuss how to develop an action.
Developing an update form
At first import the struts specific tag libraries
<%@ taglib uri="/tags/struts-bean" prefix="bean"%> <%@ taglib uri="/tags/struts-html" prefix="html"%>
<html:form action="/userregister" method="post" onsubmit="return validateForm(this);">
User Id <html:text property="userid" size="30" maxlength="120" />
Password <html:password property="password" size="30" maxlength="120" />
Email <html:text property="email" size="30" maxlength="120" />
Address <html:text property="address" size="30" maxlength="120" />
Phone No <html:text property="phno" size="30" maxlength="120" />
<html:submit>Save</html:submit>
</html:form>
Update Action
The Update action is responsible for setting value in the bean properties
It get the user id from the session and fetch all the information from the database of that user and sets into the bean properties file
HttpSession session = request.getSession();
String id = (String) session.getAttribute("ID");
roseindia.dao.hibernate.Login pojoObj = springHibernateDAO
.loadUser(id);
objForm.setId(pojoObj.getId());
objForm.setUserid(pojoObj.getLoginid());
objForm.setPassword(pojoObj.getPassword());
objForm.setAddress(pojoObj.getAddress());
objForm.setEmail(pojoObj.getEmail());
objForm.setPhno(String.valueOf(pojoObj.getPhno()));
forwardToPage = "input";
roseindia.dao.hibernate.Login pojoObj = springHibernateDAO .loadUser(objForm.getId().toString()); pojoObj.setLoginid(objForm.getUserid()); pojoObj.setPassword(objForm.getPassword()); pojoObj.setAddress(objForm.getAddress()); pojoObj.setPhno(Integer.parseInt(objForm.getPhno())); pojoObj.setId(objForm.getId()); pojoObj.setEmail(objForm.getEmail()); springHibernateDAO.updateUser(pojoObj); forwardToPage = "updated";
|
| Update Success |
|
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Update Profile
Post your Comment