You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Bud Gibson <fp...@umich.edu> on 2001/07/19 03:13:29 UTC

beans:write bug?

We have a bean with properties where the setter takes a float, and the 
getter returns a string.  Using expressions and scriptlets, this all 
works fine.

For instance, I can write the following for a bean contained inside another:

<%= HagBean.getProduct().getPrice() %>

and a formatted string with the price will appear.  However, when we try 
the equivalent bean:write,

<bean:write name="HagBean" property="product.price" />

struts tells us that we are mismatching types with a float and String.

Is this a bean:write bug?  As I understand beans, setter methods are not 
even required.  I find it odd that bean:write seems to be assuming the 
type of the setter method and then becoming unhappy when it gets the 
type returned by the getter method.

Thanks,
Bud
-- 
_______________________________________
Bud Gibson
e-Lab Czar
Assistant Professor
University of Michigan Business School
701 Tappan Street, C2424
Ann Arbor, MI 48109-1234
ph:  734\647-9200
fax:  734\764-3240
fpgibson@umich.edu


Re: beans:write bug?

Posted by Martin Cooper <ma...@tumbleweed.com>.
This is a consequence of the JavaBeans introspection mechanism. The getter
and setter must be getting and setting the same type for them to be
recognized as property accessors. See the Introspection chapter of the
JavaBeans spec for more details.

--
Martin Cooper


----- Original Message -----
From: "Bud Gibson" <fp...@umich.edu>
To: <st...@jakarta.apache.org>
Sent: Wednesday, July 18, 2001 6:13 PM
Subject: beans:write bug?


> We have a bean with properties where the setter takes a float, and the
> getter returns a string.  Using expressions and scriptlets, this all
> works fine.
>
> For instance, I can write the following for a bean contained inside
another:
>
> <%= HagBean.getProduct().getPrice() %>
>
> and a formatted string with the price will appear.  However, when we try
> the equivalent bean:write,
>
> <bean:write name="HagBean" property="product.price" />
>
> struts tells us that we are mismatching types with a float and String.
>
> Is this a bean:write bug?  As I understand beans, setter methods are not
> even required.  I find it odd that bean:write seems to be assuming the
> type of the setter method and then becoming unhappy when it gets the
> type returned by the getter method.
>
> Thanks,
> Bud
> --
> _______________________________________
> Bud Gibson
> e-Lab Czar
> Assistant Professor
> University of Michigan Business School
> 701 Tappan Street, C2424
> Ann Arbor, MI 48109-1234
> ph:  734\647-9200
> fax:  734\764-3240
> fpgibson@umich.edu
>
>