• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

restricting the length of a display string in a page

 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I am looking for a JSF tag which helps me to display a restricted version (in size) of an original string.
currently i am doing something like,
<h:outputText value="#{bean.stringField}" />

(i am using seam by the way with JSF)

the length of the string is too long. I want to display only part of it,,, then append some dots to the end. I know there are tag libraries which will do the job i want. But just checking whether there is anything in JSF which i can use for this purpose.
Thanks for any help///
 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
have you tried to put size and maxlenght attributes in your inputtext?
 
s mahen perera
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Leonardo,

Thanks for the reply.

My problem is not when entering data. It is when displaying data.

In the database i have a text data item which is very long. In the page I need to display only part of this text, and have some dots at the end to show that the actual text is much longer than the one displayed.

Let me know whether you have any clue for doing this.

Thanks.
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you have two options:

1 - build a "truncate outputtext" component by yourself (there's examples if you google it)

2 - truncate the length of the component in the backing bean directly... I suppose the string value comes from DB and I think you could truncate it before display it on the screen.

The best situation is the first one, but if you don't have enough time to do it... go with the second!
 
s mahen perera
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot Max. Will try this and get back.
 
s mahen perera
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Max. It worked.

Probably i didnt use the most important word (i.e "Truncate"), when doing google searches earlier . Earlier i was always searching by saying something like "restricting text/string size" etc etc. It didnt give me any usefull results. Now, when i just mentioned your magic word (Truncate String) i get a big list of search results .

Hope google will be able to do some fuzzy searches as well in the future
 
Max Moore
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well done!
bye!
 
I've read about this kind of thing at the checkout counter. That's where I met this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic