I am using the following code to remove the duplicates from a list of email id's while populating the dropdown. If circleList
contains 10 records and has 3 duplicates, then those 3 are replaced with an empty string (i.e., still showing 10 records) but the expected output is a dropdown with 7 records.
<select name="ccOfficialMailId" id="ccOfficialMailId"
style="width: 150px">
<option value="">-- Please select EmailId --</option>
<core:forEach var="item" items="${circleList}" varStatus="status">
<core:set var="emailAlreadyExists" value="${false}" />
<core:if test="${(status.index-1) > 0}">
<core:forEach var="previousEmail" items="${circleList}" begin="0"
end="${status.index-1}" varStatus="inner">
<core:if
test="${item.ccOfficialEmail == previousEmail.ccOfficialEmail}">
<core:set var="emailAlreadyExists" value="${true}" />
</core:if>
</core:forEach>
</core:if>
<core:if test="${not emailAlreadyExists}">
<option value="${item.ccOfficialEmail}">${item.ccOfficialEmail}</option>
</core:if>
</core:forEach>
</select>
How could I achieve this?