aspose file tools*
The moose likes Struts and the fly likes STRUTS-errors tag - Proper(ty) Usage Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "STRUTS-errors tag - Proper(ty) Usage" Watch "STRUTS-errors tag - Proper(ty) Usage" New topic
Author

STRUTS-errors tag - Proper(ty) Usage

KRISH DOSS
Greenhorn

Joined: Feb 16, 2002
Posts: 19
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 [
Jason Menard
Sheriff

Joined: Nov 09, 2000
Posts: 6450
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.
Adam Hardy
Ranch Hand

Joined: Oct 09, 2001
Posts: 565
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


I have seen things you people would not believe, attack ships on fire off the shoulder of Orion, c-beams sparkling in the dark near the Tennhauser Gate. All these moments will be lost in time, like tears in the rain.
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
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


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
KRISH DOSS
Greenhorn

Joined: Feb 16, 2002
Posts: 19
Thanks all for your immediate replies.
Ted J Schrader
Greenhorn

Joined: Oct 10, 2001
Posts: 28
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: STRUTS-errors tag - Proper(ty) Usage
 
Similar Threads
Placing error message near text field
Problem Running Struts Example
Show Struts error in JSP
Configurting all errors to single page
Cannot find ActionMappings or ActionFormBeans collection