Search in sources :

Example 1 with MessageResourcesFactory

use of org.apache.struts.util.MessageResourcesFactory in project sonarqube by SonarSource.

the class ActionServlet method initModuleMessageResources.

/**
     * <p>Initialize the application <code>MessageResources</code> for the
     * specified module.</p>
     *
     * @param config ModuleConfig information for this module
     * @throws ServletException if initialization cannot be performed
     * @since Struts 1.1
     */
protected void initModuleMessageResources(ModuleConfig config) throws ServletException {
    MessageResourcesConfig[] mrcs = config.findMessageResourcesConfigs();
    for (int i = 0; i < mrcs.length; i++) {
        if ((mrcs[i].getFactory() == null) || (mrcs[i].getParameter() == null)) {
            continue;
        }
        if (log.isDebugEnabled()) {
            log.debug("Initializing module path '" + config.getPrefix() + "' message resources from '" + mrcs[i].getParameter() + "'");
        }
        String factory = mrcs[i].getFactory();
        MessageResourcesFactory.setFactoryClass(factory);
        MessageResourcesFactory factoryObject = MessageResourcesFactory.createFactory();
        factoryObject.setConfig(mrcs[i]);
        MessageResources resources = factoryObject.createResources(mrcs[i].getParameter());
        resources.setReturnNull(mrcs[i].getNull());
        resources.setEscape(mrcs[i].isEscape());
        getServletContext().setAttribute(mrcs[i].getKey() + config.getPrefix(), resources);
    }
}
Also used : MessageResources(org.apache.struts.util.MessageResources) MessageResourcesFactory(org.apache.struts.util.MessageResourcesFactory) MessageResourcesConfig(org.apache.struts.config.MessageResourcesConfig)

Example 2 with MessageResourcesFactory

use of org.apache.struts.util.MessageResourcesFactory in project sonarqube by SonarSource.

the class TagTestBase method putBundleInScope.

protected void putBundleInScope(int scope, boolean returnNull) {
    MessageResourcesFactory factory = MessageResourcesFactory.createFactory();
    MessageResources messageResources = new PropertyMessageResources(factory, "org.apache.struts.taglib.sample");
    messageResources.setReturnNull(returnNull);
    pageContext.setAttribute(Globals.MESSAGES_KEY, messageResources, scope);
}
Also used : PropertyMessageResources(org.apache.struts.util.PropertyMessageResources) MessageResources(org.apache.struts.util.MessageResources) PropertyMessageResources(org.apache.struts.util.PropertyMessageResources) MessageResourcesFactory(org.apache.struts.util.MessageResourcesFactory)

Aggregations

MessageResources (org.apache.struts.util.MessageResources)2 MessageResourcesFactory (org.apache.struts.util.MessageResourcesFactory)2 MessageResourcesConfig (org.apache.struts.config.MessageResourcesConfig)1 PropertyMessageResources (org.apache.struts.util.PropertyMessageResources)1