2 Replies Latest reply on Aug 3, 2015 6:46 PM by teylen

    a4j:ajax gets ignored in combination with a composite component?

    teylen

      Hello all!

       

      I've got a problem with a4j:ajax in combination with a composite component. The a4j:ajax gets ignored when I add it via clientBehavior to a composite component, while f:ajax works just fine.

      I'm using RichFaces 4.5.7 with MyFaces 2.2.8 and required libs for both.

       

      The following code examples are simplified to describe the problem.

       

      I've created a custom component as myInput.xhtml:

      <ui:composition xmlns:cc="http://xmlns.jcp.org/jsf/composite" xmlns:h="http://java.sun.com/jsf/html">

          <cc:interface>

              <cc:attribute name="value" />

              <cc:clientBehavior name="keyup" event="keyup" targets="my" />

          </cc:interface>

          <cc:implementation>

              <h:inputText id="my" value="#{cc.attrs.value}" />

          </cc:implementation>

      </ui:composition>

       

       

      When I use it in combination with f:ajax like this (inside a h:form of course):

      <x:myInput id="anId" value="#{SomeBean.someProperty}">

          <f:ajax event="keyup" />

      </x:myInput>

       

      ...it generates code like this:

      <input type="text" onkeyup="jsf.ajax.request('myForm:anId:my',event,{'javax.faces.behavior.event':'keyup'})" value="" name="myForm:anId:my" id="myForm:anId:my">

       

      ...which is what I expected.

       

       

      When I use it with a4j:ajax instead:

      <x:myInput id="anId" value="#{SomeBean.someProperty}">

          <a4j:ajax event="keyup" />

      </x:myInput>

       

      ... it only generates this:

      <input type="text" value="" name="myForm:anId:my" id="myForm:anId:my">

       

      ...which is not what I hoped for.

       

       

      So the a4j:ajax is ignored for the composite component while f:ajax works. If I add some more clientBehavior and combine a4j:ajax and f:ajax inside the usage of the composite component, it still only generates the code for f:ajax. If I drop the whole composite component stuff and put a4j:ajax in a h:inputText, the code for the a4j:ajax gets generated normally on the page. So the problem is really in the combination of composite component and a4j:ajax. And since the f:ajax gets rendered just fine, I suspect it's a RichFaces-problem and not something related to MyFaces. Well, either that or I'm doing something wrong. I usually tend to user-error, but I've got no ideas left how to make it work. I'll probably go for a workaround and use f:ajax for now, but I'm interested if anybody has an idea if it's my fault, a bug or normal behavior?

      If this problem was already discussed elsewhere - sorry, I searched the internet/forum for a few hours, but only found a few things that looked related, but weren't.

       

      Thanks for reading.