At 10:55 PM +0100 12/20/04, Peter Maas wrote:
If I want to configure parameters for a certain action in a
non-hardcoded fashion; what would be the way to go?

I see:
- people using the application.properties resources file... seems not
o.k. to me... this is where I store texts for the interface
- people using attributes stored in servlet context
- people using properties set using the <set-property> element retrieved
by custom action mappings
- people using properties set using the <set-property> element retrieved
by custom action mappings (???? I can not find a good example for this)

To me the <set-property> seems te most logical to use (since it also
feature xdoclet support).

But from there, where do I go? How do I access the variable?
I have seen the example using a custom ActionMapping, but I found it a
bit strange that I can only define this in the <action-mappings>
element... i.e. globally over all my actions?

Then there is ActionConfig... which sounds like what I need... but how
do I use it to retrieve properties? anyone got an example?

ActionMapping extends ActionConfig. Conventionally, Action classes cast ActionMapping to a specific subclass which is known to have the properties they expect to be passed in.


Something like this:

public ActionForward execute(...) {

     String config = ((MyActionMapping) mapping).getConfigProperty();
}

and

<set-property property="configProperty" value="foobar" />

Note that if you only need one value, the "parameter" property of ActionMapping is the easiest way to go. Also, just last week, I committed changes that allow you to access a map of arbitrary properties in an ActionConfig, if you're willing to use a nightly build of Struts. This should eliminate most cases for actually subclassing ActionMapping.

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]



Reply via email to