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] Annotation 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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (view) (download)

1 : dgarcia 1 package eu.smartlm.abs.portal.security.login.admin;
2 :    
3 :     import javax.portlet.ActionResponse;
4 :    
5 :     import org.springframework.beans.factory.annotation.Autowired;
6 :     import org.springframework.beans.factory.annotation.Qualifier;
7 :     import org.springframework.stereotype.Controller;
8 :     import org.springframework.validation.BindingResult;
9 :     import org.springframework.web.bind.annotation.ModelAttribute;
10 :     import org.springframework.web.bind.annotation.RequestMapping;
11 :     import org.springframework.web.bind.annotation.RequestParam;
12 :     import org.springframework.web.bind.annotation.SessionAttributes;
13 :     import org.springframework.web.bind.support.SessionStatus;
14 :     import org.springframework.web.portlet.bind.annotation.ActionMapping;
15 :     import org.springframework.web.portlet.bind.annotation.RenderMapping;
16 :    
17 :     import eu.smartlm.abs.portal.security.login.model.User;
18 :     import eu.smartlm.abs.portal.security.login.service.LoginService;
19 :    
20 :     /**
21 :     * Edits the parameters of a User
22 :     * @author David García Pérez - CESGA
23 :     */
24 :     @Controller
25 :     @RequestMapping("VIEW")
26 :     @SessionAttributes("user")
27 :     public class EditUserController {
28 :     @Autowired
29 :     @Qualifier("myLoginService")
30 :     private LoginService loginService;
31 :    
32 :     public void setLoginService(LoginService loginService) {
33 :     this.loginService = loginService;
34 :     }
35 :    
36 :     @RenderMapping(params="myaction=editUserForm")
37 :     public String showEditBookForm() {
38 :     return "editUserForm";
39 :     }
40 :    
41 :     /**
42 :     * Edits an User
43 :     * @param user
44 :     * @param bindingResult
45 :     * @param response
46 :     * @param sessionStatus
47 :     */
48 :     @ActionMapping(params="myaction=editUser")
49 :     public void editUser(@ModelAttribute("user") User user, BindingResult bindingResult, ActionResponse response, SessionStatus sessionStatus) {
50 :     if (!bindingResult.hasErrors()) {
51 :     loginService.editUser(user);
52 :     response.setRenderParameter("myaction", "users");
53 :     sessionStatus.setComplete();
54 :     response.removePublicRenderParameter("user");
55 :     } else {
56 :     response.setRenderParameter("username", user.getUsername());
57 :     response.setRenderParameter("myaction", "editUserForm");
58 :     }
59 :     }
60 :    
61 :     /**
62 :     * User object that it is created to be passed to the jsp page
63 :     * @return a User Object
64 :     */
65 :     @ModelAttribute("user")
66 :     public User getUser(@RequestParam String username) {
67 :     return loginService.getUser(username);
68 :     }
69 :     }

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

Powered By FusionForge