You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Roy Truelove <ro...@pulver.com> on 2001/05/13 00:04:56 UTC
2 newbie questions..
Hey guys,
Quick questions from a newbie.. When the mapping is local to a
particular action, the Action class should call findForward on the mapping
that's passed in. But if the mapping is a global one, it should call
findForward on the instance of ActionServlet (called servlet) that is passed
down from the parent Action class. Is this correct? Or does the
ActionMapping that's passed in to the perform() method already contain the
global mappings? The reason I ask if because I really don't like the idea
of having access (and having to use) member variables of a parent class. It
makes my OO alarms go off. The example Struts application uses the
"servlet" object, instead of the ActionMapping instance.
Second question has to do with subclassing an ActionMapping class. As I
understand it right now, the default ActionMapping class that is passed into
the perform() method is created using the configuration XML file. It
contains the local mappings that are defined in the <action> tag for this
path (as well as the global mappings?) This seems to make sense, but in the
example application, there is a subclass of ActionMapping calling
ApplicationMapping, with some get / set methods. I can't find where this
class is used in the application, nor an explaination of it in the
walk-through or the user-guide.
Thanks in advance for your help. I'm trying to fully understand the example
app before trying struts on my own, and these are a few of my hangups.
Take it easy,
Roy
Re: 2 newbie questions..
Posted by Jim Richards <gr...@cyber4.org>.
The mapping that is sent to your object has the global mappings,
and the local ones as well.
As for your second question, I'm not sure but the example application
was done very early and it wouldn't surprise me if the class is not
used at all. Have you tried a global search? If it's not used anywhere
then it might be a hang over from earlier iterations of the code.
> Quick questions from a newbie.. When the mapping is local to a
>particular action, the Action class should call findForward on the mapping
>that's passed in. But if the mapping is a global one, it should call
>findForward on the instance of ActionServlet (called servlet) that is passed
>down from the parent Action class. Is this correct? Or does the
>ActionMapping that's passed in to the perform() method already contain the
>global mappings? The reason I ask if because I really don't like the idea
>of having access (and having to use) member variables of a parent class. It
>makes my OO alarms go off. The example Struts application uses the
>"servlet" object, instead of the ActionMapping instance.
--
Kumera - a new Open Source Content Management System
for small to medium web sites written in Perl and using XML
http://www.cyber4.org/kumera/index.html
Re: 2 newbie questions..
Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Sat, 12 May 2001, Roy Truelove wrote:
> Hey guys,
>
> Quick questions from a newbie.. When the mapping is local to a
> particular action, the Action class should call findForward on the mapping
> that's passed in. But if the mapping is a global one, it should call
> findForward on the instance of ActionServlet (called servlet) that is passed
> down from the parent Action class. Is this correct? Or does the
> ActionMapping that's passed in to the perform() method already contain the
> global mappings? The reason I ask if because I really don't like the idea
> of having access (and having to use) member variables of a parent class. It
> makes my OO alarms go off. The example Struts application uses the
> "servlet" object, instead of the ActionMapping instance.
>
If you call findForward() on the mapping, the implementation will search
first in the local definitions, and then in the global definitions,
without you having to worry about it. Thus, your Action can always call
mapping.findForward() and not worry about where it's defined.
> Second question has to do with subclassing an ActionMapping class. As I
> understand it right now, the default ActionMapping class that is passed into
> the perform() method is created using the configuration XML file. It
> contains the local mappings that are defined in the <action> tag for this
> path (as well as the global mappings?) This seems to make sense, but in the
> example application, there is a subclass of ActionMapping calling
> ApplicationMapping, with some get / set methods. I can't find where this
> class is used in the application, nor an explaination of it in the
> walk-through or the user-guide.
This class isn't used any more because the standard ActionMapping has
everything that the example app needed. (I should remove that class to
avoid confusion). However, earlier this evening I wrote a fairly length
HOWTO response on how to customize ActionMappings to add parameters that
are configured in the struts-config.xml file. This is a very convenient
way to pass configuration information to an Action.
>
> Thanks in advance for your help. I'm trying to fully understand the example
> app before trying struts on my own, and these are a few of my hangups.
>
> Take it easy,
> Roy
>
>
Craig