-
-
2. Re: How about <s:enumItems>?
stephen Jun 29, 2008 8:48 PM (in response to stephen)Hi Pawel and thanks for the answer.
However either you missed the point of my request or I completely misunderstood s:convertEnum.
AFAICS s:convertEnum is simply a converter (using the enum object's name() as String representation). You still need to specify SelectItems and to do that you need Java code.
Currently:
@Name("factories") public class Factories { @Factory("orderTypes") public OrderType[] getOrderTypes{ return OrderType.values(); } }
and
<s:selectItems value="#{orderTypes} ...
With my proposal you can get rid of the Java code and simply use:
<s:enumItems class="com.acme.OrderType" ...
As a side note: I found I so far never needed the s:convertEnum tag. When it is omitted, the index of the enum in the value list is used. I think that's just fine, because the ordering of enum items is stable (if you don't calculate them in a very funny way in java code).
For me the only open question is whether the s:enumItems approach is susceptible to class loader problems, as it would need to access the enum class using reflection (with the current thread's class loader?).
-
3. Re: How about <s:enumItems>?
stephen Jun 30, 2008 12:27 AM (in response to stephen)Hm, an alternative would be to add another function to Seam's EL functions that given the FQN would return a reference to a class:
<s:selectItems value="#{s:clazz(com.acme.OrderType).values()"} ...
That could be useful in other scenarios, too. Basically you would be able to call any public static method.