tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shawn Bayern <bay...@essentially.net>
Subject Re: Typecasting the variable inside a c:foreach-loop
Date Mon, 10 Feb 2003 14:00:26 GMT
On Mon, 10 Feb 2003, Sakke Wiik wrote:

> I have a loop where I need to cast the looped objects if
> they are of a certain type.
> Can someone explain me if it's possible with any standard tags,
> or how I could get hold of the storageObject object through some
> java-code?
> 
> Here's the loop:
> 
> <c:forEach var="anObject" items="${objects}">
>   <c:if test="${anObject.typeB}">
>     Need to cast here <% TypeB typeB = anObject.typeB %>
>   </c:if>
> </c:forEach>

Java code can refer to the scoped attribute as

 pageContext.findAttribute("anObject");

To get "typeB," you'd need to cast anObject to the appropriate type and
then call getTypeB().

-- 
Shawn Bayern
"JSTL in Action"   http://www.manning.com/bayern


---------------------------------------------------------------------
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