You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Cliff Rowley <cl...@onsea.net> on 2002/09/09 04:53:05 UTC

Actions and set-property

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
-- 

Regards

-------------------------------------------
 Cliff Rowley        |     cliff@onsea.net
 Software Engineer   |   www.doctype.co.uk
 +44 (0) 1206 514263 | www.cliffrowley.com
-------------------------------------------


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Actions and set-property

Posted by Cliff Rowley <cl...@onsea.net>.
Brilliant, thanks for that Ted (and Robert Taylor).  I didn't see this
in the documentation specifically, but it was really late and I probably
just didn't see it if it was there.

At least I got the chance to poke into the Struts codebase, which I've
not really had a chance to do until now.

Thanks :)

On Mon, 2002-09-09 at 12:06, Ted Husted wrote:
> 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:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 
-- 

Regards

-------------------------------------------
 Cliff Rowley        |     cliff@onsea.net
 Software Engineer   |   www.doctype.co.uk
 +44 (0) 1206 514263 | www.cliffrowley.com
-------------------------------------------


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Actions and set-property

Posted by Cliff Rowley <cl...@onsea.net>.
Yeah, I've just got mine working.  It's a bit of a pain in the butt -
I'm creating some generic reusable actions, and I've got a bit of an
Action heirarchy going on - and now I seem to have an ActionMapping
heirarchy too - but I'm not complaining.  Now I've had some sleep I
think understand why its done this way .. using ActionMappings means
that the same instance of an Action class can serve multiple actions -
or something.

On Mon, 2002-09-09 at 23:13, Michael wrote:
> Yep, that works. You have to set the "className" attribute for your Action
> to the class name of your sub-classed ActionMapping  in the config file.
> Thanks.
> 
> ----- Original Message -----
> From: Cliff Rowley <cl...@onsea.net>
> To: Struts Users Mailing List <st...@jakarta.apache.org>
> Sent: Monday, September 09, 2002 6:04 PM
> Subject: Re: Actions and set-property
> 
> 
> > From what Ted said, I am presuming that the subclassed ActionMapping
> > should implement the property you are interested in, which will be set
> > when the Digester sucks in the Struts config and that when the Action is
> > called, we can cast the ActionMapping to our subclass and access the
> > property.  I'm right in the middle of trying it so I'll post back in a
> > few and let you know :)
> >
> > On Mon, 2002-09-09 at 21:56, Michael wrote:
> > > 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 <hu...@apache.org>
> > > To: Struts Users Mailing List <st...@jakarta.apache.org>
> > > 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:
> > > <ma...@jakarta.apache.org>
> > > > For additional commands, e-mail:
> > > <ma...@jakarta.apache.org>
> > > >
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> > >
> > >
> > --
> >
> > Regards
> >
> > -------------------------------------------
> >  Cliff Rowley        |     cliff@onsea.net
> >  Software Engineer   |   www.doctype.co.uk
> >  +44 (0) 1206 514263 | www.cliffrowley.com
> > -------------------------------------------
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 
-- 

Regards

-------------------------------------------
 Cliff Rowley        |     cliff@onsea.net
 Software Engineer   |   www.doctype.co.uk
 +44 (0) 1206 514263 | www.cliffrowley.com
-------------------------------------------


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Actions and set-property

Posted by Michael <mi...@comcast.net>.
Yep, that works. You have to set the "className" attribute for your Action
to the class name of your sub-classed ActionMapping  in the config file.
Thanks.

----- Original Message -----
From: Cliff Rowley <cl...@onsea.net>
To: Struts Users Mailing List <st...@jakarta.apache.org>
Sent: Monday, September 09, 2002 6:04 PM
Subject: Re: Actions and set-property


> From what Ted said, I am presuming that the subclassed ActionMapping
> should implement the property you are interested in, which will be set
> when the Digester sucks in the Struts config and that when the Action is
> called, we can cast the ActionMapping to our subclass and access the
> property.  I'm right in the middle of trying it so I'll post back in a
> few and let you know :)
>
> On Mon, 2002-09-09 at 21:56, Michael wrote:
> > 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 <hu...@apache.org>
> > To: Struts Users Mailing List <st...@jakarta.apache.org>
> > 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:
> > <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> > >
> >
> >
> > --
> > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> > For additional commands, e-mail:
<ma...@jakarta.apache.org>
> >
> >
> --
>
> Regards
>
> -------------------------------------------
>  Cliff Rowley        |     cliff@onsea.net
>  Software Engineer   |   www.doctype.co.uk
>  +44 (0) 1206 514263 | www.cliffrowley.com
> -------------------------------------------
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Actions and set-property

Posted by Cliff Rowley <cl...@onsea.net>.
>From what Ted said, I am presuming that the subclassed ActionMapping
should implement the property you are interested in, which will be set
when the Digester sucks in the Struts config and that when the Action is
called, we can cast the ActionMapping to our subclass and access the
property.  I'm right in the middle of trying it so I'll post back in a
few and let you know :)

On Mon, 2002-09-09 at 21:56, Michael wrote:
> 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 <hu...@apache.org>
> To: Struts Users Mailing List <st...@jakarta.apache.org>
> 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:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 
-- 

Regards

-------------------------------------------
 Cliff Rowley        |     cliff@onsea.net
 Software Engineer   |   www.doctype.co.uk
 +44 (0) 1206 514263 | www.cliffrowley.com
-------------------------------------------


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Actions and set-property

