Page 1 of 1

jstl convertion

Posted: Tue May 03, 2005 5:00 pm
by hany
I tried to convert these jsp tags to JSTL, but i couldnt, can any body help me with it?

first i declare a String:
String strSelectSectors = null;
.
.
.
then:

for (int i=0; i<dlSectorsInfo.size();i++){
strSectorID = dlSectorsInfo.getKey(i);
strSectorName = dlSectorsInfo.getValue(i);
if(!Validation.isEmpty(strSearchSectorID) && strSearchSectorID.equals(strSectorID)) {
if (!strSectorID.equals("0") || !strSectorName.equalsIgnoreCase("MARKET INDEX")) {
strSelectSectors +="<option value=\""+strSectorID+"\" selected>"+strSectorName+"</option>";
}
}
else {
if (!strSectorID.equals("0") || !strSectorName.equalsIgnoreCase("MARKET INDEX")){
strSelectSectors +="<option value=\""+strSectorID+"\">"+strSectorName+"</option>";
}
}
}
%>

.
.
.
.
then i use it like this

<select name="slcSectorID" id="slcSectorID" class="frmSelect">
<option value="NULL"> All Market </option>
<%=strSelectSectors%>
</select>


Notes: "dlSectorsInfo" is a Map of Hashtable, so im iterating throw it and get key, with that key i get the the Value.

i tried to make it with JSTL, here is what i have done, but its not working:

<select id="slcSectorID" class="frmSelect">
<option value="NULL"> All Market </option>
<c:forEach var="i" begin="0" end="${dlSectorsInfo.size}">
<c:set var="strSectorID" value="${dlSectorsInfo.getKe}"/>
<c:set var="strSectorName" value="${dlSectorsInfo.getValue}"/>
<c:choose>
<c:when test="${!empty strSearchSectorID && strSearchSectorID eq strSectorID}">
<c:if test="${!strSectorID eq '0' || strSectorName ne 'MARKET INDEX'}">
<option value="${strSectorID}" selected>${strSectorName}</option>
</c:if>
</c:when>
<c:otherwise>
<option value="${strSectorID}">${strSectorName}</option>
</c:otherwise>
</c:choose>
</c:forEach>
</select>


please help me with it, Thanks.