EnumTypeConverter
This class converts java 5 enums to String and from String[] to enum.
One of Java 5's improvements is providing enumeration facility.
Up to now, there existed no enumerations. The only way to simulate was the so-called int Enum pattern:
{code}
public static final int SEASON_WINTER = 0;
public static final int SEASON_SPRING = 1;
public static final int SEASON_SUMMER = 2;
public static final int SEASON_FALL = 3;
{code}
Java 5.0 now provides the following construct:
{code}
public static enum Season { WINTER, SPRING, SUMMER, FALL };
{code}
h3. Implementing Java 5 Enumeration Type Conversion
1. myAction-conversion.properties
Place a myAction-conversion.properties-file in the path of your Action.
Add the following entry to the properties-file:
{code}
nameOfYourField=fullyClassifiedNameOfYourConverter
{code}
2. myAction.java
Your action contains the _enumeration_:
{code}
public enum Criticality {DEBUG, INFO, WARNING, ERROR, FATAL}
{code}
* Your action contains the _private field_:
{code}
private myEnum myFieldForEnum;
{code}
Your action contains _getters and setters_ for your field:
{code}
public myEnum getCriticality() {
return myFieldForEnum;
}
public void setCriticality(myEnum myFieldForEnum) {
this.myFieldForEnum= myFieldForEnum;
}
{code}
3. JSP
In your jsp you can access an enumeration value just normal by using the known -Tag:
{code}
{code}