Win a copy of Practice Tests for OCP Java 17 Certification Exam (1Z0-829) this week in the OCPJP 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

Problems displaying error messages when validating forms

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67641
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67641
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving this topic to the Web Frameworks forum where the Struts crowd hangs out.
 
Sheriff
Posts: 17005
298
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
When you have exhausted all possibilities, remember this: you haven't - Edison. Tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic