The JSP spec is quite clear on the subject:
"The only types of properties that can be assigned to from String
constants and request parameter values are those listed in TABLE 2-4; the conversion
applied
is that shown in the table. Request-time expressions can be assigned to properties of
any
type; no automatic conversions will be performed."
boolean or Boolean As indicated in java.lang.Boolean.valueOf(String)
byte or Byte As indicated in java.lang.Byte.valueOf(String)
char or Character As indicated in java.lang.Character.valueOf(String)1
double or Double As indicated in java.lang.Double.valueOf(String)
int or Integer As indicated in java.lang.Integer.valueOf(String)
float or Float As indicated in java.lang.Float.valueOf(String)
long or Long As indicated in java.lang.Long.valueOf(String)
[Please note that short/Short is missing from the list].
We had a discussion on the topic sometimes this summer (if you look at
the archives). Also seems to me that this would make sense.
Let me try to ping the spec lead on this to see if we could get
final resolution.
-- Pierre
Serge Knystautas wrote:
>
> ----- Original Message -----
> From: "Craig R. McClanahan" <[EMAIL PROTECTED]>
> > Well, it appears that we successfully licked a large number of the
> problems with
> > 3.2-beta-8, without introducing any serious new regressions. Therefore,
> I'd
> > like to ask that we vote on the following three propositions:
> >
> > (1) Build and release Tomcat 3.2 final on Wednesday 11/29/2000
>
> I'd like to request that a minor patch be applied to Tomcat 3.2 so that it
> can fully support tags with object properties. The patch to
> org.apache.jasper.compiler.TagBeginGenerator on 7/12/2000 on the tomcat_32
> branch disabled this capability (yes, I should have caught this sooner but
> didn't start using the 3.2 branch until about a month ago). This was done
> in preparation for the JSP 1.2 spec, and while I think this is a good
> direction, nobody got the chance to finish it.
>
> To summarize the behavior, if you have a tag with an object property and in
> your TLD rtexprvalue is set to true, you cannot pass it a static string. In
> Tomcat 3.1 and Tomcat 3.2 prior to 7/12/2000, the setter method for the
> Object property would be called passing the static String value. In JSP 1.2
> (so I would assume Tomcat 4.0 and Tomcat 3.X once JSP 1.2 support is added),
> the specification is more complete and specifies the use of
> BeanInfo/PropertyEditor and the setAsText method, and once this is
> implemented, we can have tags with object properties. However as of right
> now, Tomcat 3.2 does not support passing static Strings to Object properties
> on tags.
>
> In the interest of not delaying Tomcat 3.2's release, I would suggest the
> diff included below be applied and included into Tomcat 3.2. It passes the
> static String to the Object property using the setter method. While this
> means tag writers could develop tags that would not comply with the JSP 1.2
> spec, I believe this is acceptable as 1) there is clear direction as to how
> to make their tags JSP 1.2 compliant and 2) Tomcat 3.2 is not a JSP 1.2
> environment. The disadvantage to not doing this is that tags writers have
> no way to support receiving static Strings to their tags' Object properties.
> Instead page writers would have to use the workaround Craig (I believe)
> suggested in every JSP (attr='<%="value"%>').
>
> Thanks for hearing me out. I know I can just apply my own patch and build
> my own instance of Tomcat 3.2, but this seems like an important part of the
> spec to consider, especially as custom tags are gradually becoming a more
> important component of JSPs.
>
> Serge Knystautas
> Loki Technologies
> http://www.lokitech.com/
>
> cvs diff TagBeginGenerator.java (in directory
> C:\DEV\cvs-apache\jakarta-tomcat\src\share\org\apache\jasper\compiler\)
> Index: TagBeginGenerator.java
> ===================================================================
> RCS file:
> /home/cvspublic/jakarta-tomcat/src/share/org/apache/jasper/compiler/TagBegin
> Generator.java,v
> retrieving revision 1.14.2.2
> diff -r1.14.2.2 TagBeginGenerator.java
> 223a224,225
> > } else if (c == Object.class) {
> > return writer.quoteString(s);
>
> *****CVS exited normally with code 1*****