Ok, i understand that with:
    "return new ActionForward(mapping.getInput());"
i can get back to the calling Page.

First Question:
  Should i declare this page via an
     "  input="/here_i_came_from.jsp"> "
  entry in the struts-config or does he know where he cames from?

Second Question:
  Can U give me an codeexample how to use the actionForward within
  an action, where i try to jump not to an following normal forward.
  I like to go to the next action in the strutsconfig for reusing it.
  (I like to get 2 vectors of 2 different actions in a session for an
  overview jsp-page.)
  When I try this I also get a "null".

thanks o lot

I try it this way:
              return new ForwardingActionForward("Action2");
or            return new ActionForward("Action2");


-----Ursprungliche Nachricht-----
Von: Ted Husted [mailto:[EMAIL PROTECTED]]
Gesendet: Sonntag, 4. November 2001 10:53
An: Struts Users Mailing List
Betreff: Re: forward action - basic understanding



David Larson wrote:
> I've seen examples where both...
> return mapping.findForward("success");

In this case, there is an existing ActionForm named "success". These are
usually defined in the Struts configuration file (struts-config.xml).
The ActionForward gives the path a logical name (e.g. "success").

This form is "exit normally". It can be used to select among several
different exit options, depending on the circumstances.


> return new ActionForward(mapping.getInput());

The getInput method returns a path. Here, it is being wrapped into a new
(unnamed) ActionForward in order to complete perform's contract (return
an ActionForward object).

> ...redirect to the same location (and the new ActionForward appears to
> always be used under user error type situations).  What's the difference
> between these two (in re: to what they do behind the scenes) and what's
the
> rule on when to use one method vs. the other?

getInput is used by the ActionController when an ActionForm's validate
method fails. So in this form, the developer is doing the same thing --
sending control back to "input" because there is an error. This is not
exactly a rule, but it is generally what needs to be done when an error
occurs.

On a general error, like an exception was thrown and caught, I now
usually look for an input property, and not finding one, I look for an
error handler.

        // -- Report any errors
        if (!errors.empty()) {
            saveErrors(request, errors);
            if (mapping.getInput()!=null)
                return (new ActionForward(mapping.getInput()));
            // If no input page, use error forwarding
            return (mapping.findForward("error"));
        }


-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/struts/

--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to