Hi

Type coercion from String to an Enum type doesn't seem work. I get an
IllegalArgumentException even though I wrote a special TypeCoercer and
hooked it in via module.

  public static void
contributeTypeCoercer(Configuration<CoercionTuple<String,Size.Unit>>
configuration) {
    configuration.add(new
CoercionTuple<String,Size.Unit>(String.class, Size.Unit.class, new
Coercion<String,Size.Unit>() {
      public Size.Unit coerce(String input) {
        return Enum.valueOf(Size.Unit.class, input);
      }
    }));
  }


java.lang.IllegalArgumentException
Could not find a coercion from type java.lang.String to type
com.example.server.web.components.Size$Unit. Available coercions:
[...] String --> com.example.server.web.components.Size$Unit [...]

Stack trace
        * 
org.apache.tapestry5.ioc.internal.services.TypeCoercerImpl.findOrCreateCoercion(TypeCoercerImpl.java:245)
        [...]
        * 
com.example.server.web.components.Size._$read_parameter_unit(Size.java)

Is it possible that Class.isAssignableFrom() does not work for Enum
types? (see TypeCoercerImpl:231)

There's already an issue report
(https://issues.apache.org/jira/browse/TAP5-98) where the reporter
indicates that this should work. Would did I do wrong?

Regards,
Folke

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to