struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Hardy <>
Subject Re: Validation and error messages in session
Date Mon, 17 Oct 2005 20:02:53 GMT
It's a shame no-one answered this. I was interested in reading a reply.

My situation is that on validation failure, my 'input' mapping is to 
another action, not direct to a JSP, so that I can carry out the 
necessary view helper code. As part of this I can also grab the 
validation errors from the request scope and save them in session if I want.

However I like the idea of declaring that the errors go straight into 
session scope.


Robert Taylor on 16/10/05 11:10, wrote:
> Greetings, I'm using Struts 1.2.7 and noticed that functionality has 
> been added to the Action class to store error messages in the session 
> and subsequently be removed after they have been rendered. This is quite 
> helpful in some circumstances.
> I also know that error messages can be placed in the session or request 
> scope when using the Exception handling framework. Again, this is quite 
> helpful in some circumstances.
> Are there plans to add this to the Validation framework as well such 
> that we can declaratively identify the scope in which to place the 
> validation messages. I know that upon a validation error that the 
> default RequestProcessor forwards to a configured url and that since the 
> request is forwarded, then there is no need to store them in the session.
> I recently came upon a case where I have a page with conditionally 
> "imported" page fragments. The page fragment contained an iframe with 
> some dynamic text input fields. Upon a validation error in the iframe, 
> it forwarded the request to its parent which subsequently rendered the 
> page which subsequently and conditionally imported the page which was 
> supposed to contain the validation error message. Since the import 
> (c:import) was considered a separate request, the validation error 
> messages was lost.
> I ended up subclassing the ActionMapping class, adding a 
> validationMessageScope property.
> I also subclassed the RequestProcessor processValidate() and added logic 
> to look for the subclassed ActionMapping class; if found to look up the 
> scope into which to place the validation error messages. If the property 
> had not been set, defaulted to the request scope.
> So when ever I need to propogate the validation error message across 
> requests, I just add a <set-property property="validationMessageScope" 
> value="session"/> and the error messages is placed in the session.
> Struts takes care of removing the error messages from the session after 
> they have been rendered.
> I know this is a special case. The only reason I ask is that Struts 
> already supports the concept of storing the messages in the session and 
> the current Exception Handling framework supports this concept. It 
> didn't seem like too much of a stretch, to allow the Validation 
> framework to support it.
> Just a thought.
> /robert
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

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

View raw message