1 Reply Latest reply on Mar 27, 2007 5:47 PM by sergeysmirnov

    <h:inputText> loses focus when used with <a4j:support> insid

    legga

      The following code displays a table with two columns - h:inputText and its length. The length is recalculated on the server as user types:

      <rich:dataTable id="dt1" value="#{RichBean.data}" rows="20" var="dto">
       <h:column>
       <f:facet name="header">
       <h:outputText value="Name" />
       </f:facet>
       <h:inputText id="name" value="#{dto.name}">
       <a4j:support reRender="length" event="onkeyup">
       <a4j:ajaxListener type="org.ajax4jsf.ajax.ForceRender" />
       </a4j:support>
       </h:inputText>
       </h:column>
       <h:column>
       <f:facet name="header">
       <rich:spacer/>
       </f:facet>
       <h:outputText id="length" value="#{dto.length}"/>
       </h:column>
      </rich:dataTable>


      the DTO's getLength() method just returns name.length().

      Once user starts typing, the length column gets recalculated, but right after that input field loses focus. This makes typing almost impossible - user has to get focus back to the field after typing every 3-5 letters.

      I tested with h:dataTable, rich:dataTable and tomahawk's t:dataTable in both FF and IE - same problem.
      The version I used is RichFaces 3.0.0 with Ajax4jsf 1.1.0.
      JSF implementation - Myfaces 1.1.1

      This problem doesn't occur if inputField is used outside the table though.

      P.S. Guys, is this the right place to post bugs or shall I do it directly in Jira?

      P.P.S Just tested with snapshot version RF 3.0.1 + A4J 1.1.1 and it seems to be fixed in there. Unfortunately, I can't use it until bug RF-37 is fixed...


        • 1. Re: <h:inputText> loses focus when used with <a4j:support> i

          I have increased the priority of RF-37 up to Critical.

          This kind of behavior is usual for situation when the input field is located inside the re-rendered zone. It happens because the DOM node is replaced (removed and added) and browser just loses the node where the focus was in.

          If dataTable has no ajaxKeys defined OR ForceRender listener defined, the whole table with be re-rendered. This causes the focus losing .

          However, in your case, you have a listener. So, it was a bug.