This content has been marked as final.
Show 2 replies
-
1. Re: How to truncate a string
malex Jan 20, 2009 12:00 AM (in response to fvalente)1)
Checkout the Apache Commons Lang (StringUtils.abbreviate(java.lang.String str, int maxWidth)) or write yourself the method.2)
In order to directly access your method in the frontend (facelets), you can create an EL Function. The referece demonstrates, how you can very easily include the static methods in an ELFunctions library (automatic dynamic registration). -
2. Re: How to truncate a string
www.supernovasoftware.com Jan 20, 2009 12:36 AM (in response to fvalente)The java method would be trivial.
I would use a combination of rich:toolTip and only render it if the text is abbreviated.
This way the user could mouse over and see the full text.
Combining a Seam component and Facelets template should work well.
Or use Richfaces CDK.
It would be nice to have
<custom:abbreviateText value="my text" length="10" />