0 Replies Latest reply on May 23, 2008 2:17 AM by zzzz8

    Rerender causes loss in cursor position with onkeyup

    zzzz8 Newbie

      I'm trying to create a twitter-like username checking feature, e.g.:


      For example, I want to check for the availability of a username as the user types some letters. The database should be checked for the availability of a username as each character that is typed in (i.e. onkeyup). I want to check the availability of the username via the database using a validator that I have written (in this case, it's a SLSB w/ Seam annotations - and yes, it does work). Here's my Facelets code so far:

       <s:decorate id="usernameDecoration" template="layout/edit.xhtml">
       <ui:define name="label">
       <h:outputText value="#{messages['username']}" />
       <h:inputText id="username" disabled="#{customerHome.managed}" required="true" size="32" maxlength="32" value="#{customerHome.instance.username}">
       <f:validator validatorId="availableUsernameValidator" />
       <a:support event="onkeyup" reRender="usernameDecoration" bypassUpdates="true" ajaxSingle="true" />

      This works, up to a point. When the user types in his username character by character, the validator does kick in and checks the availability of the username. However, every time the user types in a character, the cursor position is lost - and thus the user needs to reposition the cursor to the last character in the username string every single time. What am I doing wrong? Thanks!