Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7547623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:30:01+00:00 2026-05-30T09:30:01+00:00

can I get the value of a inputTextare on the fly without backing bean?

  • 0

can I get the value of a inputTextare on the fly without backing bean?

<p:dialog>
<p:inputTextarea rows="5" cols="30" value="#{_var.note}" />
<h:outputText id="remaining" value="#{util.getCharactersRemaining("varibale of textarea", 160)} characters left" />



public class UtilFacade {
    public int getCharactersRemaining(String value, int maxLength) {
        log.info("length: " + value.length());
        return (maxLength - value.length());
    }
}

In order to display the remaining chars in the dialog, I have to feed the method with current value in Textarea without saving the value to a backing bean!
How can i get this value?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T09:30:02+00:00Added an answer on May 30, 2026 at 9:30 am

    You can do this with a JavaScript method (no need to go to server). Here is a sample:

    <script type="text/javascript">
        function getRemainingChars(textArea, maxLength) {
            var actualText = textArea.value;
            if (actualText.length > maxLength) {
                textArea.value = actualText.substring(0, maxLength);
            }
            var remainingChars = (maxLength > actualText.length) ? maxLength - actualText.length : 0;
            document.getElementById("frmMyPage:txtRemainingChars").value = remainingChars;
        }
    </script>
    <h:form id="frmMyPage">
    <h:inputTextArea id="txtTextArea" cols="50" rows="10" onkeyup="getRemainingChars(this, 500);" />
    <br />
    <h:outputText id="txtRemainingChars" />
    </h:form>
    

    You can get more details about keydown, keypress and keyup javascript functions here (in this case I preffer to validate the text on the keyup event). Also you can modify the JavaScript function and send the id of your component instead of sending the whole component (this will make the JS available for inputText component and similars).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know how I can get the value of an input box, without
Is there anyway I can get the value of a text field without posting
In Python I can use get method to get value from an dictionary without
I have dropdown menu..which is dynamic.. How can get value of the last item
Can I get the value of an object field some other way than obj.field
How can I get the value between quotes with an RegEx for example I
How can I get the value (string) of the current selection in a combobox?
How can I get DateTime value in C# from row, the current code is
How can I get a value from a preprocess function to template.php, in a
How can I get the value of the URL hash (eg PARAMETERS in url

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.