Christopher Schultz wrote:
> Dimitris,
>
> Dimitris Mouchritsas wrote:
> > <fmt:formatNumber type = "currency" groupingUsed = "true" >
> >   ${ table_data.package_price +
> >   ( road_assistance_2year == '-' ? 0.0 : road_assistance_2year ) +
> >   ( comp_offer_data.hasInsurance ? table_data.insuranceValue : 0.0 ) }
> > </fmt:formatNumber>
>
> > and in Tomcat 6.0.13 it works fine. However in Tomcat 5.0.19 the page
> > stops processing and and exception is thrown.
>
> Perhaps the compiler bundled with TC 6 is more forgiving.
>
> > Tomcat complains that he cannot convert String '-' to a
> > java.lang.Double.
>
> I assume that table_data.package_price is a double (or Double). You are
> adding the result of the ternary operator. The second parameter to the
> ternary operator is a double value (0.0). The third one is a String.
> Just wrap road_assistance_2year like this:
>
> ${ table_data.package_price +
>  ( road_assistance_2year == '-' ? 0.0 :
> Double.doubleValue(road_assistance_2year) ) + ...
>
> If you are using localized double values, you'll obviously have to use
> another conversion mechanism -- or perhaps you prefer to use something
> from your webapp framework of whatever. The point is the same: you can't
> add a String to a double. You need compatible data types, so just convert.
>
> -chris

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Well shouldn't the result of the ternary operator depend on the test? If
road_assistance_2year is not '-' then it's a double.
It works in Tomcat 6.0.13. Anyway I've solved the problem by adding a
boolean variable to check for road assistance
and now road_assistance_2year is always a double (either 0.0 or the price).
But thanks for the casting, I didn't know I could do that in EL.



Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to