Thx for the tip. It's what occurred to me just a few seconds after pressing the send button... A forum would be nice in these cases, I could edit my posts then.
But the deeper problem is that I have to handle a special case I don't want to care about. Tapestry's easy going spoiled me :) My personal preference would be a pair of short annotations which suppress Tapestry's conversion and use user defined methods in the page or component class. Like: @ToClient(method="toCurrencyDisplay") @ParseClient(method="parseCurrencyDisplay", errorMessage="message: err.convert.rawPrice") @Parameter private BigDecimal rawPrice; @Component private Form currencyForm; private String toCurrencyDisplay(BigDecimal input) { return input.toString() + " $"; } private BigDecimal parseCurrencyDisplay(String input, String errorMessage) { String convert = input.replaceAll("$",""); try { return new BigDecimal(convert); } catch(NumberFormatException ex) { form.recordError(errorMesage + input); return null; //meaning by convention that the property is not changed. } } This would be nice for other, more fancy per-instance-conversions, too but would only pay off compared to getter/setter, if you have more than one or two of the same type in a page/component. A possible usecase are inonvenient pages, where some properties of an object are read only (and should be displayed in the locale specific way) while a couple of others, for example a price-matrix for a certain product related to a customer are mutable and should use dojo's CurrencyTextField. I'm perfectly aware, that this is a usecase which doesn't happen too often normally and can live without a general solution catering to my laziness, but maybe these locale specifc problems when integrating other frameworks, in this case Dojo, should be kept in mind for future reference. Regards, Otho 2009/3/24 Howard Lewis Ship <hls...@gmail.com> > Make the getter and setter convert to/from String instead of double? > That should work. > > On Tue, Mar 24, 2009 at 5:09 AM, Otho <taa...@googlemail.com> wrote: > > Hi all! > > > > I want to use dojo/dijit widgets in an applicatioin. For example the > > currency textbox like this: > > > > Java: > > public getPriceFloat() > > { > > return currentProduct.getPrice().doubleValue(); > > } > > > > Template: > > <t:textfield t:id="price" t:value="priceFloat" > > dojoType="dijit.form.CurrencyTextBox" > > required="true" > > constraints="{fractional:true}" > > currency="EUR"/> > > > > > > Currencytextbox ecpects a standard javascript "float" as value and > > Tapestry's number translator renders it according to my (german) locale > with > > a comma instead of a dot as decimal separator (eg. value="123,45" instead > of > > value="123.45"). > > > > Now I could of course use a special datatype in these cases and provide a > > custom translator, but it would be better to have a more general approach > to > > it, since in this case dojo/dijit would work with the english locale but > not > > with the german one, which is a bit ugly. > > > > One solution could for example be a special annotation like > > @Translate(false) or @NoTranslation or something like that which skips > > locale specific translation, so I can override standard datatypes' > > translation only in the cases I want without having to write > (potentially) a > > bunch of custom translators. > > > > Or did I overlook some simple workaround? > > > > Regards, > > Otho > > > > > > -- > Howard M. Lewis Ship > > Creator Apache Tapestry and Apache HiveMind > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > >