struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Newton <newton.d...@yahoo.com>
Subject Re: prepare action for input after validation errors
Date Mon, 08 Sep 2008 21:27:45 GMT
--- On Mon, 9/8/08, jnizet@free.fr wrote:
> I don't have any input method. I have a displayForm
> method, and a submitForm method. 
> 
> The displayForm method returns an input *result*, which is
> a default result pointing to a JSP. This JSP has to display
> some data coming from the database. I'd like this same
> JSP to be displayed when the input *result* is returned by
> the workflow interceptor after validation fails. My problem
> is that I don't know how to make Struts get the data
> necessary to render the input JSP. This data is prepared by
> the displayForm action method when it's displayed
> initially, but when the form is submitted and a validation
> error occurs, Struts goes directly to the input JSP without
> calling any action or other method. There is no (AFAIK)
> equivalent of the prepare interceptor for *results*.
> 
> The way that seems to be suggested by the documentation is
> to prepare the data by calling an action from the JSP
> itself, but I don't like this solution very much
> because, if the data preparation method throws an exception,
> it won't be handled correctly (since the HTML has
> already been partly sent to the browser).
> 
> I could also chain the actions by making the input result
> chain to another action method, but this is discouraged by
> the doc (see http://struts.apache.org/2.x/docs/action-chaining.html).

A couple of ideas have already been provided; the way your application is currently structured
leaves you with little alternative than to implement one of the suggestions or re-structure
things a bit.

An additional potential solution I don't recall seeing is to override validate(), call super.validate(),
and if there are errors, call the initialization code.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message