2 Replies Latest reply on Jul 9, 2007 3:18 AM by s sfd

    Using a4j:support event=

    s sfd Newbie

      The following code is used to show how many characters have been put into the textarea id: smsTextField:
      <h:outputText id="charsLeft" value="#{backingbean.charCount} characters used" />


      <h:inputTextarea id="smsTextField" value="#{SmsSendView.smsText}"
      cols="20" rows="5">
      <a4j:support event="onkeyup" reRender="charsLeft" ajaxSingle="true" ignoreDupResponses="true"/>
      </h:inputTextarea>

      The backing bean has an int value that uses a String.length() function to get how many characters have been put in.

      I am experiencing very slow response times when using this. Is this a plausible way to use a4j or should I definatly go for including my own javascript for this?

      I would rather not include a javascript because I think that clutters up my code.. Are there any ways to improve performance on the feedback here?

        • 1. Re: Using a4j:support event=
          Sergey Smirnov Master

          ignoreDupResponses does not make sense without queue defined (attribute eventsQueue). Also, there is no reason to send so many events to the server when user types. So, having requestDelay (300-800ms) is a right way to go.

          ajaxSingle="true" helps you do not send more data to server, however, the whole component tree still will be processed. You can avoid this using a4j:region just around the h:inputTextarea.

          Those help you to increase the performance. However, you are absolutely right thinking about pure javascript. Updating counter is just a one line of javascript code. The updating itself does not require to invoke a server-side specific application or business logic. So, using Ajax here is an overhead.



          • 2. Re: Using a4j:support event=
            s sfd Newbie

            Thx for a quick and informative reply!