Lukasz Lenart wrote:
> <s:debug/>
what I’m really trying to do is have nice integration between s:select and
enums. I want a select box with each of the enum choices in it. For this to
work, I'd need the enum name as the key in a map, and a
user-friendly-string-representation of the enum as the value.
I can't find an easy way to do this with the struts tags. My options seem to be:
a) write code in my action to return this map (what if multiple actions need
the same enum? would each action have to extend a super class so as not to
duplicate the method?)
b) write a static helper method which takes an enum and returns a map, and call
that method from OGNL in the JSP
c) a pure OGNL solution in the JSP
d) write a custom tag
I'll probably go the custom tag route, but when trying the pure OGNL option,
the best I could come up with was:
<s:set name="enumMap" value="#{}"/>
<s:iterator id="enum" value="[EMAIL PROTECTED]@values()}">
<s:set name="dummyVariable" value="%{#enumMap.put(#enum.name(),
#enum.toString())}"/>
</s:iterator>
<s:select name="myEnum" list="%{#enumMap}"/>
Brad Cupit
Louisiana State University - UIS