Hi,
You might need to add a new property editor, see Adding New Property
Editors at
http://tapestry.apache.org/tapestry5/tapestry-core/guide/beaneditform.html.
-Filip
On 2008-04-15 18:37, Tobias Wehrum wrote:
Hi there,
I have a class named "Status" which implements toString(). But still
when I have class A, which has a property of type Status, I always have
to add the Status property to the BeanModel with model.add("myStatus").
Obviously implementing toString() isn't enough to teach my the BeanModel
a new trick. So I tried to contribute a TypeCoercer and a
TranslatorSource, but neither of them seems to work.
My try on TypeCoercer:
--------------------------------------------------
public static void contributeTypeCoercer(Configuration<CoercionTuple>
configuration)
{
Coercion<Status, String> coercionStatusString = new
Coercion<Status, String>()
{
public String coerce(Status input)
{
return input.toString();
}
};
configuration.add(new CoercionTuple<Status,
String>(Status.class, String.class, coercionStatusString)); }
--------------------------------------------------
My try on TranslatorSource:
--------------------------------------------------
public static void
contributeTranslatorDefaultSource(MappedConfiguration<Class, Translator>
configuration) {
configuration.add(Status.class, new StatusTranslator());
}
public static void
contributeTranslatorSource(MappedConfiguration<String, Translator>
configuration) {
configuration.add("status", new StatusTranslator());
}
--------------------------------------------------
--------------------------------------------------
public class StatusTranslator implements Translator<Status> {
public Class<Status> getType() {
return Status.class;
}
public Status parseClient(String arg0, Messages arg1)
throws ValidationException {
throw new ValidationException("StatusTranslator cannot implement
parseClient()");
}
public String toClient(Status arg0) {
return arg0.toString();
}
}
--------------------------------------------------
Am I missing something? Or am I on a complete wrong path?
Any hints on how to solve my problem are welcome.
Thanks in advance,
Tobias
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]