Index: lams_central/conf/xdoclet/struts-forms.xml =================================================================== diff -u --- lams_central/conf/xdoclet/struts-forms.xml (revision 0) +++ lams_central/conf/xdoclet/struts-forms.xml (revision a909454acb3505c97f39fbf6d0e2776ea8ffa3c4) @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file Index: lams_central/src/java/org/lamsfoundation/lams/web/ProfileAction.java =================================================================== diff -u -rd6a38dbb0ca18f505c89ad7c4bb79ffbe185ec39 -ra909454acb3505c97f39fbf6d0e2776ea8ffa3c4 --- lams_central/src/java/org/lamsfoundation/lams/web/ProfileAction.java (.../ProfileAction.java) (revision d6a38dbb0ca18f505c89ad7c4bb79ffbe185ec39) +++ lams_central/src/java/org/lamsfoundation/lams/web/ProfileAction.java (.../ProfileAction.java) (revision a909454acb3505c97f39fbf6d0e2776ea8ffa3c4) @@ -22,13 +22,24 @@ */ package org.lamsfoundation.lams.web; +import java.util.Collections; +import java.util.List; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.apache.struts.action.Action; +import org.apache.commons.beanutils.BeanUtils; +import org.apache.log4j.Logger; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; +import org.apache.struts.action.DynaActionForm; +import org.lamsfoundation.lams.usermanagement.SupportedLocale; +import org.lamsfoundation.lams.usermanagement.User; +import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; +import org.lamsfoundation.lams.web.action.LamsDispatchAction; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.context.support.WebApplicationContextUtils; /** * @version @@ -43,15 +54,56 @@ */ /** - * @struts.action path="/profile" - * validation="false" + * @struts:action path="/profile" + * name="UserForm" + * scope="request" + * parameter="method" + * validate="false" * - * @struts.action-forward name="profile" - * path="/profile.jsp" + * @struts:action-forward name="view" path=".profile" + * @struts:action-forward name="edit" path=".editprofile" */ -public class ProfileAction extends Action { +public class ProfileAction extends LamsDispatchAction { - public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception{ - return mapping.findForward("profile"); + private static Logger log = Logger.getLogger(ProfileAction.class); + private static IUserManagementService service; + private static List locales; + + public ActionForward view(ActionMapping mapping, + ActionForm form, + HttpServletRequest request, + HttpServletResponse response) throws Exception { + + User requestor = (User)getService().getUserByLogin(request.getRemoteUser()); + String fullName = requestor.getTitle()+" "+requestor.getFirstName()+" "+requestor.getLastName(); + + request.setAttribute("fullName", fullName); + request.setAttribute("email", requestor.getEmail()); + return mapping.findForward("view"); } + + public ActionForward edit(ActionMapping mapping, + ActionForm form, + HttpServletRequest request, + HttpServletResponse response) throws Exception { + + User requestor = (User)getService().getUserByLogin(request.getRemoteUser()); + log.debug("editing profile of userId: "+requestor.getUserId()); + DynaActionForm userForm = (DynaActionForm)form; + BeanUtils.copyProperties(userForm, requestor); + SupportedLocale locale = getService().getSupportedLocale(requestor.getLocaleLanguage(),requestor.getLocaleCountry()); + userForm.set("localeId",locale.getLocaleId()); + request.setAttribute("locales", locales); + return mapping.findForward("edit"); + } + + private IUserManagementService getService(){ + if(service==null){ + WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet().getServletContext()); + service = (IUserManagementService) ctx.getBean("userManagementServiceTarget"); + locales = getService().findAll(SupportedLocale.class); + Collections.sort(locales); + } + return service; + } } Index: lams_central/src/java/org/lamsfoundation/lams/web/ProfileSaveAction.java =================================================================== diff -u --- lams_central/src/java/org/lamsfoundation/lams/web/ProfileSaveAction.java (revision 0) +++ lams_central/src/java/org/lamsfoundation/lams/web/ProfileSaveAction.java (revision a909454acb3505c97f39fbf6d0e2776ea8ffa3c4) @@ -0,0 +1,87 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +/* $Id$ */ +package org.lamsfoundation.lams.web; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.beanutils.BeanUtils; +import org.apache.log4j.Logger; +import org.apache.struts.action.Action; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.action.DynaActionForm; +import org.lamsfoundation.lams.usermanagement.User; +import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.context.support.WebApplicationContextUtils; + +/** + * @author jliew + * + */ + +/** + * @struts:action path="/saveprofile" + * name="UserForm" + * input=".editprofile" + * scope="request" + * validate="false" + * + * @struts:action-forward name="profile" path="/profile.do?method=view" + */ +public class ProfileSaveAction extends Action { + + private static Logger log = Logger.getLogger(ProfileSaveAction.class); + private static IUserManagementService service; + + public ActionForward execute(ActionMapping mapping, + ActionForm form, + HttpServletRequest request, + HttpServletResponse response) throws Exception { + + if(isCancelled(request)){ + return mapping.findForward("profile"); + } + + User requestor = (User)getService().getUserByLogin(request.getRemoteUser()); + DynaActionForm userForm = (DynaActionForm)form; + BeanUtils.copyProperties(requestor,userForm); + getService().save(requestor); + log.debug("profile edited: "+requestor); + + return mapping.findForward("profile"); + } + + private IUserManagementService getService(){ + if(service==null){ + WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet().getServletContext()); + service = (IUserManagementService) ctx.getBean("userManagementServiceTarget"); + } + return service; + } + +} Index: lams_central/web/WEB-INF/tiles/tiles-defs.xml =================================================================== diff -u -r7a1f51f64555f4cd94274847196373c7f9f549f0 -ra909454acb3505c97f39fbf6d0e2776ea8ffa3c4 --- lams_central/web/WEB-INF/tiles/tiles-defs.xml (.../tiles-defs.xml) (revision 7a1f51f64555f4cd94274847196373c7f9f549f0) +++ lams_central/web/WEB-INF/tiles/tiles-defs.xml (.../tiles-defs.xml) (revision a909454acb3505c97f39fbf6d0e2776ea8ffa3c4) @@ -22,6 +22,16 @@ --> + + + + + + + + + + Index: lams_central/web/editprofile.jsp =================================================================== diff -u --- lams_central/web/editprofile.jsp (revision 0) +++ lams_central/web/editprofile.jsp (revision a909454acb3505c97f39fbf6d0e2776ea8ffa3c4) @@ -0,0 +1,99 @@ +<%@ page contentType="text/html; charset=utf-8" language="java" %> + +<%@ taglib uri="tags-html" prefix="html" %> +<%@ taglib uri="tags-core" prefix="c" %> +<%@ taglib uri="tags-bean" prefix="bean" %> +<%@ taglib uri="tags-logic" prefix="logic" %> +<%@ taglib uri="tags-fmt" prefix="fmt" %> + +

+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
: + + + + + + + +
+ + + +
+
\ No newline at end of file Index: lams_central/web/profile.jsp =================================================================== diff -u -rd5c91b39c576e63a3325ce60e154b14e23c4dbef -ra909454acb3505c97f39fbf6d0e2776ea8ffa3c4 --- lams_central/web/profile.jsp (.../profile.jsp) (revision d5c91b39c576e63a3325ce60e154b14e23c4dbef) +++ lams_central/web/profile.jsp (.../profile.jsp) (revision a909454acb3505c97f39fbf6d0e2776ea8ffa3c4) @@ -1,20 +1,15 @@ <%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=utf-8" %> <%@ taglib uri="tags-lams" prefix="lams" %> +<%@ taglib uri="tags-bean" prefix="bean" %> - - - - LAMS::Profile - - +

My Profile

- -
-
-

In construction

-
- -
- - - \ No newline at end of file +

Name:
+Email: +

+ +

Edit My Profile
+Change my password
+Update my portrait
+[My Courses] +

\ No newline at end of file