I have added an abbreviate() method to our base action class.
/**
* Abbreviate a string using ellipses (...).<br>
* If text is longer then len it is truncated to len characters then the
* last 3 characters are replaced with ellipses (...).
*
* @param text the string to abbreviate
* @param len the maximum length of the returned string (must be greater
* then 3)
* @return the string abbreviated with ellipses to a maximum length of
* <code>len</code>
*/
public String abbreviate(String text, int len)
{
return org.apache.commons.lang.StringUtils.abbreviate(text, len);
}
Then in the JSP I can use it like this <s:property
value="abbreviate(name,25)" />