| Author |
Output messages in Spring
|
Elie Hirschman
Ranch Hand
Joined: Dec 15, 2005
Posts: 37
|
|
|
Is there a way to store non-error messages in Spring, such that when a form passes validation and submits to the next view, we are able to say "X number of rows updated" (for lack of a better example)?
|
 |
Sonny Gill
Ranch Hand
Joined: Feb 02, 2002
Posts: 1209
|
|
[Removed my noob suggestion, since Ken's post addresses it much better ] [ January 04, 2006: Message edited by: Sonny Gill ]
|
The future is here. It's just not evenly distributed yet. - William Gibson
Consultant @ Xebia. Sonny Gill Tweets
|
 |
Ken Krebs
Ranch Hand
Joined: Nov 27, 2002
Posts: 451
|
|
It depends on whether you're forwarding or redirecting. If you're simply forwarding, rather than directly setting a request attribute, the Spring way is to simply add the messages to the Model part of the ModelAndView that is returned by the OnSubmit method. If you're forwarding, which I prefer for form submissions, there are a numbe rof approaches. You could add it to the session under a "well known" key and have your Controller invoke a utility method that extracts it and removes from the session, perhaps also placing it in the Model for rendering or having the Controller do it. The benefit of using the Model instead of directly using the Servlet api shows up when you decide you want to use a View rendering technology other than JSP, one that doesn't know anything about servlets or sessions.
|
kktec<br />SCJP, SCWCD, SCJD<br />"What we observe is not nature itself, but nature exposed to our method of questioning." - Werner Heisenberg
|
 |
 |
|
|
subject: Output messages in Spring
|
|
|