Index: lams_central/conf/xdoclet/struts-forms.xml =================================================================== RCS file: /usr/local/cvsroot/lams_central/conf/xdoclet/struts-forms.xml,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_central/conf/xdoclet/struts-forms.xml 10 Aug 2006 04:05:13 -0000 1.1 @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file Index: lams_central/src/java/org/lamsfoundation/lams/web/ProfileAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/web/ProfileAction.java,v diff -u -r1.1 -r1.2 --- lams_central/src/java/org/lamsfoundation/lams/web/ProfileAction.java 28 Jun 2006 05:16:58 -0000 1.1 +++ lams_central/src/java/org/lamsfoundation/lams/web/ProfileAction.java 10 Aug 2006 04:05:13 -0000 1.2 @@ -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 =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/web/ProfileSaveAction.java,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_central/src/java/org/lamsfoundation/lams/web/ProfileSaveAction.java 10 Aug 2006 04:05:13 -0000 1.1 @@ -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: ProfileSaveAction.java,v 1.1 2006/08/10 04:05:13 jliew Exp $ */ +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/editprofile.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/editprofile.jsp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_central/web/editprofile.jsp 10 Aug 2006 04:05:13 -0000 1.1 @@ -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 =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/profile.jsp,v diff -u -r1.1 -r1.2 --- lams_central/web/profile.jsp 28 Jun 2006 05:17:24 -0000 1.1 +++ lams_central/web/profile.jsp 10 Aug 2006 04:05:13 -0000 1.2 @@ -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 Index: lams_central/web/WEB-INF/tiles/tiles-defs.xml =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/WEB-INF/tiles/Attic/tiles-defs.xml,v diff -u -r1.5 -r1.6 --- lams_central/web/WEB-INF/tiles/tiles-defs.xml 23 Jun 2006 08:01:10 -0000 1.5 +++ lams_central/web/WEB-INF/tiles/tiles-defs.xml 10 Aug 2006 04:05:50 -0000 1.6 @@ -22,6 +22,16 @@ --> + + + + + + + + + +