示例#1
0
 /**
  * This method handles GET request and produces JSP page with all branch sections
  *
  * @param session http session that will be initiated
  * @return {@link ModelAndView} with view name as renderAllSection
  */
 @RequestMapping(
     value = {"/", "/sections"},
     method = RequestMethod.GET)
 public ModelAndView sectionList(HttpSession session) {
   /*
   Counting the number of active users based on the number of sessions.
   By default, the session will be initialized after controller's invocation,
   so at the time of request processing, we can miss the session
   if the current request is the first one for a particular user.
   To change a default behavior we call getId() method
   that initializes the session right now.
   If a request from the user is not the first one getId() call will have no effect.
   */
   session.getId();
   return new ModelAndView("sectionList")
       .addObject("pageSize", Pagination.getPageSizeFor(securityService.getCurrentUser()))
       .addObject("sectionList", sectionService.getAll())
       .addObject("breadcrumbList", breadcrumbBuilder.getForumBreadcrumb())
       .addObject("messagesCount", forumStaticsProvider.getPostsOnForumCount())
       .addObject("registeredUsersCount", forumStaticsProvider.getUsersCount())
       .addObject("visitors", forumStaticsProvider.getOnlineUsersCount())
       .addObject("usersRegistered", forumStaticsProvider.getOnlineRegisteredUsers())
       .addObject("visitorsRegistered", forumStaticsProvider.getOnlineRegisteredUsersCount())
       .addObject("visitorsGuests", forumStaticsProvider.getOnlineAnonymousUsersCount());
 }
示例#2
0
 /**
  * Displays to user a list of branches from the chosen section.
  *
  * @param sectionId section for display
  * @return {@code ModelAndView} the chosen section
  * @throws org.jtalks.jcommune.service.exceptions.NotFoundException when section not found
  */
 @RequestMapping(value = "/sections/{sectionId}", method = RequestMethod.GET)
 public ModelAndView branchList(@PathVariable("sectionId") long sectionId)
     throws NotFoundException {
   Section section = sectionService.get(sectionId);
   User user = securityService.getCurrentUser();
   return new ModelAndView("branchList")
       .addObject("section", section)
       .addObject("pageSize", Pagination.getPageSizeFor(user))
       .addObject("breadcrumbList", breadcrumbBuilder.getForumBreadcrumb());
 }