@RequestMapping(method = RequestMethod.GET) public String search( @PathVariable String language, @Validated ArticleSearchForm form, BindingResult result, @PageableDefault(50) Pageable pageable, Model model, HttpSession session) { Page<Article> articles = articleService.readArticles(form.toArticleSearchRequest(), pageable); new DomainObjectSearchCondition<>(session, form, pageable); model.addAttribute("form", form); model.addAttribute("articles", articles); model.addAttribute("pageable", pageable); UriComponentsBuilder builder = UriComponentsBuilder.fromPath(Application.ADMIN_SERVLET_PATH); builder.path("/{language}/articles/index"); builder.queryParams(form.toQueryParams()); String url = builder.buildAndExpand(language).toString(); model.addAttribute("pagination", new Pagination<>(articles, url)); return "article/index"; }
@ModelAttribute("countPublished") public long countPublished(@PathVariable String language) { return articleService.countArticlesByStatus(Post.Status.PUBLISHED, language); }
@ModelAttribute("countDraft") public long countDraft(@PathVariable String language) { return articleService.countArticlesByStatus(Post.Status.DRAFT, language); }
@ModelAttribute("countScheduled") public long countScheduled(@PathVariable String language) { return articleService.countArticlesByStatus(Post.Status.SCHEDULED, language); }
@ModelAttribute("countAll") public long countAll(@PathVariable String language) { return articleService.countArticles(language); }