Posted by Michael <mi...@comcast.net>.
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 <hu...@apache.org>
To: Struts Users Mailing List <st...@jakarta.apache.org>
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:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Actions and set-property

Posted by Ted Husted <hu...@apache.org>.
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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Actions and set-property (sort of solved)

Posted by Cliff Rowley <cl...@onsea.net>.
Me again :)

I've sort of solved it, in that I have implemented the required bits for
the set-property in the CVS source.

Nice codebase, took me a little under an hour to work out where I was
and implement it.  The changes were quite small, two methods added to
ActionConfig (addProperty and getProperties), a change to ConfigRuleset
(to set the property/value pair - I took the example from
PlugInSetPropertyRule) and a change to
RequestProcessor.processActionCreate() to set the properties of the
newly created Action instance.

What do I do now?  I can send someone the diffs (in fact it's that
trivial that someone could do it from scratch in minutes).  It'd be nice
if this functionality was in the codebase, it would help me in my quest
for generic actions :)

On Mon, 2002-09-09 at 06:42, Cliff Rowley wrote:
> Righty, just been through the CVS version (just in case) and still
> nothing.  Please someone tell me I'm looking in the wrong place :)
> 
> On Mon, 2002-09-09 at 06:22, Cliff Rowley wrote:
> > I've just been through the source, and I believe the correct place the
> > the action properties should be set is in
> > RequestProcessor.processActionCreate(), but there appears to be no code
> > to that effect (Struts 1.1-b2).  I will download the nightly build now
> > (as it appears the rest of the world is asleep ;) ) and check against
> > that too.  I could be completely wrong, however - it has been known :P
> > 
> > Please see my previous post too for more details.
> > -- 
> > 
> > Regards
> > 
> > -------------------------------------------
> >  Cliff Rowley        |     cliff@onsea.net
> >  Software Engineer   |   www.doctype.co.uk
> >  +44 (0) 1206 514263 | www.cliffrowley.com
> > -------------------------------------------
> > 
> > 
> > --
> > To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> > For additional commands, e-mail: <ma...@jakarta.apache.org>
> > 
> > 
> -- 
> 
> Regards
> 
> -------------------------------------------
>  Cliff Rowley        |     cliff@onsea.net
>  Software Engineer   |   www.doctype.co.uk
>  +44 (0) 1206 514263 | www.cliffrowley.com
> -------------------------------------------
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 
-- 

Regards

-------------------------------------------
 Cliff Rowley        |     cliff@onsea.net
 Software Engineer   |   www.doctype.co.uk
 +44 (0) 1206 514263 | www.cliffrowley.com
-------------------------------------------


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Actions and set-property (revisited again)

Posted by Cliff Rowley <cl...@onsea.net>.
Righty, just been through the CVS version (just in case) and still
nothing.  Please someone tell me I'm looking in the wrong place :)

On Mon, 2002-09-09 at 06:22, Cliff Rowley wrote:
> I've just been through the source, and I believe the correct place the
> the action properties should be set is in
> RequestProcessor.processActionCreate(), but there appears to be no code
> to that effect (Struts 1.1-b2).  I will download the nightly build now
> (as it appears the rest of the world is asleep ;) ) and check against
> that too.  I could be completely wrong, however - it has been known :P
> 
> Please see my previous post too for more details.
> -- 
> 
> Regards
> 
> -------------------------------------------
>  Cliff Rowley        |     cliff@onsea.net
>  Software Engineer   |   www.doctype.co.uk
>  +44 (0) 1206 514263 | www.cliffrowley.com
> -------------------------------------------
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 
-- 

Regards

-------------------------------------------
 Cliff Rowley        |     cliff@onsea.net
 Software Engineer   |   www.doctype.co.uk
 +44 (0) 1206 514263 | www.cliffrowley.com
-------------------------------------------


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Actions and set-property (revisited)

Posted by Cliff Rowley <cl...@onsea.net>.
I've just been through the source, and I believe the correct place the
the action properties should be set is in
RequestProcessor.processActionCreate(), but there appears to be no code
to that effect (Struts 1.1-b2).  I will download the nightly build now
(as it appears the rest of the world is asleep ;) ) and check against
that too.  I could be completely wrong, however - it has been known :P

Please see my previous post too for more details.
-- 

Regards

-------------------------------------------
 Cliff Rowley        |     cliff@onsea.net
 Software Engineer   |   www.doctype.co.uk
 +44 (0) 1206 514263 | www.cliffrowley.com
-------------------------------------------


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Actions and set-property

Posted by Robert Taylor <rt...@mulework.com>.
Cliff, I use this functionality currently. All I did was extend
ActionMapping, add my properties, and in the struts-config.xml, assigned the
type attribute of the action-mappings element my extended ActionMapping
class name. Struts will then use introspection to identify and assign the
new properties their corresponding values.

<action-mappings type="com.companyname.BaseActionMapping">

It's an easy way to extend ActionMapping class.

robert

> -----Original Message-----
> From: Cliff Rowley [mailto:cliff@onsea.net]
> Sent: Sunday, September 08, 2002 10:53 PM
> To: struts-user@jakarta.apache.org
> Subject: Actions and set-property
>
>
> 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
> --
>
> Regards
>
> -------------------------------------------
>  Cliff Rowley        |     cliff@onsea.net
>  Software Engineer   |   www.doctype.co.uk
>  +44 (0) 1206 514263 | www.cliffrowley.com
> -------------------------------------------
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>