Review Board 1.7.22


Refactor common navbar into header.tag

Review Request #4930 - Created April 29, 2012 and submitted

Chris Geer
RAVE-586
Reviewers
rave
rave
Refactored the common navbar components to the header.tag file and included that in all relevant jsp files (except mobile). I also expanded the NavigationItem code to handle parameters for the navigation item text. Moved menu generation code to the ControllerUtils class. This should eventually be loaded from a DB per ticket RAVE-589
Went through all screens to verify items showed as expected and had the correct links.
/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/PageController.java
Revision 1331506 New Change
[20] 22 lines
[+20]
23
import org.apache.rave.portal.model.User;
23
import org.apache.rave.portal.model.User;
24
import org.apache.rave.portal.service.PageLayoutService;
24
import org.apache.rave.portal.service.PageLayoutService;
25
import org.apache.rave.portal.service.PageService;
25
import org.apache.rave.portal.service.PageService;
26
import org.apache.rave.portal.service.UserService;
26
import org.apache.rave.portal.service.UserService;
27
import org.apache.rave.portal.web.controller.util.ControllerUtils;
27
import org.apache.rave.portal.web.controller.util.ControllerUtils;

    
   
28
import org.apache.rave.portal.web.model.NavigationItem;

    
   
29
import org.apache.rave.portal.web.model.NavigationMenu;
28
import org.apache.rave.portal.web.util.ModelKeys;
30
import org.apache.rave.portal.web.util.ModelKeys;
29
import org.apache.rave.portal.web.util.ViewNames;
31
import org.apache.rave.portal.web.util.ViewNames;
30
import org.slf4j.Logger;
32
import org.slf4j.Logger;
31
import org.slf4j.LoggerFactory;
33
import org.slf4j.LoggerFactory;
32
import org.springframework.beans.factory.annotation.Autowired;
34
import org.springframework.beans.factory.annotation.Autowired;
[+20] [20] 36 lines
[+20] [+] public String login() {
69
    public String viewDefault(Model model, HttpServletRequest request) {
71
    public String viewDefault(Model model, HttpServletRequest request) {
70
        List<Page> pages = getAllPagesForAuthenticatedUser();
72
        List<Page> pages = getAllPagesForAuthenticatedUser();
71
        Page page = pageService.getDefaultPageFromList(pages);
73
        Page page = pageService.getDefaultPageFromList(pages);
72
        List<PageLayout> pageLayouts = pageLayoutService.getAllUserSelectable();
74
        List<PageLayout> pageLayouts = pageLayoutService.getAllUserSelectable();
73
        addAttributesToModel(model, page, pages, pageLayouts);
75
        addAttributesToModel(model, page, pages, pageLayouts);
74
        return ControllerUtils.getDeviceAppropriateView(request, ViewNames.getPageView(page.getPageLayout().getCode()), ViewNames.MOBILE_HOME);
76
        String view = ControllerUtils.getDeviceAppropriateView(request, ViewNames.getPageView(page.getPageLayout().getCode()), ViewNames.MOBILE_HOME);

    
   
77
        ControllerUtils.addNavItemsToModel(view, model, page.getEntityId(), userService.getAuthenticatedUser());

    
   
78
        return view;
75
    }          
79
    }          
76
    
80
    
77
    @RequestMapping(value = "/page/view/{pageId}", method = RequestMethod.GET)
81
    @RequestMapping(value = "/page/view/{pageId}", method = RequestMethod.GET)
78
    public String view(@PathVariable Long pageId, Model model, HttpServletRequest request) {
82
    public String view(@PathVariable Long pageId, Model model, HttpServletRequest request) {
79
        User user = userService.getAuthenticatedUser();
83
        User user = userService.getAuthenticatedUser();
80
        logger.debug("attempting to get pageId {} for {}", pageId, user);
84
        logger.debug("attempting to get pageId {} for {}", pageId, user);
81
        
85
        
82
        List<Page> pages = getAllPagesForAuthenticatedUser();
86
        List<Page> pages = getAllPagesForAuthenticatedUser();
83
        Page page = pageService.getPageFromList(pageId, pages);
87
        Page page = pageService.getPageFromList(pageId, pages);
84
        List<PageLayout> pageLayouts = pageLayoutService.getAllUserSelectable();
88
        List<PageLayout> pageLayouts = pageLayoutService.getAllUserSelectable();
85
        addAttributesToModel(model, page, pages, pageLayouts);
89
        addAttributesToModel(model, page, pages, pageLayouts);
86
        return ControllerUtils.getDeviceAppropriateView(request, ViewNames.getPageView(page.getPageLayout().getCode()), ViewNames.MOBILE_HOME);
90
        String view = ControllerUtils.getDeviceAppropriateView(request, ViewNames.getPageView(page.getPageLayout().getCode()), ViewNames.MOBILE_HOME);

    
   
91
        ControllerUtils.addNavItemsToModel(view, model, page.getEntityId(), user);

    
   
92
        return view;
87
    }
93
    }
88
    
94
    
89
    private List<Page> getAllPagesForAuthenticatedUser() {
95
    private List<Page> getAllPagesForAuthenticatedUser() {
90
        User user = userService.getAuthenticatedUser();
96
        User user = userService.getAuthenticatedUser();
91
        long userId = user.getEntityId();
97
        long userId = user.getEntityId();
[+20] [20] 11 lines
[+20] public String view(@PathVariable Long pageId, Model model, HttpServletRequest request) {
103
    private void addAttributesToModel(Model model, Page page, List<Page> pages, List<PageLayout> pageLayouts) {
109
    private void addAttributesToModel(Model model, Page page, List<Page> pages, List<PageLayout> pageLayouts) {
104
        model.addAttribute(ModelKeys.PAGE, page);
110
        model.addAttribute(ModelKeys.PAGE, page);
105
        model.addAttribute(ModelKeys.PAGES, pages);
111
        model.addAttribute(ModelKeys.PAGES, pages);
106
        model.addAttribute(ModelKeys.PAGE_LAYOUTS, pageLayouts);
112
        model.addAttribute(ModelKeys.PAGE_LAYOUTS, pageLayouts);
107
    }
113
    }

    
   
114

   

    
   
115

   
108
}
116
}
/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/ProfileController.java
Revision 1331506 New Change
 
/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/WidgetStoreController.java
Revision 1331506 New Change
 
/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/admin/AdminControllerUtil.java
Revision 1331506 New Change
 
/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/util/ControllerUtils.java
Revision 1331506 New Change
 
/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/model/NavigationItem.java
Revision 1331506 New Change
 
/trunk/rave-components/rave-web/src/test/java/org/apache/rave/portal/web/model/NavigationItemTest.java
Revision 1331506 New Change
 
/trunk/rave-components/rave-web/src/test/java/org/apache/rave/portal/web/model/NavigationMenuTest.java
Revision 1331506 New Change
 
/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/addwidget.jsp
Revision 1331506 New Change
 
/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/page.jsp
Revision 1331506 New Change
 
/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/personProfile.jsp
Revision 1331506 New Change
 
/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/store.jsp
Revision 1331506 New Change
 
/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/widget.jsp
Revision 1331506 New Change
 
/trunk/rave-portal-resources/src/main/webapp/WEB-INF/tags/header.tag
Revision 1331506 New Change
 
  1. /trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/PageController.java: Loading...
  2. /trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/ProfileController.java: Loading...
  3. /trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/WidgetStoreController.java: Loading...
  4. /trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/admin/AdminControllerUtil.java: Loading...
  5. /trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/util/ControllerUtils.java: Loading...
  6. /trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/model/NavigationItem.java: Loading...
  7. /trunk/rave-components/rave-web/src/test/java/org/apache/rave/portal/web/model/NavigationItemTest.java: Loading...
  8. /trunk/rave-components/rave-web/src/test/java/org/apache/rave/portal/web/model/NavigationMenuTest.java: Loading...
  9. /trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/addwidget.jsp: Loading...
  10. /trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/page.jsp: Loading...
  11. /trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/personProfile.jsp: Loading...
  12. /trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/store.jsp: Loading...
  13. /trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/widget.jsp: Loading...
  14. /trunk/rave-portal-resources/src/main/webapp/WEB-INF/tags/header.tag: Loading...