You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Craig R. McClanahan" <cr...@apache.org> on 2001/06/02 04:53:40 UTC

Re: 2 newbie questions..


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