struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <Craig.McClana...@eng.sun.com>
Subject Re: STRUTS FRAMEWORK QUESTION
Date Sun, 11 Jun 2000 22:05:14 GMT
Kevin Duffey wrote:

> I don't think there is anything yet on how to use it. Most of us that know
> how is probably because we have talked about in the jsp-interest mailing
> list for quite some time. I just got it yesterday and haven't had time to
> play with it yet myself. It definitely looks better than what I have thus
> far.
>

See my answer to the documentation question in a separate response.

>
> Craig, my only question thus far...is it possible to have an action return
> more than GOOD/BAD responses (I think you name them success/fail). I would
> like to possibly forward to one of many JSP pages from an action based on a
> conditional logic result. For example, my login action needs to forward to
> one of four different pages. Can you possibly explain how I might be able to
> add multiple results and get it to work?
>

As long as you can name the four different responses, this is pretty easy to do
(following the model in the example app).  The steps go like this:

* Create a new subclass of ActionMappingBase that
  includes whatever additional properties you want.  The
  example application used "success" and "failure", but there
  is no limit to how many properties you add, or what you
  want to call them.

* In your web.xml file, when you are setting the initialization
  parameters for the controller servlet, set the "mapping"
  parameter to be the fully qualified class name of your
  ActionMapping class.  (In the example app, it used
  "org.apache.struts.example.ApplicationMapping").

* In your action.xml file, add the additional properties (with
  names that matched whatever you added in your
  ActionMapping implementation class) to each entry.

* In your action classes, you will have to cast the "mapping"
  argument you receive from the controller servlet to be an
  instance of your ApplicationMapping subclass, so that you
  can now call the property get methods for the new properties
  you have defined.  (In the example application, this was
  mapped to ApplicationMapping so that getSuccess() and
  getFailure() could be called.

As you can see, the whole environment is extensible in this way.  It is
appropriate to add properties for pretty much anything that is common to all (or
most -- properties do not have to be required) actions in this way.

>
> Thanks.
>

Craig McClanahan





Mime
View raw message