I've been looking into the BeanUtils isssue,  and I've posted details on
that bug - see Bug 28358

    http://issues.apache.org/bugzilla/show_bug.cgi?id=28358

To summarise, there is a problem in how different versions of the JDK work
with indexed properties when you use java.util.List for your indexed
properties. However using Arrays doesn't have any issues (as far as I know)
and my advice would be (if you don't want to use DynaBeans) is to change
your ActionForm to use Arrays rather than java.util.Lists. So your methods
for the "foos" property in your ActionForm would look like:

   public Foo[] getFoos()
   public Foo getFoos(int index)
   public void setFoos(Foo[] foos)
   public void setFoos(int index, Foo foo)

That way you can use consistent property names throughout and the error
highlighting should work:

In your jsp...

   <c:forEach items="foos" id="foos">
       <html:text errorStyleClass="fooError" name="foos" property="day"
indexed="true" />
   </c:forEach>

In your validation.xml

   <field indexedListProperty="foos" property="day" depends="mask">

Niall

----- Original Message ----- 
From: "BLOOMFIELD, TOM F [AG-Contractor/1000]"
<[EMAIL PROTECTED]>
To: <user@struts.apache.org>
Sent: Thursday, January 27, 2005 7:07 PM
Subject: errorStyleClass and lists


>
> Per suggestion, I'm posting a follow up to see if anyone on the list has a
solution/suggestions to the "issue/enhancement" below:
>
> http://issues.apache.org/bugzilla/show_bug.cgi?id=33258
>
> Summary: To get around the problem with BeanUtils, I have an actionform
with the following list structure:
>
> List foos;
>
> List getFoos() {
>  return foos;
> }
> void setFoos(List foos) {
>  this.foos = foos;
> }
> Object getFoo(index) {
>  .. initialize list capacity..
>  return this.foos.get(index);
> }
>
> In my JSP, I iterate over this list and output elements as so:
>
> <c:forEach items="foos" id="foo">
>   <html:text errorStyleClass="fooError" name="foo" property="day"
indexed="true" />
> </c:forEach>
>
> This works great and gets/sets my list accordingly.  All is well.
>
> I created a validation for this list:
>
> <field indexedListProperty="foos" property="day" depends="mask">
> ...
> </field>
>
> This validates my list and puts errors into the global errors with keys
that look like this:
>
> foos[xxx].day
>
> That's fine, it validates, and stores errors.   However, since the key it
creates, "foos[xxx].day" is different than the name of my html:text,
"foo[xxx].day", the errorStyleClass is never used - the two don't match.
>
> As pointed out by Niall (see bug link above), I could use a different
method name to get/set the list in my actionform.  However, doing this
causes a BeanUtils error when the page renders (see related bug Niall
included).
>
> There seem to be a plethora of examples showing how to get/set lists in
the manner I posted above, so assume other people have/will have this issue
with errorStyleClass.
>
> Does anyone have a work around or suggestion for how to fix this without
relying on a change to the validator/BeanUtils.
>
> Thanks!
> Tom



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to