• 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

Limit characters returned in H:Outputtext?

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there anyway to limit the number of characters returned in an <h:OUTPUTTEXT/> ? The value attribute I mean...




Or will I need to call a method behind to do the work?

If I build a method.. how will this string of code at least look differently?

Will I use an actionlistener?
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The API for outputtext makes no mention of a parameter such as 'maxLength'.

I would have a method on a backing bean which in turn gets the string you want displayed and truncates it.

Maybe something like:



With a method on your backing bean like:



Where 10 is your desired number of characters to display in the outputtext
 
Dan Acuff
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Rory. That gives me a good start.
Getting it to work in a full blown seam environment is another story ...

Do I have to tie it into the interface in any way?

I am getting an error:
value="#{_item.truncateBenefitsString}": Property 'truncateBenefitsString' not found on type com.thissource.webstore.entity.Item

Or do I need to set Setters and Getters?

Thank you from,
Total Java Newb!
 
Rory Evans
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try renaming the truncateBeansString() method to getTruncateBeanString()
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic