Question

I am trying to create am method to reload all the message resource defined in struts config. There are more than one message resource defined. I need a way to get all the <message-resources> defined in struts config.

I am using Struts 1.2.

Thanks in advance.

Was it helpful?

Solution

I manage to get the list by this underlying code snippet.

    ServletContext context = request.getSession().getServletContext();

ModuleConfig moduleConfig = ModuleUtils
                                .getInstance()
                                .getModuleConfig(request, context);

    MessageResourcesConfig[] msgConfigArr = ModuleUtils.getInstance()
                                            .getModuleConfig(request)
                                            .findMessageResourcesConfigs();

    MessageResources[] messages= new MessageResources[msgConfigArr.length]; 
for(int i = 0; i<msgConfigArr.length;i++){
    if(msgConfigArr[i]==null)
    continue;

    messages[i] = context.getAttribute(key[i] + moduleConfig.getPrefix());
}

    return messages;

Hope this help Somebody.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top