0 Replies Latest reply on Jan 11, 2011 7:06 PM by senthilnz

    a4j:ajax problem with Injected CDI bean

    senthilnz

      Hi,

       

      In the recent days, I was always facing issue with ajax display with richfaces 4. Today, I tried with testing of a showcase example from richfaces-M4 named as ajax-simple.xhtml.

      If the Bean is declared with annotation @ManagedBean(name="user") then the a4j:ajax works. But, if I declare the bean with javax.inject.Named annotation(instead of ManagedBean) then the a4j:ajax request is not triggering at all.

       

      Can someone explain me whether the CDI injected will work with a4j:ajax or not?

       

      Regards,

      Senthil

       

      My class declaration and xhtml file,

       

      import javax.faces.bean.RequestScoped;

      import javax.inject.Inject;

      import javax.inject.Named;

       

       

      @Named("user")

      @RequestScoped

      public class UserDisplay {

       

          public UserDisplay() {

              super();

          }

       

      private String name = "";

       

          public String getName() {

              return name;

          }

       

          public void setName(String name) {

              this.name = name;

          }

       

      }

       

       

      xhtml file as,

       

      <ui:composition xmlns="http://www.w3.org/1999/xhtml"

                      xmlns:ui="http://java.sun.com/jsf/facelets"

                      xmlns:a4j="http://richfaces.org/a4j"

                      xmlns:rich="http://richfaces.org/rich"

                      xmlns:h="http://java.sun.com/jsf/html"

                      xmlns:f="http://java.sun.com/jsf/core">

      <html>

            <h:head>

       

                  <title>RichFaces Greeter</title>

       

            </h:head>

            <h:body>

                  <f:view>

                        <h:form>

                              <h:inputText value="#{user.name}">

                              <a4j:ajax event="keyup" render="out" />

                          </h:inputText>

                  <h:outputText value="#{user.name}" id="out" />

                        </h:form>

                  </f:view>

            </h:body>

      </html>

      </ui:composition>