Announcement Announcement Module
No announcement yet.
cannot get @ModelAttribute to work Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • cannot get @ModelAttribute to work

    I am trying to use the model attribute annotation to populate the "nav" variable with my navigation data for use on the jsp.
    I am using tiles 2 for my views, by the way, if that makes any difference.

    my attribute "nav" cannot be found on the jsp, even though looking at the log file, i can see that the method getNavigation() is called.

    public class ItemController {
        private ItemManager itemManager;
        private NavigationManager navigationManager;
        private MediaUtils mediaUtil;
        private final Log log = LogFactory.getLog(ItemController.class);
        private static final int PROMO_SIZE = 4; //how big are the promotions, how many items do they include?
    //this DOES NOT APPEAR on my JSP!!
        public List<Navigation> getNavigation(){
        	log.debug("returning moddel attribute: "+this.navigationManager.getNavigationByGroupName("main"));
        	return this.navigationManager.getNavigationByGroupName("main");
         *  Maps all nav level 2 requests
        public ModelAndView handleSubCategoryRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
    		String path = request.getServletPath();
    		int idx=path.lastIndexOf("/");
    		String navUrl = path.substring(0,idx);
    		String itemSeoName = path.substring(idx+1, path.length() - 5);
    		Navigation selectedNav = navigationManager.getNavigationByURL(navUrl);
    		ModelAndView mav = new ModelAndView("error.404");
    		log.debug("(detail) nav url:"+navUrl+" nav:"+selectedNav);
    		log.debug("(detail) item seo name:"+itemSeoName);
    		if(selectedNav == null){
    		} else if(selectedNav.getNavName().equals("item") && !processItemDetailRequest(selectedNav, mav, itemSeoName)){
    			//this is a weird if block: if we have an item request, and fail to process it, fail, 
    			//otherwise the request is already set up correctly!
    		mav.addObject("selectedNav", selectedNav);
    //		mav.addObject("nav", this.navigationManager.getNavigation());
    		log.debug("finished detail request returning modelandview: "+mav);
    	    return mav;  //at this point its error.404         
    Last edited by koryakm; Jun 9th, 2008, 04:16 PM. Reason: wtf