You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Michael Binette <mb...@mediaone.net> on 2001/05/23 00:52:43 UTC
New ActionMapping Class
I created a new GenericActionMapping class that extends ActionMapping. I
added one property, processAction with public getter and setter methods for
it.
I then set the mapping property in web.xml for the struts Action servlet to
my new GenericActionMapping class. The log when I run TomCat correctly
shows it using my new GenericActionMapping class.
But, if I add processAction="whatever" to my struts-config.xml, within the
<action> element, I get a SAXParseException, Attribute "processAction" is
not declared for element "action".
How do I get this to work?
--
Thanks,
Michael Binette
RE: New ActionMapping Class
Posted by Michael Binette <mb...@mediaone.net>.
Great. It worked.
I am using this so that I can easily use one action class for multiple
actions such as "view", "edit", "delete" and "save", where it makes sense.
I wanted multiple Action mappings such as /editUser.do and /saveUser.do but
have them both use the same Action class.
I used your Transport idea and created an ActionInfo class to contain
properties with the mapping, request, response, form, and my new
processAction properties.
I also created a GenericAction that extends Action, sets up the ActionInfo
and calls an abstract method processAction(ActionInfo actionInfo).
Hopefully this will save me from the many Action classes per jsp view.
I've created a ViewSubmitAction that extends my GenericAction that looks at
the processAction and calls either processView(ActionInfo actionInfo) - an
abstract method of ViewSubmitAction, or processSubmit(AcitonInfo
actionInfo) - which can take care of all other cases.
anyways... Thanks for the tip.
--
Thanks,
Michael Binette
-----Original Message-----
From: Niall Pemberton [mailto:niall.pemberton@btInternet.com]
Sent: Wednesday, May 23, 2001 8:45 PM
To: struts-user@jakarta.apache.org
Subject: RE: New ActionMapping Class
Michael
You need to use a <set-property> tag is Struts-config.xml
For example:
<action path="/this" name="myForm" type ="myPackage.myAction">
<forward name="success" path="/next.jsp"/>
<forward name="fail" path="/prev.jsp"/>
<set-property property="processAction" value="whatever"/>
</action>
Niall
> -----Original Message-----
> From: Michael Binette [mailto:mbinette@mediaone.net]
> Sent: 22 May 2001 23:53
> To: Struts-User
> Subject: New ActionMapping Class
>
>
> I created a new GenericActionMapping class that extends ActionMapping. I
> added one property, processAction with public getter and setter
> methods for
> it.
>
> I then set the mapping property in web.xml for the struts Action
> servlet to
> my new GenericActionMapping class. The log when I run TomCat correctly
> shows it using my new GenericActionMapping class.
>
> But, if I add processAction="whatever" to my struts-config.xml, within the
> <action> element, I get a SAXParseException, Attribute "processAction" is
> not declared for element "action".
>
> How do I get this to work?
>
> --
> Thanks,
> Michael Binette
>
>
RE: New ActionMapping Class
Posted by Niall Pemberton <ni...@btInternet.com>.
Michael
You need to use a <set-property> tag is Struts-config.xml
For example:
<action path="/this" name="myForm" type ="myPackage.myAction">
<forward name="success" path="/next.jsp"/>
<forward name="fail" path="/prev.jsp"/>
<set-property property="processAction" value="whatever"/>
</action>
Niall
> -----Original Message-----
> From: Michael Binette [mailto:mbinette@mediaone.net]
> Sent: 22 May 2001 23:53
> To: Struts-User
> Subject: New ActionMapping Class
>
>
> I created a new GenericActionMapping class that extends ActionMapping. I
> added one property, processAction with public getter and setter
> methods for
> it.
>
> I then set the mapping property in web.xml for the struts Action
> servlet to
> my new GenericActionMapping class. The log when I run TomCat correctly
> shows it using my new GenericActionMapping class.
>
> But, if I add processAction="whatever" to my struts-config.xml, within the
> <action> element, I get a SAXParseException, Attribute "processAction" is
> not declared for element "action".
>
> How do I get this to work?
>
> --
> Thanks,
> Michael Binette
>
>
Re: New ActionMapping Class
Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Tue, 22 May 2001, Michael Binette wrote:
> I created a new GenericActionMapping class that extends ActionMapping. I
> added one property, processAction with public getter and setter methods for
> it.
>
> I then set the mapping property in web.xml for the struts Action servlet to
> my new GenericActionMapping class. The log when I run TomCat correctly
> shows it using my new GenericActionMapping class.
>
> But, if I add processAction="whatever" to my struts-config.xml, within the
> <action> element, I get a SAXParseException, Attribute "processAction" is
> not declared for element "action".
>
This error happens because your struts-config.xml document now violates
the DTD.
> How do I get this to work?
>
That's what the <set-property> element is for:
<action path="..." ...>
<set-property property="processAction" value="yadda yadda"/>
</action>
This little trick lets you extend the syntax of an ActionMapping, and add
new configurable properties, without having to modify the DTD.
> --
> Thanks,
> Michael Binette
>
>
Craig McClanahan