• Post Reply Bookmark Topic Watch Topic
  • New Topic

restricting the length of a display string in a page

 
s mahen perera
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • 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,
<hutputText 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///
 
Leonardo Rafaeli
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Max Moore
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • Quote
  • Report post to moderator
well done!
bye!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!