| Author |
Limit characters returned in H:Outputtext?
|
Dan Acuff
Ranch Hand
Joined: Jul 13, 2009
Posts: 62
|
|
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?
|
 |
Rory Evans
Greenhorn
Joined: Feb 19, 2010
Posts: 18
|
|
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
Joined: Jul 13, 2009
Posts: 62
|
|
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
Joined: Feb 19, 2010
Posts: 18
|
|
|
Try renaming the truncateBeansString() method to getTruncateBeanString()
|
 |
 |
|
|
subject: Limit characters returned in H:Outputtext?
|
|
|