Reputation: 946
I increased the max entry size of URLs from a 100 to 300, but now when displayed, they run over the screen. How can i shorten these URLs to end with three dots if they cant fit on the page.
<c:forEach items="${targets}" var="target">
<tr>
<th></th>
<td class="data">
<c:if test="${not empty target.valueString}">
<a href="<c:out value="${target.valueString}"/>" target="_blank"><c:out value="${target.valueString}"/></a>
<spring:message code="entry.confirmDelTarget" var="confirmDelete" />
<a href="#" onClick="if(confirm('${confirmDelete}')) document.entryForm.actionBtn.value='delTarget';document.entryForm.targetId.value='${target.id}';document.entryForm.submit();">
<img src="/theme/images/gfx/ico_delete2.gif"/>
</a>
</c:if>
</td>
</tr>
</c:forEach>
Upvotes: 0
Views: 557
Reputation: 691933
with
<c:out value="${target.valueStringTruncated}"/>
and
public String getValueStringTruncated() {
if (valueString.length() > 100) {
return valueString.substring(0, 97) + "...";
}
}
Or you could extract this code to a JSP tag or an EL function:
<c:out value="${myFn:truncate(target.valueString)}"/>
Upvotes: 1