How do I get my properties from the ActionMapping object? I see getParameter
and getAttribute methods for the ActionConfig object, but they don't take
parameters. Is there any way, in my Action so say something like:
mapping.getAttribute("layerKey"); ?
----- Original Message -----
From: Ted Husted <[EMAIL PROTECTED]>
To: Struts Users Mailing List <[EMAIL PROTECTED]>
Sent: Monday, September 09, 2002 7:06 AM
Subject: Re: Actions and set-property
> I know this is confusing, but the <action> element does not instantiate
> an Action object. It creates an ActionMapping object (which acts like a
> decortate for the Action). This is the object that you need to extend.
> Then, at runtime, the controller will pass your Action object the
> mapping, and you can get the custom property from there. (Of course, you
> will need to typecase the mapping first.)
>
> The <set-property> feature is provided by the Digester, so you won't
> find it in the Struts codebase. It's implemented in the Digester codebase.
>
> -Ted.
>
>
> Cliff Rowley wrote:
>
> > Greetings, very quick question. From the struts config DTD, I
> > understand that action classes, like plugins, can be configured via bean
> > style properties using the <set-property> in an <action> element:
> >
> > <quote>
> > The "set-property" element specifies the method name and initial value
> > of an additional JavaBean configuration property. When the object
> > representing the surrounding element is instantiated, the accessor for
> > the indicated property is called and passed the indicated value. The
> > "set-property" element is especially useful when a custom subclass is
> > used with <data-source>, <forward>, <action>, or <plug-in> elements. The
> > subclass can be passed whatever other properties may be required to
> > configure the object without changing how the struts-config is parsed.
> >
> > property Name of the JavaBeans property whose setter method
> > will be called.
> >
> > value String representation of the value to which this
> > property will be set, after suitable type conversion
> > </quote>
> >
> > I've just had a stab at this but my property is not being set. The
> > action configuration is as follows:
> >
> > <action path="/test" type="net.onsea.huts.actions.ListAction">
> > <set-property property="entityType" value="foo"/>
> > <forward name="success" path="/test.jsp"/>
> > </action>
> >
> > and my action (which is a subclass of a base action, as in Action ->
> > BaseAction -> ListAction) has a public getter/setter pair for its
> > entityType property.
> >
> > Just wondered if this is a known issue/bug/user_error?
> >
> > Its late (early?) and I'm not sure my blurry eyes will be much use
> > reading through the source code :|
> >
> > Cheers
> >
>
>
> --
> Ted Husted, Husted dot Com, Fairport NY US
> co-author, Java Web Development with Struts
> Order it today:
> <http://husted.com/struts/book.html>
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>