International Menu Help
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 ListMenu 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
RE: International Menu Help
Your solution works great! Syntax issue, bad on me. Thanks very much! DAN IS THE GREATEST! Singing the praises. From: Dave Newton [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 30, 2008 2:22 PM To: Struts Users Mailing List Subject: Re: International Menu Help --- On Tue, 9/30/08, Williams, Marlon wrote: 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 I'm lost; this is Java code in an ActionSupport-derived action? That shouldn't even *compile* let alone do anything useful. Doesn't normal Java work? ts_login.setLabel(getText(menu.login)); Dave - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Basic Action config issue with s:form in jsp
Please help a struggling newbie, and first time mailing list user. The following Netbeans 6.0 project is using Glassfish. Directory listing: TS_6 TS_6/src/ TS_6/src/conf/ TS_6/src/conf/MANIFEST.MF TS_6/src/java/ TS_6/src/java/HelloWorld.java TS_6/src/java/struts.xml TS_6/src/java/ts/ TS_6/src/java/ts/BaseAction.java TS_6/src/java/ts/Login.java TS_6/src/java/ts/ts_struts.xml TS_6/test/ TS_6/web/ TS_6/web/HelloWorld.jsp TS_6/web/index.html TS_6/web/index.jsp TS_6/web/jsp/ TS_6/web/jsp/login.jsp TS_6/web/jsp/login_error.jsp TS_6/web/jsp/login_input.jsp TS_6/web/jsp/login_success.jsp TS_6/web/WEB-INF/ TS_6/web/WEB-INF/sun-web.xml TS_6/web/WEB-INF/web.xml TS_6/web/WEB-INF/lib/ TS_6/web/WEB-INF/lib/commons-fileupload-1.2.1.jar TS_6/web/WEB-INF/lib/commons-io-1.3.2.jar TS_6/web/WEB-INF/lib/commons-logging-1.0.4.jar TS_6/web/WEB-INF/lib/freemarker-2.3.12.jar TS_6/web/WEB-INF/lib/ognl-2.6.11.jar TS_6/web/WEB-INF/lib/struts2-core-2.1.2.jar TS_6/web/WEB-INF/lib/xwork-2.1.1.jar Below find the files that I view as being involved in my problem web.xml ?xml version=1.0 encoding=UTF-8? web-app version=2.5 xmlns=http://java.sun.com/xml/ns/javaee; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation=http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd; filter filter-namestruts2/filter-name filter-classorg.apache.struts2.dispatcher.FilterDispatcher/filter-cla ss /filter filter-mapping filter-namestruts2/filter-name url-pattern/*/url-pattern /filter-mapping welcome-file-list welcome-fileindex.html/welcome-file welcome-fileindex.jsp/welcome-file /welcome-file-list /web-app struts.xml !DOCTYPE struts PUBLIC -//Apache Software Foundation//DTD Struts Configuration 2.0//EN http://struts.apache.org/dtds/struts-2.0.dtd; struts include file=ts/ts_struts.xml/ package name=hello extends=struts-default action name=HelloWorld class=HelloWorld result/HelloWorld.jsp/result /action /package /struts ts_struts.xml !DOCTYPE struts PUBLIC -//Apache Software Foundation//DTD Struts Configuration 2.0//EN http://struts.apache.org/dtds/struts-2.0.dtd; struts package name=ts namespace=/ts extends=struts-default action name=Login class=ts.Login result name=success/jsp/login_success.jsp/result result name=input/jsp/login_input.jsp/result result name=error/jsp/login_error.jsp/result /action /package /struts index.html !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transitional//EN html head META HTTP-EQUIV=Refresh CONTENT=0;URL=ts/Login.action /head body pLoading .../p /body /html Login.java package ts; public class Login extends BaseAction { public String execute() throws Exception { if (isInvalid(getUsername())) { return INPUT; } if (isInvalid(getPassword())) { return INPUT; } return SUCCESS; } private boolean isInvalid(String value) { return (value == null || value.length() == 0); } private String username; public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } private String password; public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } } BaseAction.java package ts; import com.opensymphony.xwork2.ActionSupport; public class BaseAction extends ActionSupport { } login_input.jsp %@ page language=java contentType=text/html; charset=ISO-8859-1 pageEncoding=ISO-8859-1 % %@ taglib prefix=s uri=/struts-tags% !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN http://www.w3.org/TR/html4/loose.dtd; html head meta http-equiv=Content-Type content=text/html; charset=UTF-8 titleLogin Input/title /head body h1/jsp/login_input.jsp/h1 h2Input Page/h2 /body /html RUN... http://localhost:8080/TS_6/ yields this url... http://localhost:8080/TS_6/ts/Login.action which displays... /jsp/login_input.jsp Input Page This all seems wired up well enough for the Login action to find the mapped jsp BUT... When I edit the same jsp by adding a form... login_input.jsp %@ page language=java contentType=text/html; charset=ISO-8859-1 pageEncoding=ISO-8859-1 % %@ taglib prefix=s uri=/struts-tags% !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN http://www.w3.org/TR/html4/loose.dtd;