7 Replies Latest reply on Aug 1, 2007 1:17 PM by Curtis Crabb

    aj4:support for onkeyup taking 3 keystrokes before properly

    Curtis Crabb Newbie

      I am having difficulties getting a pretty simple page working consistently...

      <%@ page contentType="text/html"%>
      <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
      <%@ taglib uri="https://ajax4jsf.dev.java.net/ajax" prefix="a4j"%>


      <f:view>
      <h:form>
      <h:inputText value="#{testBacking.text}">
      <a4j:support event="onkeyup" reRender="test"/>
      </h:inputText>
      <h:outputText id="test" value="#{testBacking.text}"/>
      </h:form>
      </f:view>




      public class TestBacking
      {
      private String text;

      public String getText()
      {
      return text;
      }

      public void setText(String text)
      {
      this.text = text;
      }
      }

      The page should simply mirror what gets typed into the inputText to the outputText. But it does not work for the first two key strokes...

      The first couple key strokes do not get reflected in the outputText, but starting with the 3rd character, all will work. For the first two keystrokes, I do see all phases occur on the webserver...

      1.) the first key stroke actually results in a call to TestBacking.setText, but I do not see the new value reflected in the browser (on the outputText).
      2.) the second key stroke never even calls TestBacking.setText
      3.) the third key stroke and all remaining key strokes work like a charm until I re-enter the entire page; then I am back to the first two key strokes not working.

      Any ideas for what the issue might be? As an fyi, I am using Java 1.4 and Weblogic 8.1.

      Thanks for any help

        • 1. Re: aj4:support for onkeyup taking 3 keystrokes before prope
          Alexander Jiteg Newbie

          Try to use an ajax form <a4j:form> instead of the standard jsf-form. Not sure but that might just do the trick.

          • 2. Re: aj4:support for onkeyup taking 3 keystrokes before prope
            Curtis Crabb Newbie

            Thanks for the response, but using <a4j:form> doesn't behave any differently. Looks like I am going to have to debug with the source code... bummer, but i guess that will definitely help me learn Ajax4JSF

            • 3. Re: aj4:support for onkeyup taking 3 keystrokes before prope
              Alexander Jiteg Newbie

              Actually, I think that this can be a bug in the components. Try to search the forum for similar cases.

              As I recall it, it can have something to do with your combination of ajax and jsf versions..

              • 4. Re: aj4:support for onkeyup taking 3 keystrokes before prope
                Vince Hilton Newbie

                Check to make sure that you are using a supported JSF runtime. I had this exact problem using IBM's runtime, and the problem disappeared when I switched to MyFaces.

                • 5. Re: aj4:support for onkeyup taking 3 keystrokes before prope
                  Curtis Crabb Newbie

                  I am using Sun JSF 1.1 which is supported by Ajax4jsf. I plan on looking further into this soon, but currently have at least a temporary work around.

                  While debugging this issue in the Ajax4jsf code, I saw that Ajax4jsf was using a different id and component instance (HTMLForm) during the same request for what should be the same form. I haven't looked at this for a number of days so I don't remember the details... I will look more carefully at this when I have the time and can provide a better description of exactly what is happening.

                  Anyway, my current workaround is to specify an id on each of the jsf components in my page (on the h:form and on the h:input) rather than allowing jsf to pick the ids; this makes things work consistently.

                  • 6. Re: aj4:support for onkeyup taking 3 keystrokes before prope
                    Vince Hilton Newbie

                    << my current workaround is to specify an id on each of the jsf components in my page >>

                    That seems like an easy enough fix...

                    You're right about JSF RI 1.1 being supported, but I think A4J has some lifecycle problems with it. I found that both the jsf-ibm.jar (IBM's RI 1.1-based implementation) and the vanilla RI 1.1 in Java 1.4 exhibited the same weird behavior you're seeing. So, I went to MyFaces core 1.1.5--NOT an RI distribution with extensions, but an entirely different JSR 127 AND JSR 252 (JSF 1.2) supporting framework.

                    I would bet that by default WebLogic's JSF runtime uses an RI 1.1 distribution with BEA proprietary extensions, like what IBM does.

                    Maybe this is too broad a solution for you, but you could probably try using RI 1.2 or another framework that implements the JSF 1.2 spec. I chose MyFaces 1.1.5 because it was built primarily for Java 1.4, not Java 5 like most of the other JSF 1.2 implementations.

                    In my case the behavior I saw was an <a4j:support> tag on an <h:selectOneMenu> that would fire ajax requests correctly every time, but only after the second AJAX request (from the third request on) would I get the correct AJAX responses from the faces lifecycle. Seems to be the same problem you're having...

                    • 7. Re: aj4:support for onkeyup taking 3 keystrokes before prope
                      Curtis Crabb Newbie

                      Thanks for your thoughts. Yesterday, I went ahead and changed from using the Sun implementation to use MyFaces 1.1.5. As soon as I do that, my problems disappear; I no longer need an id specified on my components and a couple other oddities I was noticing (but didn't mention on the foum) disappeared as well.

                      We have been thinking of moving over to a MyFaces implementation anyway so this encourages it further.

                      Thanks again!