At 5:15 PM +0200 10/10/05, Thomas Corte wrote:
Hi there,
I have a Struts plugin that needs to access the MessageResources of
my Struts application (to send out some internationalized mails).
However, neither the ActionServlet nor the ModuleConfig passed to
the PlugIn's init () method seem to grant access to the
MessageResources.
I actually switched from a ServletContextListener to a PlugIn just
because of this requirement, but now I'm stuck.
The MessageResources objects are just placed in the ServletContext,
so if you know the attribute naming conventions, you can retrieve
them from either a plugin or a listener. If you use multiple modules
in your app, you'll want to use the plugin so it can know in which
module it has been initialized, because the module name is used to
ensure a unique name in the servlet context.
See protected void initModuleMessageResources(ModuleConfig config) in
ActionServlet for the real deal:
https://svn.apache.org/repos/asf/struts/core/trunk/src/java/org/apache/struts/action/ActionServlet.java
The general intention in relatively near-term development is to steer
Struts towards using objects which mediate access to the servlet
context so as to protect users from having to know things like this,
but it will be a little tricky because there may be much existing
code which depends on the current behavior. In Struts 1.3 the
ActionContext class provides this mediation for access to the request
and session, so the next step is to provide it for the module and
application level.
Joe
--
Joe Germuska
[EMAIL PROTECTED]
http://blog.germuska.com
"Narrow minds are weapons made for mass destruction" -The Ex
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]