I would like to contribute a Translator for Long values that would allow me
to translate between byte counts and human readable file sizes (e.g.
5000bytes ~ 5MB). Since around 5.2 , the Translator configuration switched
to a Mapped configuration where each translator is contributed for a given
type. In my case, I just want to be able to use the translator I created in
text fields' "translate" property, so that I don't have to create the
translator on each page I need it.

E.g. I want to be able to use:

<t:textField value="..." translate="fileSize" />

When I attempt to contribute my FileSizeTranslator using the approach
below, I get a warning that I'm overriding the numeric translator from a
tapestry core module, which is not something I want to do.

    @SuppressWarnings("rawtypes")
    public static void
contributeTranslatorSource(MappedConfiguration<Class, Translator>
configuration) {
        configuration.add(Long.class, new FileSizeTranslator());
    }

Can anyone point me to how I can accomplish this ?

Cheers,

Alex K

Reply via email to