I am sure my BigDecimal translator is no problem, I have fixed this problem by modify the Tapestry ioc's source code. ok, here is my translator.
1. package com.javaeye.dengyin2000.gtts.tapestry; 2. 3. import java.math.BigDecimal; 4. 5. import org.apache.tapestry.Translator; 6. import org.apache.tapestry.ValidationException; 7. import org.apache.tapestry.ioc.Messages; 8. import org.apache.tapestry.ioc.internal.util.InternalUtils; 9. 10. public class BigDecimalTranslator implements Translator<BigDecimal> { 11. 12. public BigDecimal parseClient(String clientValue, Messages messages) 13. throws ValidationException { 14. if (InternalUtils.isBlank(clientValue)) 15. return null; 16. 17. try 18. { 19. return new BigDecimal(clientValue.trim()); 20. } 21. catch (NumberFormatException ex) 22. { 23. throw new ValidationException(messages.format( "number-format-exception", clientValue)); 24. } 25. } 26. 27. public String toClient(BigDecimal value) { 28. return value == null ? "" : value.toString(); 29. } 30. 31. } and in AppModule.java 1. public static void contributeTranslatorDefaultSource( 2. MappedConfiguration<Class, Translator> configuration) 3. { 4. configuration.add(BigDecimal.class, new BigDecimalTranslator()); 5. } 6. 7. public static void contributeTranslatorSource( 8. MappedConfiguration<String, Translator> configuration) 9. { 10. configuration.add("bigdecimal", new BigDecimalTranslator()); 11. } It's a real bug in tapestry ioc 5.0.5. 1. // String to BigDecimal is important, as String->Double->BigDecimal would lose 2. // precision. 3. 4. add(configuration, String.class, BigDecimal.class, new Coercion<String, BigDecimal>() 5. { 6. public BigDecimal coerce(String input) 7. { 8. return new BigDecimal(input); 9. } 10. So I modify code to : 1. // String to BigDecimal is important, as String->Double->BigDecimal would lose 2. // precision. 3. 4. add(configuration, String.class, BigDecimal.class, new Coercion<String, BigDecimal>() 5. { 6. public BigDecimal coerce(String input) 7. { 8. if (input == null || input.trim().length() == 0) 9. return null; 10. return new BigDecimal(input); 11. } 12. }); And the problem has gone. On 8/27/07, Nick Westgate <[EMAIL PROTECTED]> wrote: > > Please show the code for your translator. > > Cheers, > Nick. > > > Denny wrote: > > I have contribute a BigDecimal translator, Yes, I know it's a T5 bug and > it > > would be fix in version 5.0.6. I searched tapestry mailling list, but I > > haven't gotten the answer. Does anybody know how to fix it? do your guys > > don't meet this problem. Or I should modify the T5.0.5' source code? > > > > Thanks. > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Regards Denny Site: http://dengyin2000.javaeye.com