aspose file tools*
The moose likes Struts and the fly likes Problems displaying error messages when validating forms Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problems displaying error messages when validating forms" Watch "Problems displaying error messages when validating forms" New topic
Author

Problems displaying error messages when validating forms

Radu Todoran
Greenhorn

Joined: Oct 22, 2004
Posts: 3
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.


Only 2 things are infinite in the world... the univers and stupidity!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61224
    
  66

"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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61224
    
  66

Moving this topic to the Web Frameworks forum where the Struts crowd hangs out.
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4462
    
    6

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 ]

Junilu - [How to Ask Questions] [How to Answer Questions]
Radu Todoran
Greenhorn

Joined: Oct 22, 2004
Posts: 3
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).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problems displaying error messages when validating forms