Hello Craig,
First option turns out to be a great way to store
initialization parameters that are shared by many
actions. In this case what name convention should
be adopted?
Best of luck,
Yuriy Zubarev
--- "Craig R. McClanahan" <[EMAIL PROTECTED]> wrote:
> First, one approach is to use servlet initialization parameters, and
> adopt
> the convention that the names of parameters for a specific action start
> with the fully qualified class name of that action.
>
> Second, if you only need *one* configuration parameter, there is a
> general
> purpose property of an ActionMapping called "parameter" (with accessor
> methods getParameter() and setParameter()) that you can use for this
> purpose.
>
> Third, there is a way to store Action-specific configuration information
> in struts-config.xml. It's a little involved, but goes basically like
> this:
>
> * Write your own subclass of ActionMapping that includes the extra
> properties you are interested in. You can do individual subclasses
> for each different action, or a class that includes all the custom
> properties you might want for any action.
>
> * Modify your <action> entries in two respects:
> - Tell Struts to use your ActionMapping subclass instead of the
> standard one.
> - Configure the extra parameters with <set-property> elements>
>
> <action path="/myaction"
> className="com.mycompany.MyActionMapping"
> type="com.mycompany.MyAction"
> ... >
> <set-property property="foo" value="Value for property foo"/>
> <set-property property="bar" value="Value for property bar"/>
> </action>
>
> * In your Action, cast the mapping you receive to your own class
> so you can access these extra properties:
>
> public ActionForward perform(...) {
>
> MyActionMapping myMapping = (MyActionMapping) mapping;
> String foo = myMapping.getFoo();
> String bar = myMapping.getBar();
> ... use foo and bar to modify the behavior ...
>
> }
>
> Craig McClanahan
>
>
> On Thu, 21 Jun 2001, Yuriy Zubarev wrote:
>
> > Hello everybody,
> >
> > While working directly with servlets, in configuration
> > file you can specify initial valus of parameters for a servlet
> > in the following way:
> >
> > <init-param>
> > <param-name>
> > parameter
> > </param-name>
> > <param-value>
> > value
> > </param-value>
> > </init-param>
> >
> > And you can easily get those values without resorting to
> > parse information on your own.
> >
> > So I was wondering if it's possible to make such a
> > thing with actions in struts-config.xml file.
> > In another words I would like to have some custom
> > parameters for some actions with handy means of
> > extracting those parameters.
> >
> > Thank you for your time.
> >
> > Best of luck,
> > Yuriy Zubarev
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Get personalized email addresses from Yahoo! Mail
> > http://personal.mail.yahoo.com/
> >
>
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/