I can iterate over HashMap *values* no problem when the value is a String. However when the value is a bean I don't know how to get at the properties (the getter methods) of the bean! It seems that struts allows only property="value" or property="key". I need something like property="value, property in value object=fieldname". Can anyone help? Thanks!
It'd help if you included how you were trying to access the values, and potentially which version of Struts.
Steve Dambrosio
Greenhorn
Joined: Apr 02, 2009
Posts: 28
posted
0
Struts version is 1.1
I'm using the iterate tag as follows.
Remember, the *value* object is a bean. An interesting side-bar: bean:write actually renders the contents of the bean! This is because the bean has overridden the toString method with one that returns a string containing formatted contents of the instance variables with labels. However, I want just one value, not the whole bean! Thanks.
Why not set a value with the bean value, then access that? I don't even know how to do that, what with S1.1 being like 10 years old or something... when functionality overlaps with JSTL, you should really be using JSTL. <bean:define>, maybe?
Steve Dambrosio
Greenhorn
Joined: Apr 02, 2009
Posts: 28
posted
0
Thanks for the prompt reply! Your post is somewhat unclear to me but I think you're saying that I might be able to define a bean, "extract" the HashMap value into the bean and then get at the fields (well, the setter methods). Sounds intriguing given that this would happen within an interate loop. I'll give it some more thought. In the mean time I decided I can change the collection in my ActionClass to be an ArrayList and populate the ArrayList from the HashMap using hashMap.values(). Still there should be an easy way to iterate through the values of a HashMap when the value is a bean! P.S. sorry about the S1.1 but it's a big (er... gigantic) corporation.