tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hans Bergsten <h...@gefionsoftware.com>
Subject Re: Tags with primitive variables.
Date Wed, 08 Dec 1999 06:24:36 GMT
Glenn Atter wrote:
> 
> Hi Folks,
> 
> I have been using the taglibrary functionality of Jakarta for about 1 month.
> I have developed quite a few tags (~10). One of these tags is a for loop
> tag, i.e.
> 
> <for id="i" start="1" end="20">
>         Item number <%=i%>
> </for>
> 
> Currently the variable nested inside the for tag is an java.lang.Integer
> Object. This is fine for general usage as show above but if I wanted to use
> the variable in an equation I have to remember to use the intValue() method,
> i.e.
> 
> <for id="i" start="1" end="20">
>         Item number <%=i.intValue() * 100%>
> </for>
> 
> As our customers will be using these tags I can see this becoming very
> complicated for them. However, this would not be a problem if we could
> return primitive types from the tags, in this case an int. I have looked
> into the problem and implementing this would mean a change to the
> TagGeneratorBase.declareVariables() method.
> 
> If the className is a primitive type, i.e. int, double, float etc. then it
> should output something like the following
> 
> int i = ((Integer) pageContext.getAttribute("i")).intValue();
> 
> or
> 
> double d = ((Double) pageContext.getAttribute("d")).doubleValue();
> 
> I know that this requires that the object used in the setAttribute call
> within the Tag to be the appropriate java.lang object for the primitive data
> type.
> 
> I also appreciate that this change would probably go against the current JSP
> specification but it would greatly simplify the usage of these types of
> tags.
> 
> If anyone has a workaround that does not require any changes to Jakarta I
> would really like to hear from you. Otherwise, am I expecting too much for
> this type of change to be made to Jakarta.

I have recently seen the same need, but I'm afraid this requires a change
in the JSP spec and therefore it can't be implemented in Tomcat until then 
(since Tomcat is the reference implementation). 

Eduardo or Anil, comments?

hans
-- 
Hans Bergsten		hans@gefionsoftware.com
Gefion Software		http://www.gefionsoftware.com

Mime
View raw message