• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

STRUTS-errors tag - Proper(ty) Usage

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I like to show error message near to
form fields, instead of showing all
error messages at the top of page,
using STRUTS.
Is this the proper way to get it done
by using <html:errors property="propertyName"/> near form field?

Is there any other proper way to do it?

thanks krishna [
 
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's what the docs say. It should be a simple enough thing for you to try out and see if you get the proper results. Keep in mind that error.heander and error.footer still print out I think.
 
Ranch Hand
Posts: 567
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I haven't used the html:errors tag like that but I assume that you would have to specify the filter properly (e.g. ActionErrors.GLOBAL_ERROR etc) otherwise your errors would probably all appear at the first instance of the errors tag.
I think
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Krish,
That is the correct way to do what you want. I mention it in the Struts article in the JavaRanch newsletter:
http://www.javaranch.com/newsletter/Mar2002/newslettermar2002.jsp#struts
 
KRISH DOSS
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks all for your immediate replies.
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would like to mention that we can display both global errors and field-specific errors in the same page in a mutually-exclusive fashion (well, it's working with Struts 1.1b2, anyway).
Sometimes, it would be nice if we could display global errors at the top, and field-specific errors near the fields. Anyone who has tried using <html:errors /> at the top knows that all errors will be displayed, not just the global one like we want.
To lock out the field-specific errors, do this:

Then, continue with each field:

This idiom does make the assumption that the Action classes are using ActionErrors.GLOBAL_ERROR.

The following is just a quick discussion of the code's "aesthetics", so feel free to skip this part.
At first glance, the code for displaying the GLOBAL_ERROR might not look like it's the "Struts Way" (at least, it didn't to me), since the whole point of custom tags is to eliminate scriptlets. A week ago, I would have thought that it wouldn't even compile, being a JSP expression inside a custom tag. But it does, and that's always a good thing! Also, I don't consider the expression syntax <%= %> a scriptlet, which, from my impression of the Struts UserGuide, is in accord with the Struts folks.
Also, in the UserGuide is the use of "(RT EXPR)", which I think means "Run Time Expression" which means JSP expressions can be used. Don't quote me on this, though.
I hope this helps.
Ted Schrader
SCJ2P
[ December 12, 2002: Message edited by: Ted Schrader ]
reply
    Bookmark Topic Watch Topic
  • New Topic