tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Du <d...@cdsc.com.cn>
Subject Re: How to break a loop in JSTL c:foreach
Date Thu, 26 Sep 2002 06:28:52 GMT
I think breaking a loop is a general and useful feature for better 
performance.


Here is a case:

Assuming a multiple select control in a form, and a java variable 
id2textMap keeps all the items showed in the select control, each entry 
in the map is responding to an item in the control and "id" is the value 
and "text" is the text. A variable selIDs keeps all selected items. Now 
the jstl codes to generate the select control is as follows:

<select name="selIDs" size="5" multiple>
<c:foreach var="entry" items="id2textMap">
   <option value="<c:out value="${entry.key}"/>"
     <c:foreach var="selID" items="selIDs">
       <c:if test={selID==entry.key}>
         selected
         <%-- I WANT TO BREAK THE LOOP HERE -->
       </c:if>
     </c:foreach>
   >
   <c:out value="${entry.value}"/>
   </option>
</c:foreach>
</select>


In our project, we have a page that contains more than 50 select 
controls like that and the performance to display that page with JSTL is 
not good.


Regards,

Eric Du



Shawn Bayern wrote:
 >>Would it be possible to have an loop tag which iterates based on a
 >>boolean condition?

 > A <c:while>?  Yes, additions like this are always possible in future
 > versions if there's enough perceived need.
 >
 > I'd suggest mailing jsr-52-comments@jcp.org with the suggestion.  Be sure
 > to indicate the situations where this would be useful to you, with as
 > specific examples as possible.
 >
 > Best,
 >


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


Mime
View raw message