1
2
3
4
5 package hu.elte.tribus.action;
6
7 import hu.elte.tribus.form.ProfileForm;
8 import hu.elte.tribus.interfaces.UserDao;
9 import hu.elte.tribus.model.User;
10 import hu.elte.tribus.util.AuthUtil;
11
12 import javax.servlet.http.HttpServletRequest;
13 import javax.servlet.http.HttpServletResponse;
14
15 import org.apache.struts.action.ActionForm;
16 import org.apache.struts.action.ActionForward;
17 import org.apache.struts.action.ActionMapping;
18 import org.springframework.web.struts.ActionSupport;
19
20 /***
21 * MyEclipse Struts
22 * Creation date: 11-11-2006
23 *
24 * XDoclet definition:
25 * @struts.action validate="true"
26 * @struts.action-forward name="ok" path="/user/profile.jsp"
27 */
28 public class EditProfileAction extends ActionSupport {
29
30 /***
31 * Method execute
32 * @param mapping
33 * @param form
34 * @param request
35 * @param response
36 * @return ActionForward
37 */
38 public ActionForward execute(ActionMapping mapping, ActionForm form,
39 HttpServletRequest request, HttpServletResponse response) {
40 UserDao userDao = (UserDao) this.getWebApplicationContext().getBean("userDao");
41 User currentUser = userDao.getUser(AuthUtil.getCurentUserName());
42 request.setAttribute("user", currentUser);
43 ProfileForm profileForm = (ProfileForm)form;
44 profileForm.setId(currentUser.getId().intValue());
45 profileForm.setFirstName(currentUser.getFirstname());
46 profileForm.setLastName(currentUser.getLastname());
47 profileForm.setEmail(currentUser.getEmail());
48 profileForm.setAdmin(currentUser.isAdmin());
49 return mapping.findForward("ok");
50 }
51 }