Log In | Get Help   
Home My Page Projects Code Snippets Project Openings Accounting and Billing Portal
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files
[abportal] View of /src/main/java/eu/smartlm/abs/portal/security/login/admin/EditUserController.java
[abportal] / src / main / java / eu / smartlm / abs / portal / security / login / admin / EditUserController.java Repository:
ViewVC logotype

View of /src/main/java/eu/smartlm/abs/portal/security/login/admin/EditUserController.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (download) (annotate)
Wed Jul 28 10:05:51 2010 UTC (13 years, 9 months ago) by dgarcia
File size: 2240 byte(s)
First code commit
package eu.smartlm.abs.portal.security.login.admin;

import javax.portlet.ActionResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.bind.support.SessionStatus;
import org.springframework.web.portlet.bind.annotation.ActionMapping;
import org.springframework.web.portlet.bind.annotation.RenderMapping;

import eu.smartlm.abs.portal.security.login.model.User;
import eu.smartlm.abs.portal.security.login.service.LoginService;

/**
 * Edits the parameters of a User
 * @author David García Pérez - CESGA
 */
@Controller
@RequestMapping("VIEW")
@SessionAttributes("user")
public class EditUserController {
	@Autowired
	@Qualifier("myLoginService")
	private LoginService loginService;
	
	public void setLoginService(LoginService loginService) {
		this.loginService = loginService;
	}
	
	@RenderMapping(params="myaction=editUserForm")
	public String showEditBookForm() {
		return "editUserForm";
	}
	
	/**
	 * Edits an User
	 * @param user
	 * @param bindingResult
	 * @param response
	 * @param sessionStatus
	 */
	@ActionMapping(params="myaction=editUser")
	public void editUser(@ModelAttribute("user") User user, BindingResult bindingResult, ActionResponse response, SessionStatus sessionStatus)  {
		if (!bindingResult.hasErrors()) {
			loginService.editUser(user);
			response.setRenderParameter("myaction", "users");
			sessionStatus.setComplete();
			response.removePublicRenderParameter("user");
		} else {
			response.setRenderParameter("username", user.getUsername());
			response.setRenderParameter("myaction", "editUserForm");
		}
	}
	
	/**
	 * User object that it is created to be passed to the jsp page
	 * @return a User Object
	 */
	@ModelAttribute("user")
	public User getUser(@RequestParam String username) {
		return loginService.getUser(username);
	}
}

root@forge.cesga.es
ViewVC Help
Powered by ViewVC 1.0.0  

Powered By FusionForge