I am trying to build and use a Yahoo UI menu in my struts2 / tiles2 
application.  The menu I am creating is a static 'logged out' menu created in 
the action triggerd by the web app 'index.jsp'.  The menu is a List<Menu> 
collection and is added to the session, e.g. session.put("basicMenu", 
basicMenuList);

 

The data transfer object that I am using has a setLabel(String label) method.  
Everything works fine until I want to set the labels based on the current 
locale.

 

My MenuBuilder action class is where the menu is constructed prior to placement 
in the session.  I also have resource bundles configured for various languages 
in my MenuBuilder.properties.  An example name/value pair is 'menu.login=Login' 
for english - en, and 'menu.login=Inicio de sesión' for spanish - es.

 

Every time the user sets their language preference, I want to rebuild the menu 
using locale specific text like those found in the resource bundles.  In the 
Language.java action, I remove the current menu from the session, build a new 
menu, and put in the session again.

 

session.remove("basicMenu");

basicMenuList = new MenuBuilder().getStaticMenu();

session.put("basicMenu", basicMenuList);  

 

Here are some of the things I've tried to pick up the properties file values 
with no success.  I'm probably out in left field with little comprehension of 
the framework, but if there is someone that can help me with my problem, or 
suggest a different methodology, I'll thank you and sing your praises.

 

Menu ts_login = new Menu();

ts_login.setId("1102");

//ts_login.setLabel("Login");                              // This is hard 
coding

ts_login.setLabel("menu.login");                         // This also is hard 
coding

//ts_login.setLabel("%{getText('menu.login')}");    //The prevents the menu 
from dispalying at all

//ts_login.setLabel("getText('menu.login')");         //The prevents the menu 
from dispalying at all

 

 

 

 

Reply via email to