jstl convertion

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
hany
Posts: 1

jstl convertion

Tue May 03, 2005 5:00 pm

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[i]}"/>
<c:set var="strSectorName" value="${dlSectorsInfo.getValue[i]}"/>
<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.

Return to “Common Problems”

Who is online

Users browsing this forum: No registered users and 0 guests