You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Hauschel Fred <Fr...@ixtra.com> on 2005/03/10 10:08:20 UTC
Problems with SwitchAction and Modules
Hey all,
I call the switch action in "module a" and tell him to switch to "module
b".
The switch Action does it's work, but the TilesRequestProcessor's
moduleConfig is still the moduleConfig from "module a" and so the
definitionFactory says:
10.03.2005 09:58:03.112 DEBUG [I18nFactorySet.parseXmlFile (508)] Can't
open file '/WEB-INF/instanceDefinitions_de.xml'
That's right, the "module a" didn't have any tiles-def's. But "modul b"
have some.
Does anybody have any idea?
And I think there is a bug in ModuleUtils $Revision: 1.9 $ :
If the passed prefix is wrong so the line
MessageResourcesConfig[] mrConfig =
config.findMessageResourcesConfigs();
Will throw an NullPointer.
Fredy
public void selectModule(
String prefix,
HttpServletRequest request,
ServletContext context) {
// Expose the resources for this module
Enumeration enumer = context.getAttributeNames();
while (enumer.hasMoreElements()) {
String element = (String) enumer.nextElement();
System.out.println( element );
}
ModuleConfig config = getModuleConfig(prefix, context);
if (config != null) {
request.setAttribute(Globals.MODULE_KEY, config);
} else {
request.removeAttribute(Globals.MODULE_KEY);
}
MessageResourcesConfig[] mrConfig =
config.findMessageResourcesConfigs();
for(int i = 0; i < mrConfig.length; i++) {
String key = mrConfig[i].getKey();
MessageResources resources =
(MessageResources) context.getAttribute(key + prefix);
if (resources != null) {
request.setAttribute(key, resources);
} else {
request.removeAttribute(key);
}
}
}