***********************
Your mail has been scanned by InterScan MSS.
***********************
Qestion - what is the purpose of th e following test?
if (component instanceof UIInput ||
UIInput.COMPONENT_FAMILY.equals(component.getFamily())) {
Regards,
Yee
-----Original Message-----
From: Mario Ivankovits [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 18, 2006 4:11 PM
To: MyFaces Discussion
Subject: Re: JSF and Java 5.0 Enums
Hi Yee!
> I found some useful hints on how to handle Enum in JSF.
>
> http://brondsema.net/blog/index.php/2005/09/30/jsf_and_java_5_0_enums
>
> I think this is good material for Wiki, for the "Convertion and
> Validation" section.
>
I am not sure if we should add this blog entry as "official way" how to
handle enums.
I commented the blog, though, here my are my doubts again:
I think its better to use "name()" as "toString()" as toString might be
customized by the developer.
public enum MyEnum
{
ABC("myAbc"),
DEF("myDef"),
UIO("myAbc");
private final String description;
MyEnum(String description)
{
this.description = description;
}
public String toString()
{
return this.description;
}
}
Though, I'd even used ordinal() as you can see here:
http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox15/core/src/main/
java/org/apache/myfaces/custom/dynaForm/jsfext/EnumConverter.java?view=marku
p
As you can see, I render a special string with "[EMAIL PROTECTED]" that way
I avoid the use of valueBinding.getType() thing which can fail if it
e.g. points to a list or method with a simple Object as return type
(Though, not very likely I admit ;-) )
For sure, that way the user isn't really able to input the value of an
enum, though, I think the main use case of an enum in JSF is to show the
user a selection menu.
Just additional ideas ...
Ciao,
Mario