This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Output messages in Spring

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)?
 
Ranch Hand
Posts: 1211
Mac IntelliJ IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[Removed my noob suggestion, since Ken's post addresses it much better ]
[ January 04, 2006: Message edited by: Sonny Gill ]
 
Ranch Hand
Posts: 451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
a wee bit from the empire
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!