Really easy with your help!!! Thanks a lot Laurie!
From: Laurie Harper <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <user@struts.apache.org>
To: user@struts.apache.org
Subject: Re: Show info from collection by levels and check data type
Date: Sat, 31 Mar 2007 16:22:29 -0400
Francisco Exposito Aguilera wrote:
Sorry, I forgot to translate some info....
Hi all,
In the jsp page I sent a collection which contains integer and
string values:
[1, "A", 2, "B", 2, "C", 1, "D", 2 , "E", 3, "F", 3, "G"]
In the page I want to obtain the data (strings of the collection) in
the correct level (integers of the collection)
A
B
C
D
E
F
G
In the jsp I have:
<logic:iterate name="structureAssy" id="structure">
//If the value of the collection is an integer ????
<c:set var="numberOfBlanks" value="${structure}"/>
//End if
//If the value of the collection is a string ????
<tr>
<td>
<c:forEach begin="1" end="${numberOfBlanks}">
 
</c:forEach>
<c:out value="${structure}"/>
</td>
</tr>
//End if
</logic:iterate>
¿Is this idea correct? If yes, how can I know if the actual value of
the collection is an integer or a string? If my idea is not correct,
could you guide me???
Thanks a lot
Regards,
Paco
From: "Francisco Exposito Aguilera" <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <user@struts.apache.org>
To: user@struts.apache.org
Subject: Show info from collection by levels and check data type
Date: Sat, 31 Mar 2007 10:32:27 +0000
Hi all,
In the jsp page I sent a collection which contains integer and string
values:
[1, "A", 2, "B", 2, "C", 1, "D", 2 , "E", 3, "F", 3, "G"]
In the page I want to obtain the data (strings of the collection) in the
correct level (integers of the collection)
A
B
C
D
E
F
G
In the jsp I have:
<logic:iterate name="estructuraAsociacion" id="estructura">
//Si el valor de la collection es un integer ????
<c:set var="espacios" value="${estructura}"/>
//Fin si el valor de la collection es un integer ????
//Si el valor de la collection es un string ????
<tr>
<td>
<c:forEach begin="1" end="${espacios}">
 
</c:forEach>
<c:out value="${estructura}"/>
</td>
</tr>
//Fin si el valor de la collection es un string ????
</logic:iterate>
¿Is this idea correct? If yes, how can I know if the actual value of the
collection is an integer or a string? If my idea is not correct, could
you guide me???
I don't think there's any standard 'is integer' test you can apply, and
there's no way to make an s:iterator of c:forEach consume two elements from
the collection at a time anyway. Given the data structure you're working
with, something like this might work:
<c:forEach var="data" varStatus="status" items="estructuraAsociacion">
<c:choose>
<c:when test="${status.index % 2 == 0}">
<c:set var="indent" value="${data}"/>
</c:when>
<c:otherwise>
<tr><td>... (generate your output)
</c:otherwise>
</c:choose>
</c:forEach>
It would probably simplify things, though, if you made your data structure
a list of tuples:
[[1, "A"], [2, "B"], [2, "C"], ...
which would simplify the logic within your main iteration.
HTH,
L.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
_________________________________________________________________
Descubre la descarga digital con MSN Music. Más de un millón de canciones.
http://music.msn.es/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]