On Mon, Jun 22, 2009 at 12:32 PM, Jon Pearson<[email protected]> wrote:
> I could be wrong...
>
> Honestly, you'd be better off adding a function to your action class
> that would format a string to a specific length. It would be clearer
> what was going on. Something like
>
> public String formatString(String s, int maxLen) {
>  return String.format("%." + maxLen + "s", s);
> }
>
> It would also be an easy extension later if you decided that you wanted
> truncated strings to end with elipses:
>
> public String formatString(String s, int maxLen) {
>  if (s.length() < maxLen) {
>    return s;
>  } else {
>    return s.substring(0, maxLen - 3) + "...";
>  }
> }
>
>

No, Jon, you are right... This belongs in the action class. Just
because OGNL lets you cheat doesn't mean you should (cue Dave jumping
in any minute). I think the OP mentioned at one point that adding this
to the action is not an option.

Also, another choice is to use JavaScript. Is the choice to abbreviate
because of bandwidth or screen real estate?

-Wes

-- 
Wes Wannemacher
Author - Struts 2 In Practice
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to