Thiago wrote: > > As of 5.1.0.5, it isn't possible to override them for a given type > globally, but you can override it in a given TextField instance (translate > parameter). > > Really? I wish that was my experience. Here's what I'm seeing; maybe you can point out what I've done wrong.
I have a custom BigDecimal translator that formats the number as a currency. (Code outlined below in case it matters.) A page has a couple of textfields, one specifying t:translate and one not: <t:textfield t:id="annualSales" value="company.annualSales" t:translate="bigdecimal"/> <t:textfield t:id="averageAr" value="company.averageAr"/> The result is that both textfields use the custom translator, as verified in the debugger and by looking at the resulting page. Why should the textfield without the t:translate get the custom translator? Should I specify some other t:translate to prevent that? The other problem I had, when I first upgraded to 5.1.0.5, was that my translator didn't always take effect. After some restarts, Tapestry's built-in BigDecimalNumericFormatter would be supplied. There was a thread about this; see http://old.nabble.com/overriding-a-translator-ts25791006.html Details: The essentials of the translator: public class BigDecimalTranslator extends AbstractTranslator<BigDecimal> { public BigDecimalTranslator() { super("bigdecimal", BigDecimal.class, "bigdecimal-format-exception"); } public BigDecimal parseClient(Field field, String clientValue, String message) throws ValidationException { // ... } public void render(Field field, String message, MarkupWriter writer, FormSupport formSupport) { // Do nothing; we don't support client-side validation. } /** Returns a string formatted as a currency. */ public String toClient(BigDecimal number) { // ... } } AppModule adds it: public static void contributeTranslatorSource(Configuration<Translator> configuration) { configuration.add(new BigDecimalTranslator()); }