Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problems displaying error messages when validating forms

 
Radu Todoran
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm trying to upgrade my application from struts 1.1 to struts 1.2.4. The problem is I'm using ValidatorForm and I don't know what the code in the jsp should look like to display the error messages.
html:messages requires an id and I don't know what the value of the id shoud be if I'm using ValidatorForm.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65115
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"monstruletz monster",

We're pleased to have you here with us on the Ranch, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65115
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this topic to the Web Frameworks forum where the Struts crowd hangs out.
 
Junilu Lacar
Bartender
Posts: 7589
53
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It doesn't matter if you're using the ValidatorForm. The id attribute follows the standard JSP attribute naming convention: it is the name of a scripting variable. In the earlier versions of Struts, the html:errors tag iterated internally to display error messages. Because of its implementation, you had to include any HTML markup with the message text in your application resources file.

This has since changed. The html:messages now acts like a iteration loop. The current message will be accessible through the variable named by the id attribute. This way, you can keep the markup in the JSP, as it should be, and you only need to specify the message text in your application resources.

Example:


[ October 22, 2004: Message edited by: Junilu Lacar ]
 
Radu Todoran
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But one question is still unanswered... what should I put here: html:messages id="???"... because I'm using FormValidator the struts class does all the work( I'm not building any message object or anything hence I don't have the name of the Message variable).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic