public static ModuleConfig selectModule ( String prefix , HttpServletRequest request , ServletContext servletContext ) { ModuleConfig moduleConfig = getModuleConfig ( prefix , servletContext ) ; if ( moduleConfig == null ) { request . removeAttribute ( Globals . MODULE_KEY ) ; return null ; } // If this module came from an abstract page flow controller class, don't select it. ControllerConfig cc = moduleConfig . getControllerConfig ( ) ; if ( cc instanceof PageFlowControllerConfig && ( ( PageFlowControllerConfig ) cc ) . isAbstract ( ) ) { return moduleConfig ; } // Just return it if it's already registered. if ( request . getAttribute ( Globals . MODULE_KEY ) == moduleConfig ) return moduleConfig ; request . setAttribute ( Globals . MODULE_KEY , moduleConfig ) ; MessageResourcesConfig [ ] mrConfig = moduleConfig . findMessageResourcesConfigs ( ) ; Object formBean = unwrapFormBean ( getCurrentActionForm ( request ) ) ; for ( int i = 0 ; i < mrConfig . length ; i ++ ) { String key = mrConfig [ i ] . getKey ( ) ; MessageResources resources = ( MessageResources ) servletContext . getAttribute ( key + prefix ) ; if ( resources != null ) { if ( ! ( resources instanceof ExpressionAwareMessageResources ) ) { resources = new ExpressionAwareMessageResources ( resources , formBean , request , servletContext ) ; } request . setAttribute ( key , resources ) ; } else { request . removeAttribute ( key ) ; } } return moduleConfig ; }
Set the given Struts module in the request and expose its set of MessageResources as request attributes .