Sounds great. Nothing stands out to me. Maybe turn on developer mode to see if there's any errors logged when trying to set the value (struts.devMode=true) Is it possible it can't instantiate an AmountDTO object or call the corresponding getter before setting the BigDecimal value?

Also try to set a BigDecimal in your action directly rather than the property of your AmountDTO.

Another solution is to provide an AmountDTO converter rather than a BigDecimal converter..

Ned Collyer wrote:
I've implemented this now... but its not working correctly.  I'm using Struts
2.0.9 (am aware of the new versions).

I have an AmountDTO which has a CurrencyCode (String), and a BigDecimal.

I have created an xwork-conversion.properties in the root of the classpath
which has the following line in it.

java.math.BigDecimal=example.BigDecimalConverter

The converter was not working at all with the
<ActionClass>-conversion.properties.

I lookup the current locale as follows

Locale locale = ActionContext.getContext().getLocale();
NumberFormat format = DecimalFormat.getInstance(locale);

If i turn on Debug, i can step through the convertFromString method, and the
correct value is assigned to the result.  The converter works!!! :) this is
a good thing.

However, after the converter - the AmountDTO.value in the action has null
set against it.  (value is a BigDecimal with appropriate getters and
setters)

What could cause this?  All I have changed is the converter, and its obeying
its contract correctly (and detecting the appropriate class, and returning
an appropriate instance)

Ideas?


Jeromy Evans - Blue Sky Minds wrote:
This should give you an idea. It's modified from existing code so I haven't tested it. I've decided to use a collection of NumberFormat's. You could use any string -> decimal conversion technique you like.

This can be used to an action by created a <actionname>-conversion.properties will in the same directory as the class, with an entry:
<propertyName>=example.DecimalConverter

where <propertyName> is the name of the property name that needs custom conversion and <actionName> is the short class name of your action



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to