2 Replies Latest reply on Aug 11, 2012 4:07 PM by Brendan Healey

    Richfaces 4.2 <a4j:ajax> when inside <ui:include> causes 'identifier resolved to null'

    Ivan Costa Newbie

      Hi, this question came out from this problem of mine: https://community.jboss.org/message/723859

       

      a4j:commandLink or a4j:ajax tags causes 'identifier resolved to null', but h:commandLink + f:ajax (both from Mojarra) works perfectly fine!

       

      Code for testing:

       

       

      test.xhtml

       

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

      <html

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

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

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

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

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

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

          >

      <h:head>

          <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

         

      </h:head>

       

      <f:view>

          <h:form>

              <h:selectBooleanCheckbox id="checkId" value="#{testBean.checkBox}" >

                  <a4j:ajax event="click" execute="@this" listener="#{testBean.checkBoxListener}" render="panelId">

                  </a4j:ajax>

                 </h:selectBooleanCheckbox>

              <h:outputLabel for="checkId">Check me</h:outputLabel>

             

              <a4j:outputPanel id="panelId" >

                  <h:panelGroup rendered="#{testBean.ruleRender}" >

                      <div>

                          <ui:include src="/template/testFrag.xhtml" >

                              <ui:param name="beanName" value="#{testBean}" />

                          </ui:include>

                      </div>

                  </h:panelGroup>

              </a4j:outputPanel>

          </h:form>

      </f:view>

      </html>

       

      /template/testFrag.xhtml

       

       

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

      <html

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

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

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

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

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

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

          >

       

          <ui:fragment>

                   <table>

                      <tr>

                          <td>

                              <a4j:commandLink value="Click RichFaces" actionListener="#{beanName['fragmentMethodListener']}" render="inputId">

                              </a4j:commandLink>

                          </td>

                      </tr>

                      <tr>

                          <td>

                              <h:commandLink value="Click Mojarra + Mojarra Ajax">

                                  <f:ajax listener="#{beanName['fragmentMethodListener']}" render="inputId">

                                  </f:ajax>

                              </h:commandLink>

                          </td>

                      </tr>

                      <tr>

                          <td>

                              <h:commandLink value="Click Mojarra + RichFaces Ajax">

                                  <a4j:ajax listener="#{beanName['fragmentMethodListener']}" render="inputId">

                                  </a4j:ajax>

                              </h:commandLink>

                          </td>

                      </tr>

                       <tr>

                          <td>

                              <h:inputText id="inputId" value="#{beanName['input']}"></h:inputText>

                          </td>

                      </tr>           

                   </table>

          </ui:fragment>

      </html>

       

       

      Managed Bean:

       

       

      import java.io.Serializable;

       

      import javax.annotation.PostConstruct;

      import javax.faces.bean.ManagedBean;

      import javax.faces.bean.ViewScoped;

       

      @ManagedBean(name="testBean")

      @ViewScoped

      public class TestBean implements Serializable {

       

          private Boolean checkBox;

          private String input;

       

          public Boolean getCheckBox() {

              return checkBox;

          }

          public void setCheckBox(Boolean checkBox) {

              this.checkBox = checkBox;

          }

          public String getInput() {

              return input;

          }

          public void setInput(String input) {

              this.input = input;

          }

          public void checkBoxListener() {

              System.out.println("Changed to:" + checkBox);

          }

       

          @PostConstruct

          private void init() {

              checkBox = false;

              input = "";

          }

         

          public boolean isRuleRender() {

              return checkBox;

          }

         

          public void fragmentMethodListener() {

              input = input + ""+input.length();

          }

      }

       

       

      Environment:

      Mojarra 2.1.7

      Richfaces 4.2 Final

      Tomcat 7.0.26

       

       

      Complete stacktrace:

       

      INFO: BEFORE INVOKE_APPLICATION 5

      14/03/2012 19:59:55 javax.faces.event.MethodExpressionActionListener processAction

      GRAVE: 'javax.el.PropertyNotFoundException' recebido ao invocar escuta de ação '#{beanName['fragmentMethodListener']}' para o componente 'j_idt14'

      14/03/2012 19:59:55 javax.faces.event.MethodExpressionActionListener processAction

      GRAVE: javax.el.PropertyNotFoundException: Target Unreachable, identifier 'beanName' resolved to null

          at org.apache.el.parser.AstValue.getTarget(AstValue.java:98)

          at org.apache.el.parser.AstValue.invoke(AstValue.java:244)

          at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)

          at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:153)

          at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)

          at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:769)

          at javax.faces.component.UICommand.broadcast(UICommand.java:300)

          at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)

          at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)

          at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)

          at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)

          at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)

          at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)

          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)

          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)

          at foo.login.AuthorizationFilter.doFilter(AuthorizationFilter.java:57)

          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)

          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)

          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)

          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)

          at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)

          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)

          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)

          at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)

          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)

          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)

          at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)

          at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)

          at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)

          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

          at java.lang.Thread.run(Thread.java:662)

       

      14/03/2012 19:59:55 foo.util.PhaseTracker afterPhase

      INFO: AFTER INVOKE_APPLICATION 5

      14/03/2012 19:59:55 com.sun.faces.context.AjaxExceptionHandlerImpl log

      GRAVE: JSF1073: javax.faces.event.AbortProcessingException obtido durante o processamento de INVOKE_APPLICATION 5: UIComponent-ClientId=j_idt5:j_idt14, Message=Target Unreachable, identifier 'beanName' resolved to null

      14/03/2012 19:59:55 com.sun.faces.context.AjaxExceptionHandlerImpl log

      GRAVE: Target Unreachable, identifier 'beanName' resolved to null

      javax.faces.event.AbortProcessingException: Target Unreachable, identifier 'beanName' resolved to null

          at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:182)

          at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)

          at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:769)

          at javax.faces.component.UICommand.broadcast(UICommand.java:300)

          at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)

          at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)

          at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)

          at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)

          at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)

          at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)

          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)

          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)

          at foo.login.AuthorizationFilter.doFilter(AuthorizationFilter.java:57)

          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)

          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)

          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)

          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)

          at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)

          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)

          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)

          at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)

          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)

          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)

          at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)

          at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)

          at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)

          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

          at java.lang.Thread.run(Thread.java:662)

      Caused by: javax.el.PropertyNotFoundException: Target Unreachable, identifier 'beanName' resolved to null

          at org.apache.el.parser.AstValue.getTarget(AstValue.java:98)

          at org.apache.el.parser.AstValue.invoke(AstValue.java:244)

          at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)

          at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:153)

          ... 28 more

      14/03/2012 19:59:55 foo.util.PhaseTracker beforePhase

      INFO: BEFORE RENDER_RESPONSE 6

      14/03/2012 19:59:55 foo.util.PhaseTracker afterPhase

      INFO: AFTER RENDER_RESPONSE 6