tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hans Bergsten <>
Subject Re: lameness with jsp:setproperty for non-basic types
Date Thu, 18 May 2000 21:53:22 GMT
Joakim Verona wrote:
> hello,
> i'm experiencing a problem when setting non-basic properties with jsp:setproperty.
> ok, the problem is maybe to the spec, but its still irritating, and i wonder 
> if anybody has a neat solution to it?
> say that you have a bean, with date properties for instance. you want the bean 
> to have get/set for the date property. but in your forms, you must send strings. 
> jsp:setproperty does not convert the string to a date, so you must do it yourself.
> ok, so you add a setDate(String s) overloaded method, (you already have a 
> setDate(Date d) of course). But this breaks the bean introspection code in tomcat, 
> so this is not possible.
> so then you must rename the setDate to setDateStr or someting similar, and handle 
> the string->object conversion yourself.
> this is inconvenient and voids the elegance of setproperty * in my opinion.
> i assume this is well-known, but is there any more elegant solutions, or 
> proposals for the future behaviour of tomcat?

This is caused by the fact that the JavaBeans spec (or, more correctly, the bean
introspection classes) doesn't allow more than one setter method for a property.
Something that should be looked at for the next version of the JSP spec is to
see of the standard beans way of handling multi-type setters for a property,
through java.beans.PropertyEditor classes, can be used in JSP.

Hans Bergsten
Gefion Software

View raw message