User module


Published on

Published in: Technology
  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

User module

  1. 1. AdminUsers Module – Changesin Web-Layerto use Spring MVC Overview In this module following functions willbe coveredinREL. 1. Show Users List 2. Add New User 3. Edit Existing User 4. Save Changespost Editing 5. Delete Existing User Module functions in Sample Application: The users module inthe sample applicationwill support the followingfunctions exposedbythe listed URLs. # URL Method Description 1 /admin/users/view/{id} /admin/users/view GET Gets the list of users inthis REL application 2 /admin/users/new GET Shows the UI to adda new user. 3 /admin/users/edit/{id} GET Show the UI to edit the info of existing user. 4 /admin/users/delete/{id} POST Deletes the existing user. 5 /admin/users/save POST Saves the informationof new andexisting user. Controller – Create a newfile 'web/'. This class handlesthe "/adminUsers/*" requests. package com.pearson.rel.webapp.controller; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import com.pearson.rel.model.User; @Controller @RequestMapping(value="/adminUsers") public classUsersController { @RequestMapping(value="/view",method= RequestMethod.GET) public String view(User user) { return "userList"; } @RequestMapping(value="/addNew",method= RequestMethod.GET) public String addNew(Modelmodel,User user) { return "userForm"; } @RequestMapping(value="/edit/{userName}",method= RequestMethod.GET) public String edit(Model model,User user){ model.addAttribute("userForm",new User()); return "userForm"; }
  2. 2. @RequestMapping(value="/delete",method = RequestMethod.POST) public String delete(Model model,User user){ return "userList"; } @RequestMapping(value="/save",method= RequestMethod.POST) public String save(Modelmodel,User user) { return "userForm"; } } Models & Services (1) Model: Due to simplicityof requests, noadditional model needs to be added. (2) Service: No changesat the servicesare required. Subtasks (1) Validations : a. To check User withthe same name alreadyexists b. To validate the “password” and“confirm password” fields match. c. Validate mandatoryfields. New functionality - Bulk Import from Spreadsheet Overview: Bulk Import from SpreadSheet: New linkwill be providedadjacent to “Addnew User” onview page. Using this link ,user can import multiple admin users from XLS. After performing the validations, users would be addedto the database. Steps Involved: 1. After clickingon link “BulkImport from SpreadSheet ” a newpage willget openas follows: 2. On UploadSpreadsheet : Uploaded data from XLS will be shown inJquerydata-gridas shownbelow:
  3. 3. 3. After all the validations are validated, onclick of “Save” buttonnew adminusers will be savedin “appUser” table in Relational database. 4. After saving indatabase, updatedstatus of the user will be shownas follows: Module Functions: # URL Method Description 1 /adminUsers/downloadTemplate GET Downloads a newXLS template to enter the user records 2 /adminUsers/uploadSpreadSheet POST Uploads the XLS file and show the records inData Grid on UI. 3 /adminUsers/saveAllUsers POST Saves allthe validated users in datatbase. 4 /adminUsers/editSheetUser POST Edits the selecteduser in the data grid. 5 /adminUsers/deleteSheetUser POST Deletes the selecteduser from the grid Controller Changes – New functions will be added in UserController to achieve the above functionality is as follows: @RequestMapping(value="/downloadTemplate",method= RequestMethod.GET) public String downloadTemplate(Model model,User user) { return "downloadTemplate"; } @RequestMapping(value="/uploadSpreadSheet",method= RequestMethod.POST) public String uploadSpreadSheet(Model model,User user) { return "jsonView"; } @RequestMapping(value="/saveAllUsers",method= RequestMethod.POST) public String saveAllUsers(Model model,User user) {
  4. 4. return "successUsers"; } @RequestMapping(value="/editSheetUser",method= RequestMethod.POST) public String editSheetUser(Model model,User user) { return "jsonView"; } @RequestMapping(value="/deleteSheetUser",method= RequestMethod.POST) public String deleteSheetUser(Model model,User user) { return "jsonView"; } Models & Services (1) Model: No additionalmodel needs to be added. (2) Service: Service that requires modification: service/ (3) Helper: A new Helper class that needs to be added:web/BulkImportUserHelper”.