tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rahul P Akolkar <akol...@us.ibm.com>
Subject Re: Odd behavior of Number/String conversion??
Date Mon, 07 Mar 2005 23:51:09 GMT
> trying to convert String "field." to type "java.lang.Double"<snip>
> I even tried using the fn:trim tag which is supposed to return a String

In short, the spec says so :-) 

Remember, + is not string concatenation in JSPs, it is an arthmetic 
operator. The rogue argument here is not the index (so trimming the index 
won't help), its the String "field.", and the dot triggers the String to 
Double coercion (again, as per the spec).

> there must be a way to display this in one expression?

<c:set var='theField' value="${metaProps[fn:replace('field.*.type', '*', 
fieldNum)]}"/>

Conceptually, a fn:join is a better fit here, but I'm not too keen on 
creating arrays in JSPs ;-) Finally, if temporary variables is what you're 
after, 'theField' would be the next in line, although readability has its 
own benefits.

-Rahul

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message