tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eugeny N Dzhurinsky <eugeny...@jdevelop.com>
Subject Re: passing variable to custom tag
Date Fri, 11 Nov 2005 19:19:00 GMT
On Fri, Nov 11, 2005 at 12:44:18PM -0600, erh@swapsimple.com wrote:
> > But I have problem passing variable from JSTL forEach tag into my tag, it does
> > not passed and throws an exeption. However date attribute in tag definition
> > is defined with 'rtexpval' property. Tag definistion is below:
> rtexprvalue does not have any effect on EL expressions.  It controls
> whether or not you can use a run-time, e.g. "<%= ... %>", expression.

Aha, got you.

> > Could somebody please suggest how should I pass variables from JSTL tags to
> > custom tags libraries?
> Posted a "help me" message without enough detailed information isn't going to
> get you many answers.  For instance, posting the actual exception that you get
> would be helpful.  Showing the entire forEach block wouldn't hurt.  Maybe
> even the container (Tomcat?) and version, as well as what version of the
> servlet spec your webapp uses (2.4? 2.3?)

Actually I'm using Tomcat 5.0 and JSTL 1.1 from Jakarta. The code looks like
this:

<c:forEach var="obj" items="${collection}">
    <my:custom parameter="${obj.creation_date}" />
</c:forEach>

And the exception is JasperException, with message "-348"
I think it's because jasper container tries to cast ${obj} as Date object
(setParameter method in tag takes java.util.Date as parameter)

I think i could rewrite my code in this way:

<c:forEach var="obj" items="${collection}" scope="page">
    <jsp:useBean id="obj" class="myObject"/>
    <my:custom parameter="<%=obj.getCreation_date()%>" />
</c:forEach>

But may be there is some better and elegant solution?

-- 
Eugene N Dzhurinsky

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Mime
View raw message