File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Application Frameworks and the fly likes Output messages in Spring Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Application Frameworks » Other Application Frameworks
Reply Bookmark "Output messages in Spring" Watch "Output messages in Spring" New topic
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
 
Threads others viewed
WA #1.....word association
Frameworks
What Is the Next Marketable Technology To Learn
Spring MVC - repopulate the already entered values ?
How to handle 'Success Messages' in Spring MVC in a manner similar to 'Error Messages'

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture