protected boolean addCategoryListToModel( List<Category> categoryList, Category rootCategory, String url, ModelMap model) { boolean categoryError = false; while (categoryList == null) { categoryError = true; int pos = url.indexOf("/"); if (pos == -1) { categoryList = new ArrayList<Category>(1); categoryList.add(rootCategory); } else { url = url.substring(0, url.lastIndexOf("/")); List<Long> categoryIdList = catalogService.getChildCategoryURLMapByCategoryId(rootCategory.getId()).get(url); if (categoryIdList != null) { categoryList = new ArrayList<Category>(categoryIdList.size()); for (Long id : categoryIdList) { categoryList.add(catalogService.findCategoryById(id)); } } } } List<Category> siblingCategories = new ArrayList<Category>(); Category currentCategory = (Category) categoryList.get(categoryList.size() - 1); siblingCategories = currentCategory.getAllChildCategories(); model.addAttribute("breadcrumbCategories", categoryList); model.addAttribute("currentCategory", categoryList.get(categoryList.size() - 1)); model.addAttribute("categoryError", categoryError); model.addAttribute("displayCategories", siblingCategories); return categoryError; }