Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts newbie question - bean:message

 
Gyula Klinszky
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

A newbie Struts question: I have a data processing action, which can update, insert, or delete a record, and forwards to a "success page", which contains a message indicating what happenened (= different message based on the type of action).
What solution would you suggest to display this message, which is coming from a ResourceBundle (3 entries, one for insert, one for update, one for delete) ? I was trying for one bean:message, but the only solution I came up with was using Java scriptlet...

Thanks in advance, and sorry if the answer is obvious
 
Junilu Lacar
Bartender
Pie
Posts: 7783
62
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use the html:messages tag to do this.



You can do the same for other types of messages by changing "errormsg" to something else. What I did for my current project was to have a fixed set of message types, defined those types as constants and put all the code to display in one JSP. That way, other developers simply had to include the one JSP in the appropriate place in their page. This made the display of messages consistent throughout the application and also made maintenance a breeze: if we needed to change something, we just changed the one JSP.

Example:

 
Gyula Klinszky
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, Junilu, that is what I have been looking for. Of course having read about ActionMessages before, I feel somewhat stupid
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic