[EMAIL PROTECTED] (Jim Bell) wrote:
> Does struts provide a mechanism to recall the "requesting" view
> in case of validation errors. This could also be useful if
> someone requests a particular page, but is send to the logon
> page, and upon successful authentication would like to be
> automatically forwarded to the originally requested page.
Yes it does.
Override the ActionForm validate method in your form bean.
If you need to to extra checks in the Action perform method, then
you can configure an "input" for the action in struts-config.xml:
<action path="/create"
type="..."
name="createForm"
input="/WEB-INF/jsp/create.jsp"
scope="request">
</action>
then use this in the perform:
if( ! validationTest() )
{
// add error here
return new ActionForward( mapping.getInput() );
}
You can also do the logon thing. I use this, just forward to
your logon JSP if not logged on. Remember when you forward
you don't redirect, so the browser just sees it as a different
response to the same URL.
I'm not entirely convinced that this is the best way to handle
a logon since it breaks the IE feature of remembering passwords
since you end up with the logon form being returned from any one
of your URLs. I think it would be better to redirect (not forward)
to a logon action which remembering the action from which you came
in the session. Once the logon has completed OK, then redirect back.
I use a template method pattern for logon checking. If you do this
and combine with the "all URLs refer to actions" pattern then you
can have your logon checking in only one place.
Duncan Harris
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Hartford, Cheshire, U.K., Tel: 07968 060418
Looking for STRUTS contract work in the U.K.
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>