struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Newton <>
Subject Re: prepare action for input after validation errors
Date Mon, 08 Sep 2008 21:27:45 GMT
--- On Mon, 9/8/08, 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

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.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message