It'd only be a few line custom Taglib to write a tag that does a HashMap key
lookup. It's not possible with <bean:write> in its current form, although
I believe the Commons BeanUtils code has recently been updated to include
this kind of lookup, but its not necessary in order to write a simple custom
tag.
Erik
----- Original Message -----
From: "Paul King" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, September 19, 2001 4:45 PM
Subject: dealing with HashMaps instead of beans
> I've encountered 2 jsp apps recently that are passing data around in
> HashMaps instead of java classes with getters and setters. Without
> re-writing everything, I'm trying to use struts to re-write the display
> and controller code of these apps, but I haven't found a good way to
> deal with these non-bean HashMaps. I really want to avoid changing all
> the model code that deals with HashMaps, but I'd like to use the
> bean-oriented taglibs that struts offers.
>
> Here's an example. The model api provides a getProducts method, which
> returns a List of HashMaps that contain product-related keys (productID,
> productName, productDescription, ...). Ideally, I could do something
> like this:
>
> <logic:iterate id="product" name="products">
> productID is <bean:write name="product" property="productID"/>
> productName is <bean:write name="product" property="productName"/>
> productDescription is <bean:write name="product"
> property="productDescription"/>
> </logic:iterate>
>
> So, is there some trick or workaround to get HashMaps to work in this
> and other cases where beans are expected? I've seen previous threads
> that demonstrate how individual map entries can be accessed as valid
> beans, but that's not the issue here.
>
> Thanks,
>
> paul
>
>
>