> How do I associate more than one Translator to a type?

I think TranslatorAlternatesSource is what you want. It allows you to
specify translators by name and they can overlap types.

http://tapestry.apache.org/tapestry5.2-dev/apidocs/org/apache/tapestry5/services/TranslatorAlternatesSource.html

On Thu, Dec 2, 2010 at 4:53 AM, Paul Stanton <p...@mapshed.com.au> wrote:
> Hi,
>
> in 5.0 you used to be able to define and refer to Translators by name:
>
>    public static void contributeTranslatorSource(Configuration<Translator>
> configuration)
>    {
>        configuration.add(new MyTranslator("Decimal"));
>        configuration.add(new MyTranslator("Decimal2Dp"));
>    }
>
> I could then use <t:textfield ... t:translator="Decimal" /> for example.
>
> however in 5.2 you associate a translator to a type:
>
>    public static void contributeTranslatorSource(MappedConfiguration<Class,
> Translator> configuration)
>    {
>        configuration.add(Date.class, new DateTranslator("Date"));
>        configuration.add(Date.class, new DateTranslator("DateTime"));
>    }
>
> but this causes an exception:
> Service contribution (to service 'TranslatorSource') conflicts with existing
> contribution
>
> I assume because they are mapped to the same class.
>
> How do I associate more than one Translator to a type?
>
> Also, now that I have created all these fancy translators is there any way
> to use them as formatters as well?
>
> so that I can do <t:output ... formatter="trans:Date" /> or similar?
>
> thanks, p.
>
> ps I can't find the 5.2 version of the userguides
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>

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

Reply via email to