Re: menu item order if menu stored in database

Matt Raible <lists-T7vlz3gD7BdF/EzeuO4KJwC/[email protected]>
Newsgroups gmane.comp.java.struts-menu.user
Message-ID <[email protected]>
Sorry, this has been sitting in my inbox for awhile now. Can you please 
enter this as a bug in Struts Menu?

http://sourceforge.net/tracker/?func=add&group_id=48726&atid=453974

Thanks,

Matt

On Jan 9, 2005, at 6:52 PM, lixin chu wrote:

> 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
> _______________________________________________
> struts-menu-user mailing list
> struts-menu-user-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> https://lists.sourceforge.net/lists/listinfo/struts-menu-user



-------------------------------------------------------
This SF.net email is sponsored by Microsoft Mobile & Embedded DevCon 2005
Attend MEDC 2005 May 9-12 in Vegas. Learn more about the latest Windows
Embedded(r) & Windows Mobile(tm) platforms, applications & content.  Register
by 3/29 & save $300 http://ads.osdn.com/?ad_id=6883&alloc_id=15149&op=click
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.