Re: menu item order if menu stored in database

lixin chu <lixin_chu-/[email protected]>
Newsgroups gmane.comp.java.struts-menu.user
Message-ID <[email protected]>
I guess it is becuase menu items are put into a
HashMap in MenuRepository, that's why the sequence is
not presevered.

--- lixin chu <lixin_chu-/[email protected]> wrote:

> Hi,
> would like check if anyone has encountered this
> before.
> 
> i basically want to display menu items in a
> particular
> order. the menu items are stored in a database. I
> followed the online example. I deliberatly store the
> menu items into the database according to the view
> sequence. The resulted list of items show the
> corrent
> sequnce. However, when jsp renders the topMenus, it
> seems that it order is not what I stored in the
> database (the sub menu items are all correctly
> displayed in each top menu).
> 
> SQL query menu database:
> ------------------------
> "from Menu p order by p.id asc"
> 
> in my StartupListener:
> ----------------------
> MenuRepository defaultRepository = (MenuRepository)
> context.getAttribute
> (MenuRepository.MENU_REPOSITORY_KEY);
> MenuRepository repository = new MenuRepository();
>
repository.setDisplayers(defaultRepository.getDisplayers());
> MenuManager mgr = (MenuManager)
> ctx.getBean("menuManager");
> 
> List menus = mgr.getMenus();
> for (int i=0; i<menus.size();i++) {
>   MenuComponent mc = new MenuComponent();
>   Menu m = (Menu) menus.get(i);
>   BeanUtils.copyProperties (mc, m);
>   String parent = m.getParentName();
>   if(parent != null) {
>     MenuComponent parentMenu =
> repository.getMenu(parent);
>     if (parent == null) {
> 	parentMenu = new MenuComponent();	
> parentMenu.setName(parent);    		
> repository.addMenu(parentMenu);
>     }
>     mc.setParent(parentMenu);
>   }    			
>   repository.addMenu(mc);
>  }
>     		
> context.setAttribute("menuRepository", repository);	
> 	
> 
> in my jsp file:
> ----------------
> <menu:useMenuDisplayer name="ListMenu"
> repository="menuRepository">
>  <c:forEach var="menu"
> items="${menuRepository.topMenus}">
>     <menu-el:displayMenu name="${menu.name}"/>
>  </c:forEach>
> </menu:useMenuDisplayer>
> 
> 
> I am not sure how to control the <c:forEach> with
> menuRepository so that it displays the topMenu in my
> intended order.
> 
> thanks
> li xin
> 
> 
> 		
> __________________________________ 
> Do you Yahoo!? 
> The all-new My Yahoo! - Get yours free! 
> http://my.yahoo.com 
>  
> 
> 
> 
>
-------------------------------------------------------
> The SF.Net email is sponsored by: Beat the
> post-holiday blues
> Get a FREE limited edition SourceForge.net t-shirt
> from ThinkGeek.
> It's fun and FREE -- well,
> almost....http://www.thinkgeek.com/sfshirt
> _______________________________________________
> struts-menu-user mailing list
> struts-menu-user-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
>
https://lists.sourceforge.net/lists/listinfo/struts-menu-user
> 



		
__________________________________ 
Do you Yahoo!? 
Read only the mail you want - Yahoo! Mail SpamGuard. 
http://promotions.yahoo.com/new_mail 


-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.