// Submit Add Form For: Role @RequestMapping(value = "/add_role", method = RequestMethod.POST) public ModelAndView insertNewUser(HttpServletRequest request) { HttpSession sess = request.getSession(); SessionHelper sh = new SessionHelper(); ModelAndView model = null; // Get User Data Access Object to Manage Session User UserDAO userSessionDAO = new UserDAO(); // Get Data Access Object For: Role RoleDAO roleDAO = new RoleDAO(); // Validate session if (!sh.isValidSession(sess)) { // If invalid session, redirect to login page model = new ModelAndView("login"); // Set redirect back to new form for: Role model.addObject("redirectTo", "/add_role"); // Error Message: Invalid session model.addObject("errmsg", "Invalid Session: User record not created."); } else { // TODO Get All Attributes From Form // TODO Populate Object with Attributes For: Role // TODO Insert Base Object For: Role // Redirect to list for: Role // Include standard filter for: role model = new ModelAndView("redirect:/role_list?query=" + userSessionDAO.getUsersFilter("Role")); } return model; }
// Display Add Form For: Role @RequestMapping(value = "/add_role", method = RequestMethod.GET) public ModelAndView displayNewUser(HttpServletRequest request) { HttpSession sess = request.getSession(); SessionHelper sh = new SessionHelper(); ModelAndView model = null; // Get User Data Access Object to Manage Session User UserDAO userSessionDAO = new UserDAO(); // Validate session if (!sh.isValidSession(sess)) { // If invalid session, redirect to login page model = new ModelAndView("login"); // Set redirect back to new form for: Role model.addObject("redirectTo", "/add_role"); // Error Message: Invalid session model.addObject("errmsg", "Invalid Session: Please log in."); } else { // Call Form View For: Role model = new ModelAndView("role_form"); // Pass session user to View model.addObject("sessionUser", userSessionDAO.getSessionUser(sess)); // Pass Operation of New model.addObject("operation", "new"); } return model; }
// Display Update Form For: Role @RequestMapping( value = "/upate_role", params = {"id"}, method = RequestMethod.GET) public ModelAndView displayExistingUser( HttpServletRequest request, @RequestParam(value = "id") Integer id) { HttpSession sess = request.getSession(); SessionHelper sh = new SessionHelper(); ModelAndView model = null; // Get User Data Access Object to Manage Session User UserDAO userSessionDAO = new UserDAO(); // Validate session if (!sh.isValidSession(sess)) { // If invalid session, redirect to login page model = new ModelAndView("login"); // Set redirect back to existing form for: Role model.addObject("redirectTo", "/update_role?id=" + id.toString()); // Error Message: Invalid session model.addObject("errmsg", "Invalid Session: Please log in."); } else { // Call Form View For: Role model = new ModelAndView("role_form"); // Pass session user to View model.addObject("sessionUser", userSessionDAO.getSessionUser(sess)); // Pass Operation of Update model.addObject("operation", "update"); } return model; }
// Display List For: Role @RequestMapping( value = "/role_list", params = {"query"}, method = RequestMethod.GET) public ModelAndView displayList( HttpServletRequest request, @RequestParam(value = "query") String query) { HttpSession sess = request.getSession(); SessionHelper sh = new SessionHelper(); ModelAndView model = null; // Get User Data Access Object to Manage Session User UserDAO userSessionDAO = new UserDAO(); // Get Data Access Object For: Role RoleDAO roleDAO = new RoleDAO(); // Validate Session if (!sh.isValidSession(sess)) { // If invalid session, redirect to login page model = new ModelAndView("login"); // Set redirect back to list for: Role model.addObject("redirectTo", "/role_list?query=" + query); // Error Message: Invalid session model.addObject("errmsg", "Invalid Session: Please log in."); } else { // Get ArrayList From Query For: Role ArrayList<Role> roleList = roleDAO.getListByQuery(query); // Update session user's personalized filter from the provided query for: Role userSessionDAO.updateUsersFilter("Role", query); // Call List View For: Role model = new ModelAndView("role_list"); // Pass session user to View model.addObject("sessionUser", userSessionDAO.getSessionUser(sess)); // Pass ArrayList to View For: Role model.addObject("roleList", roleList); } return model; }