Dear Wiki user, You have subscribed to a wiki page or wiki category on "Tapestry Wiki" for change notification.
The "Tapestry5EnumAsComponentParameter" page has been changed by LeonardLu. http://wiki.apache.org/tapestry/Tapestry5EnumAsComponentParameter -------------------------------------------------- New page: A quick example of declaring an [[http://java.sun.com/docs/books/tutorial/java/javaOO/enum.html|enum type]] and using it as a parameter in a Tapestry component. === Declaring the enum type === {{{ public enum Day { SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY } }}} === Declaring the enum parameter in a component class === {{{ @Parameter private Day day; }}} == Adding the String To Enum type coercion == In order to use literal string values for your enum parameter in your component, add a coercion from String to your enum class by adding the following code to your module class {{{ public static void contributeTypeCoercer(Configuration<CoercionTuple> configuration) { configuration.add(new CoercionTuple<String, Day>( String.class, Day.class, StringToEnumCoercion.create(Day.class) )); } }}} === Passing a literal string value to your enum parameter === {{{ <t:mycomponent day="literal:WEDNESDAY" /> }}} --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
