Thanks guys for your reponses, but I think I may have been unclear in
my question.  I have a class called MyCurrencyConverter that converts
a string to a BigDecimal by stripping the "$", commas, etc. - this
works fine.  The problem arises when struts does not call
MyCurrencyConverter for the nested class "Contact -> ContactLead"
("Contact" class has a member variable "ContactLead" class all with
getters/setters).

For the code below, the first field converts just fine and I can track
this in my debugger.  But for the second field, MyCurrencyConverter is
never called by Struts.  I am wondering if this is a bug.  I would
have thought Struts would be smart enough to map the nested
ContactLead class to the conversion.properties file.

JSP snippet:
<!-- First Field: Works fine, MyCurrencyConverter is called -->
<s:textfield key="contactLead.income"
value="%{getText('format.money',{contactLead.income != null ?
contactLead.income :''})}"  />
<!-- Second Field: MyCurrencyConveter is never called for this textfield -->
<s:textfield key="contact.contactLead.income"
value="%{getText('format.money',{contact.contactLead.income != null ?
contact.contactLead.income :''})}"  />

ContactCreateAction-conversion.properties:
contactLead.income=com.afs.web.converter.MyCurrencyConverter
contact.contactLead.income=com.afs.web.converter.MyCurrencyConverter

Thanks,
Burton

On Mon, Dec 13, 2010 at 1:09 AM, Lukasz Lenart
<lukasz.len...@googlemail.com> wrote:
> 2010/12/12 Burton Rhodes <burtonrho...@gmail.com>:
>> I know. I don't have a setIncome(String) method. But I do have
>> setIncome(BigDecimal) method , hence the type conversion. Normally the
>> class MyCurrencyCoverter will covert the String to BigDecimal, but
>> it's never called. I am wondering what I am doing wrong that the
>> conversion class is not called.
>
> String to BigDecimal conversion is built-in functionality and looks
> like your user is entering $ at the beginning of the field Income
> that's why Sturts falling with conversion.
>
> The current converter treats an input string as whole, there is no
> parsing to extract numbers, you write your own and assign it to all
> BigDecimal types
> http://struts.apache.org/2.x/docs/type-conversion.html#TypeConversion-ApplyingaTypeConverterforanapplication
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
> Kapituła Javarsovia 2010 http://javarsovia.pl
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>

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

Reply via email to