com.in28minutes.web.common.util.TodoListUtils Java Examples
The following examples show how to use
com.in28minutes.web.common.util.TodoListUtils.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ListTodoServlet.java From MavenIn28Minutes with MIT License | 6 votes |
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(); User user = (User) session.getAttribute(TodoListUtils.SESSION_USER); TodoItemList todoList = todoService.getTodoListByUser(user.getId()); // todo list is request scoped to avoid storing and synchronizing it in // session for each CRUD operation request.setAttribute("todoList", todoList.getItems()); request.setAttribute("homeTabStyle", "active"); request.setAttribute("totalCount", todoList.getCount()); request.setAttribute("doneCount", todoList.getDoneCount()); request.setAttribute("todoCount", todoList.getTodoCount()); request.getRequestDispatcher(HOME_PAGE).forward(request, response); }
Example #2
Source File: ListTodoServlet.java From RealWorldWebApplicationWithServletsAndJspIn28Minutes with MIT License | 6 votes |
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(); User user = (User) session.getAttribute(TodoListUtils.SESSION_USER); TodoItemList todoList = todoService.getTodoListByUser(user.getId()); // todo list is request scoped to avoid storing and synchronizing it in // session for each CRUD operation request.setAttribute("todoList", todoList.getItems()); request.setAttribute("homeTabStyle", "active"); request.setAttribute("totalCount", todoList.getCount()); request.setAttribute("doneCount", todoList.getDoneCount()); request.setAttribute("todoCount", todoList.getTodoCount()); request.getRequestDispatcher(HOME_PAGE).forward(request, response); }
Example #3
Source File: StatusStyleTag.java From SpringIn28Minutes with MIT License | 5 votes |
@Override public void doTag() throws JspException, IOException { JspWriter out = getJspContext().getOut(); String statusStyle = TodoListUtils.getStatusStyle(status); out.print(statusStyle); }
Example #4
Source File: PriorityIconTag.java From RealWorldWebApplicationWithServletsAndJspIn28Minutes with MIT License | 5 votes |
@Override public void doTag() throws JspException, IOException { JspWriter out = getJspContext().getOut(); String priorityIcon = TodoListUtils.getPriorityIcon(Priority .valueOf(priority)); out.print(priorityIcon); }
Example #5
Source File: StatusLabelTag.java From RealWorldWebApplicationWithServletsAndJspIn28Minutes with MIT License | 5 votes |
@Override public void doTag() throws JspException, IOException { JspWriter out = getJspContext().getOut(); String statusLabel = TodoListUtils.getStatusLabel(status); out.print(statusLabel); }
Example #6
Source File: StatusStyleTag.java From RealWorldWebApplicationWithServletsAndJspIn28Minutes with MIT License | 5 votes |
@Override public void doTag() throws JspException, IOException { JspWriter out = getJspContext().getOut(); String statusStyle = TodoListUtils.getStatusStyle(status); out.print(statusStyle); }
Example #7
Source File: SessionCheckFilter.java From RealWorldWebApplicationWithServletsAndJspIn28Minutes with MIT License | 5 votes |
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException { HttpServletRequest req = (HttpServletRequest) request; HttpSession session = req.getSession(); User user = (User) session.getAttribute(TodoListUtils.SESSION_USER); if (user != null) { chain.doFilter(request, response); } else { request.getRequestDispatcher(LOGIN_PAGE).forward(request, response); } }
Example #8
Source File: LoginServlet.java From RealWorldWebApplicationWithServletsAndJspIn28Minutes with MIT License | 5 votes |
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String email = request.getParameter("email"); String password = request.getParameter("password"); LoginForm loginForm = new LoginForm(); loginForm.setEmail(email); loginForm.setPassword(password); validateCredentials(request, loginForm); if (isInvalid(request)) { request.getRequestDispatcher(LOGIN_PAGE).forward(request, response); return; } if (isValidUser(email, password)) { request.setAttribute("error", resourceBundle.getString("login.form.invalid.credentials")); request.getRequestDispatcher(LOGIN_PAGE).forward(request, response); return; } HttpSession session = request.getSession(true);// create session User user = userService.getUserByEmail(email); session.setAttribute(TodoListUtils.SESSION_USER, user); request.getRequestDispatcher(REDIRECT_HOME_PAGE).forward(request, response); }
Example #9
Source File: CreateTodoServlet.java From RealWorldWebApplicationWithServletsAndJspIn28Minutes with MIT License | 5 votes |
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setAttribute("today", new SimpleDateFormat( TodoListUtils.DATE_FORMAT).format(new Date())); request.getRequestDispatcher(CREATE_TODO_PAGE).forward(request, response); }
Example #10
Source File: PriorityIconTag.java From SpringIn28Minutes with MIT License | 5 votes |
@Override public void doTag() throws JspException, IOException { JspWriter out = getJspContext().getOut(); String priorityIcon = TodoListUtils.getPriorityIcon(Priority .valueOf(priority)); out.print(priorityIcon); }
Example #11
Source File: StatusLabelTag.java From SpringIn28Minutes with MIT License | 5 votes |
@Override public void doTag() throws JspException, IOException { JspWriter out = getJspContext().getOut(); String statusLabel = TodoListUtils.getStatusLabel(status); out.print(statusLabel); }
Example #12
Source File: CreateTodoServlet.java From MavenIn28Minutes with MIT License | 5 votes |
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setAttribute("today", new SimpleDateFormat( TodoListUtils.DATE_FORMAT).format(new Date())); request.getRequestDispatcher(CREATE_TODO_PAGE).forward(request, response); }
Example #13
Source File: TodoController.java From SpringIn28Minutes with MIT License | 5 votes |
@RequestMapping(value = "/user/todos/new", method = RequestMethod.GET) public String showCreateTodo(Model model) { model.addAttribute("today", new SimpleDateFormat( TodoListUtils.DATE_FORMAT).format(new Date())); model.addAttribute("todo", new TodoItem()); return "todo/create"; }
Example #14
Source File: TodoController.java From SpringIn28Minutes with MIT License | 5 votes |
@InitBinder public void initBinder(WebDataBinder binder) { SimpleDateFormat dateFormat = new SimpleDateFormat( TodoListUtils.DATE_FORMAT); binder.registerCustomEditor(Date.class, new CustomDateEditor( dateFormat, false)); binder.registerCustomEditor(Priority.class, new TodoPriorityPropertyEditor()); }
Example #15
Source File: PriorityIconTag.java From MavenIn28Minutes with MIT License | 5 votes |
@Override public void doTag() throws JspException, IOException { JspWriter out = getJspContext().getOut(); String priorityIcon = TodoListUtils.getPriorityIcon(Priority .valueOf(priority)); out.print(priorityIcon); }
Example #16
Source File: StatusLabelTag.java From MavenIn28Minutes with MIT License | 5 votes |
@Override public void doTag() throws JspException, IOException { JspWriter out = getJspContext().getOut(); String statusLabel = TodoListUtils.getStatusLabel(status); out.print(statusLabel); }
Example #17
Source File: StatusStyleTag.java From MavenIn28Minutes with MIT License | 5 votes |
@Override public void doTag() throws JspException, IOException { JspWriter out = getJspContext().getOut(); String statusStyle = TodoListUtils.getStatusStyle(status); out.print(statusStyle); }
Example #18
Source File: SessionCheckFilter.java From MavenIn28Minutes with MIT License | 5 votes |
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException { HttpServletRequest req = (HttpServletRequest) request; HttpSession session = req.getSession(); User user = (User) session.getAttribute(TodoListUtils.SESSION_USER); if (user != null) { chain.doFilter(request, response); } else { request.getRequestDispatcher(LOGIN_PAGE).forward(request, response); } }
Example #19
Source File: LoginServlet.java From MavenIn28Minutes with MIT License | 5 votes |
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String email = request.getParameter("email"); String password = request.getParameter("password"); LoginForm loginForm = new LoginForm(); loginForm.setEmail(email); loginForm.setPassword(password); validateCredentials(request, loginForm); if (isInvalid(request)) { request.getRequestDispatcher(LOGIN_PAGE).forward(request, response); return; } if (isValidUser(email, password)) { request.setAttribute("error", resourceBundle.getString("login.form.invalid.credentials")); request.getRequestDispatcher(LOGIN_PAGE).forward(request, response); return; } HttpSession session = request.getSession(true);// create session User user = userService.getUserByEmail(email); session.setAttribute(TodoListUtils.SESSION_USER, user); request.getRequestDispatcher(REDIRECT_HOME_PAGE).forward(request, response); }
Example #20
Source File: CreateTodoServlet.java From RealWorldWebApplicationWithServletsAndJspIn28Minutes with MIT License | 4 votes |
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(); User user = (User) session.getAttribute(TodoListUtils.SESSION_USER); String title = request.getParameter("title"); String dueDate = request.getParameter("dueDate"); String priority = request.getParameter("priority"); TodoItem todoItem = new TodoItem(user.getId(), title, false, Priority.valueOf(priority), new Date(dueDate)); todoService.create(todoItem); request.getRequestDispatcher("/todos").forward(request, response); }
Example #21
Source File: CreateTodoServlet.java From MavenIn28Minutes with MIT License | 4 votes |
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(); User user = (User) session.getAttribute(TodoListUtils.SESSION_USER); String title = request.getParameter("title"); String dueDate = request.getParameter("dueDate"); String priority = request.getParameter("priority"); TodoItem todoItem = new TodoItem(user.getId(), title, false, Priority.valueOf(priority), new Date(dueDate)); todoService.create(todoItem); request.getRequestDispatcher("/todos").forward(request, response); }
Example #22
Source File: LoginServlet.java From RealWorldWebApplicationWithServletsAndJspIn28Minutes with MIT License | 3 votes |
private boolean doesValidSessionExist(HttpServletRequest request) { HttpSession session = request.getSession(false); if (session != null) { User user = (User) session.getAttribute(TodoListUtils.SESSION_USER); if (user != null) { return true; } } return false; }
Example #23
Source File: LoginServlet.java From MavenIn28Minutes with MIT License | 3 votes |
private boolean doesValidSessionExist(HttpServletRequest request) { HttpSession session = request.getSession(false); if (session != null) { User user = (User) session.getAttribute(TodoListUtils.SESSION_USER); if (user != null) { return true; } } return false; }