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