You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Elod Horvath <el...@itfais.com> on 2000/12/21 14:48:41 UTC

PROPOSAL: public method in ActionErrors to iterate across properties

I would like to propose that a public method be 
added to the ActionErrors class to retrieve an
enumeration of all the property names that 
have errors associated with them.  additionally, 
a size method should be added to return the 
count of the number of properties that have 
errors associated with them.
(Also, it may be useful or desired to associate
an ActionError instance directly with a property in
the ActionError class itself).

There currently is no way to associate an ActionError 
with a particular property unless you a priori 
know the property name in question.  this
is particularly troublesome when trying to 
use a generic error page to display validation errors.  
typically, in such a page, one needs to display
the field/property name associated with its errors. 
See, for example, this rendition of an error page:

     Validation Failure:
        
           property1     -     some error message1
                         -     some error message2
           property2     -     some error message3
           property3     -     some error message4
                         -     some error message5

Additionally, when the user goes back to the page 
with the relevant form, it is useful to somehow 
visually highlight the labels for the form entry fields 
in question.  without being able to get at the property 
names with errors, it's extremely difficult to 
accomplish this. The struts errors tag certainly provides 
no help in any of these situations.  Some thought needs
to go into creating a new set of tags to help with 
dealing with ActionErrors in a general way.  These
tags should not produce markup themselves -- the markup
should be done in the JSP page using them.  (They should
allow you to iterate errors grouped by property and to get 
at the property and error messages independently.  The
existing iteration and logic tags are too cumbersome and 
non intuitive for use here).

e
-- 
_______________________________________________________________________
Elod Horvath ('e')       /      ITFAIS Records (http://www.itfais.com/)

Re: PROPOSAL: public method in ActionErrors to iterate across properties

Posted by Elod Horvath <el...@itfais.com>.
"Craig R. McClanahan" wrote:
> 
> I just committed a patch that adds a properties() method to ActionErrors.  It
> returns an Iterator over the property names for which at least one error has
> been recorded.  The existing size(String) and get(String) methods can return you
> the number of errors for a particular property, and an Iterator of the actual
> errors for a particular property, respectively.
> 
> It is quite correct to say that the current <struts:errors> tag doesn't deal
> with the new flexibility provided by ActionErrors -- I'm open to suggestion for
> what to do for Struts 1.0.
> 

i've been working on a tag family for dealing with ActionErrors in a
generic way. i'll post my results for critique/consideration when i'm 
finally happy with them (within a day or 2).

e
-- 
_______________________________________________________________________
Elod Horvath ('e')       /      ITFAIS Records (http://www.itfais.com/)

Re: PROPOSAL: public method in ActionErrors to iterate across properties

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
I just committed a patch that adds a properties() method to ActionErrors.  It
returns an Iterator over the property names for which at least one error has
been recorded.  The existing size(String) and get(String) methods can return you
the number of errors for a particular property, and an Iterator of the actual
errors for a particular property, respectively.

It is quite correct to say that the current <struts:errors> tag doesn't deal
with the new flexibility provided by ActionErrors -- I'm open to suggestion for
what to do for Struts 1.0.

On the general problem of support for dynamically named properties, I think
that's a much bigger issue, and needs broad support throughout Struts.
Therefore, I'd like to put it on a (soon-to-be-created) list of desired
enhancements for Struts 1.1.

Craig


Elod Horvath wrote:

> I would like to propose that a public method be
> added to the ActionErrors class to retrieve an
> enumeration of all the property names that
> have errors associated with them.  additionally,
> a size method should be added to return the
> count of the number of properties that have
> errors associated with them.
> (Also, it may be useful or desired to associate
> an ActionError instance directly with a property in
> the ActionError class itself).
>
> There currently is no way to associate an ActionError
> with a particular property unless you a priori
> know the property name in question.  this
> is particularly troublesome when trying to
> use a generic error page to display validation errors.
> typically, in such a page, one needs to display
> the field/property name associated with its errors.
> See, for example, this rendition of an error page:
>
>      Validation Failure:
>
>            property1     -     some error message1
>                          -     some error message2
>            property2     -     some error message3
>            property3     -     some error message4
>                          -     some error message5
>
> Additionally, when the user goes back to the page
> with the relevant form, it is useful to somehow
> visually highlight the labels for the form entry fields
> in question.  without being able to get at the property
> names with errors, it's extremely difficult to
> accomplish this. The struts errors tag certainly provides
> no help in any of these situations.  Some thought needs
> to go into creating a new set of tags to help with
> dealing with ActionErrors in a general way.  These
> tags should not produce markup themselves -- the markup
> should be done in the JSP page using them.  (They should
> allow you to iterate errors grouped by property and to get
> at the property and error messages independently.  The
> existing iteration and logic tags are too cumbersome and
> non intuitive for use here).
>
> e
> --
> _______________________________________________________________________
> Elod Horvath ('e')       /      ITFAIS Records (http://www.itfais.com/)