Back Forum Reply New

Spring 2.5rc1 errors tag

After rolling to Spring 2.5rc1, the form:errors tag is throwing an exception when I try to display the global error message.  Here is how I have used this tag successfully in the past to display the form's global error message.

lt;form:errors cssClass=quot;errorquot; /gt;

Now when I use this, I get the following exception.

ERROR [web.servlet.tags.form.ErrorsTag] Invalid property '' of bean class [org.myproject.bean.SomeFormBean]:
Bean property '' is not readable or has an invalid getter method:
Does the return type of the getter match the parameter type of the setter?
org..beans.NotReadablePropertyExcep  tion:
Invalid property '' of bean class [org.myproject.bean.SomeFormBean]:
Bean property '' is not readable or has an invalid getter method:
Does the return type of the getter match the parameter type of the setter?
at org..beans.BeanWrapperImpl.getPrope  rtyValue(BeanWrapperImpl.java:544)
at org..beans.BeanWrapperImpl.getPrope  rtyValue(BeanWrapperImpl.java:536)
at org..validation.AbstractPropertyBin  dingResult.getActualFieldValue(AbstractPropertyBin  dingResult.java:78)
at org..validation.AbstractBindingResu  lt.getFieldValue(AbstractBindingResult.java:337)
at org..web.servlet.support.BindStatus  .lt;initgt;(BindStatus.java:118)
at org..web.servlet.tags.form.Abstract  DataBoundFormElementTag.getBindStatus(AbstractData  BoundFormElementTag.java:171)
at org..web.servlet.tags.form.ErrorsTa  g.shouldRender(ErrorsTag.java:131)

The only way I can get it to not throw an exception is by displaying all error messages including the field level messages this way.

lt;form:errors path=quot;*quot; cssClass=quot;errorquot; htmlEscape=quot;falsequot; /gt;

This ends up showing field level messages as well which is not desired.  Is there a new path I should use for the global error message display?

When u say global error, how did u manage it ?

The Errors interface comes with methods reject() amp; rejectValue(). What did u use ?

I use reject() for such errors and it works like charm with lt;form:errors cssClass=quot;errorquot; /gt;

Regards,
Smruti..

This would be a message that I would display at the top of the form using the following syntax.Code:
errors.reject(null, quotlease correct the form values.quot;);
This results in a global error message that is not tied to a specific field being added to the errors.  With previous versions of Spring, I was able to display this global message at the top if my form by not including a path on the form:errors tag, and then field specific error messages on each field by adding the path on the form:errors tags on each field.  On 2.5rc1, if I do not include the path on the errors tag, an exception is thrown.  This did work in version 2.0.6.


Originally Posted by fuzzbientThis would be a message that I would display at the top of the form using the following syntax.Code:
errors.reject(null, quotlease correct the form values.quot;);
This results in a global error message that is not tied to a specific field being added to the errors.  With previous versions of Spring, I was able to display this global message at the top if my form by not including a path on the form:errors tag, and then field specific error messages on each field by adding the path on the form:errors tags on each field.  On 2.5rc1, if I do not include the path on the errors tag, an exception is thrown.  This did work in version 2.0.6.

Try this instead - errors.reject(quotlease correct the form values.quot;);

Lemme know what happens.

Regards,
Smruti..


Originally Posted by smrutimoTry this instead - errors.reject(quotlease correct the form values.quot;);

Lemme know what happens.

Regards,
Smruti..Just noticed the Spring version u mentioned... Hmm.. Yeah I also use 2.0.6.. My bad !! Guess I need a break from this desk.. Lemme know if this one works though...

Thanks amp; Regards,
Smruti..

That would work in 2.0.6 but this is strictly an issue with the form:errors tag in 2.5rc1.  Is it a bug or an quot;enhancement?quot;

It looks like a potential bug. The JavaDoc for the lt;form:errorsgt; tag states that it should be possible to display object-level errors only by omitting the quot;pathquot; attribute:

sp...ErrorsTag.html

I've opened a JIRA issue for further investigation:

proj...rowse/SPR-4005

Thank you for logging the issue in Jira.  I'll monitor it and test the update if it becomes available.

Try this...
lt;form:errorsgt;    lt;form:errors cssClass=quot;errorTextquot;/gt;
lt;/form:errorsgt;

it should work fine
¥
Back Forum Reply New