struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kris Schneider <k...@dotech.com>
Subject Re: <bean:write> not writing?
Date Sat, 27 Dec 2003 15:13:15 GMT
I'm pretty sure this boils down to the way PropertyUtils works. 
<bean:write> will use PropertyUtils.getProperty(bean, property) to 
retrieve the "subTotal" property from the bean "cart". PropertyUtils 
will test whether or not "cart" is a Map (which it is) and then call 
Map.get to retrieve the property value. Since you've defined "subTotal" 
as a standard JavaBean property, <bean:write> (or really PropertyUtils) 
won't be able to find it.

Michael Marrotte wrote:

> Here's the bean:
> 
> public class Cart extends HashMap {
>     private double subTotal = 400.00;
>     public double getSubTotal(){return subTotal;}
> }
> 
> 
> Here's the Java:
> 
> session.setAttribute("cart", new Cart());
> 
> 
> Here's the JSP
> 
> <bean:write name="cart" property="subTotal"/> // no output?
> <%= ((csp.Cart)session.getAttribute("cart")).getSubTotal() %> // works,
> writes 400.0
> 
> 
> Here's the problem
> 
> <bean:write> isn't producing any output, but
> 
> <%= ... %> is...
> 
> Any ideas are greatly appreciated.
> 
> Thanks,
> 
> --Mike M.

-- 
Kris Schneider <mailto:kris@dotech.com>
D.O.Tech       <http://www.dotech.com/>



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message