tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Luca Passani <>
Subject looping on a list of lists (or accessing custom attributes of a list)
Date Sat, 03 Jun 2006 09:01:48 GMT

Hi guys, here is my big problem today.

I have a list the items of two kinds (with and without icons) which gets 
turned into a list of lists.

 [x , x, y, x,y, y, y, y,x, x,y] becomes  [[x,x],[y],[x],[y,y,y,y],[x],[y]]

When I render the list of lists in my JSP, I need to understand which 
kind of list it is I am dealing with.
That's when I had a brilliant idea. I defined to subclasses of ArrayList:

public class LinkWithIconList extends ArrayList {

    public boolean isLinkWithIconList() {
    return true;
    public boolean isLinkWithoutIconList() {
    return false;

(you can probably guess what the other class looks like :). And each 
sublist is an object of the respective subclasses.
The rationale was to be able to do something like:

<c:forEach var="sub_list" items="${list_of_lists}">
     <c:when test="${sub_list.linkWithIconList}">
    render list with icons
     <c:when test="${sub_list.linkWithoutIconList}">
    render list without icons

Unfortunately this doesn't work. ${sub_list.linkWithIconList} is 
interpreted as an attempt to access to an item of the collection (and 
not one of its properties):

javax.servlet.ServletException: The "." operator was supplied with 
an index value of type "java.lang.String" to be 
applied to a List or array, but that value cannot be converted to an integer.

So,  the question for this respactable forum is:
- is there an easy way to achieve what I am trying to achieve?
- are there other ways to achieve my goals?



To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message