Thanks for setting the context Amine..You can extend the ActionServlet, read the param 
from Web.xml and then access the Servlet instance from your Action class by using the 
context key Globals.ACTION_SERVLET_KEY...see the javadoc below from the Action 
class.....

    /**
     * The context attributes key under which our <code>ActionServlet</code>
     * instance will be stored.
     * @deprecated Use Globals.ACTION_SERVLET_KEY instead.
     * @since Struts 1.1
     */
    public static final String ACTION_SERVLET_KEY = Globals.ACTION_SERVLET_KEY;
    


Sumit

-----Original Message-----
From: Amine Bousta [mailto:[EMAIL PROTECTED]
Sent: Friday, November 14, 2003 4:21 PM
To: Struts Users Mailing List
Subject: RE: Dreaming of a constant value that can be available in all
of my actions


Thanks Sumit for such a quick answer!

That's a good idea but I'd like to have a different constant for each of my
application.
Concretely I've made kind of generic actions that uses "Class" and
"MethodUtils" to perform basic actions on beans.
These actions are commonly shared by all of my applications but the thing is
that these actions need a package prefix to create objects with
Class.forName.
This package prefix is different from an application to another.

If I implement your concept I'd have the same constant value (package
prefix) for all my apps.

So basically I need a constant value initialised in the web.xml and
accessible from any action.

Thank you again
Amine



-----Message d'origine-----
De : Sumit S. [mailto:[EMAIL PROTECTED]
Envoyé : vendredi 14 novembre 2003 11:26
À : Struts Users Mailing List
Objet : RE: Dreaming of a constant value that can be available in all of
my actions


U can define & use a base Action class  that has a static block that sets
the constant....derive all your actions from the base...the base class can
read the value from the envrionment or context.....



Hope this helps...

Sumit

-----Original Message-----
From: Amine Bousta [mailto:[EMAIL PROTECTED]
Sent: Friday, November 14, 2003 3:43 PM
To: [EMAIL PROTECTED]
Subject: Dreaming of a constant value that can be available in all of my
actions


Hello,

I want a constant value that I could use in all of my Struts action.

I already have a "MyActionMapping" that extends the ActionMapping and owns a
parameter.
I would like to initialise this parameter with a constant value. Then I
would access it with a getXXX in every actions.
It's like if I'd do a myActionMapping.setXXXX just once for all my
application.

Is there a way to configure web.xml so that it initialises a MyActionMapping
parameter while initialising my app?

If you know another way to do that (extending ServletAction? if so, how to
access the parameter from within an action?) I'd be happy to read you.

Regards
Amine



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to