Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within JSF
Search Coderanch
Advance search
Google search
Register / Login
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
Forum:
JSF
Do I need a backing bean to get the character length of the contents in a text-area?
Dan Acuff
Ranch Hand
Posts: 62
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Do I need a backing bean to get the length of char's in a text-area?
Will richfaces or
jsf
do it inline for me?
How should I proceed?
<rich:tab id="tshortDescription" label="#{messages.shortDescription}"> <s:decorate id="shortDescriptionDecoration" template="/layout/edit.xhtml"> <ui:define name="label">#{messages.shortDescription}</ui:define> <h:inputTextarea id="shortDescription" cols="80" rows="3" value="#{itemHome.instance.longDescription}"> <a:support id="getCount" event="onkeyup" reRender="count" /> </h:inputTextarea> <h:outputLabel id="count" value="count" for="getCount" /> </s:decorate> </rich:tab>
Dan Acuff
Ranch Hand
Posts: 62
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I ended up doing it with Javascript.
function textCounter(field,cntfield,maxlimit) { if (field.value.length > maxlimit) // if too long...trim it! field.value = field.value.substring(0, maxlimit); // otherwise, update 'characters left' counter else //cntfield.value = maxlimit - field.value.length; cntfield.value = field.value.length; }
<s:decorate id="shortDescriptionDecoration" template="/layout/edit.xhtml"> <ui:define name="label">#{messages.shortDescription}</ui:define> <h:inputTextarea id="shortDescription" name="shortDescription" cols="80" rows="3" value="#{itemHome.instance.longDescription}" onkeydown="textCounter(#{rich:element('shortDescription')},#{rich:element('charCount')},200)" onkeyup="textCounter(#{rich:element('shortDescription')},#{rich:element('charCount')},200)"/> Character Count: <h:inputText readonly="true" id="charCount" value="#{fn:length(itemHome.instance.longDescription)}"/> </s:decorate>
Hope it helps someone in the future.
With a little knowledge, a
cast iron skillet
is non-stick and lasts a lifetime.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
user input with single quotes
jsf decorate
How to dynamically set panel header on a condition using <f:facet
Is jboss seam framework really slow?
SEAM s:decorate template attribute?
More...