JavaScud | Forum | JIRA | Blog |
  Dashboard > WebWork2文档中文化计划 > ... > FAQ > How do I set a global resource bundle
  WebWork2文档中文化计划 Log In View a printable version of the current page.  
  How do I set a global resource bundle
Added by scud, last edited by scud on Mar 30, 2006  (view change)
Labels: 
(None)

In webwork.properties(as of Webwork 2.1.1),
you can now use:

webwork.custom.i18n.resources=global-messages

Serveral resource bundles can be specified by comma separating them.
for example see webwork.properties :
http://wiki.opensymphony.com/display/WW/webwork.properties

Java class (thanks Drew McAuliffe):

public class WebworkGlobalMessagesListener implements ServletContextListener {
    private static Logger log = Logger.getLogger(WebworkGlobalMessagesListener.class);
    private static final String DEFAULT_RESOURCE = "global-messages";

    /**
     * Uses the LocalizedTextUtil to load messages from the global
     message bundle.
     * @see
     javax.servlet.ServletContextListener#contextInitialized(javax.servlet.Servle
     tContextEvent)
     */
    public void contextInitialized(ServletContextEvent arg0) {
        log.info("Loading global messages from " + DEFAULT_RESOURCE);
        LocalizedTextUtil.addDefaultResourceBundle(DEFAULT_RESOURCE);
        log.info("Global messages loaded.");
    }

    /**
     * @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent)
     */
    public void contextDestroyed(ServletContextEvent arg0) {

        // do nothing
    }

}

web.xml:
(under listeners section)

<listener>
<listener-class>mypackagename.WebworkGlobalMessagesListener</listener-class>
</listener>
Site running on a free Atlassian Confluence Open Source Project License granted to WebWork China. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.3 Build:#808 May 29, 2007) - Bug/feature request - Contact Administrators