Uploaded image for project: 'RichFaces'
  1. RichFaces
  2. RF-12084

Richfaces 4.2 <a4j:ajax> when inside <ui:fragment> dont work and causes 'identifier resolved to null'

    Details

    • Steps to Reproduce:
      Hide

      3 files: test.xhtml, testFrag.xhtml, test.java

      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>
      

      test.java

      
      package foo
      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();
          }
      }
      

      Generated html:

      <html xmlns="http://www.w3.org/1999/xhtml"><head>
      	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><link type="text/css" rel="stylesheet" href="/Copaiba/rfRes/skinning.ecss.xhtml?db=eAG7mShzEgAFjAIg"><script type="text/javascript" src="/Copaiba/javax.faces.resource/jsf.js.xhtml?ln=javax.faces&amp;stage=Development"></script><script type="text/javascript" src="/Copaiba/javax.faces.resource/jquery.js.xhtml"></script><script type="text/javascript" src="/Copaiba/javax.faces.resource/richfaces.js.xhtml"></script><script type="text/javascript" src="/Copaiba/javax.faces.resource/richfaces-queue.js.xhtml"></script></head>
      <body><form id="j_idt5" name="j_idt5" method="post" action="/Copaiba/test.xhtml" enctype="application/x-www-form-urlencoded">
      <input name="j_idt5" value="j_idt5" type="hidden">
      <input id="j_idt5:checkId" name="j_idt5:checkId" onclick='RichFaces.ajax(this,event,{"parameters":{"javax.faces.behavior.event":"click","org.richfaces.ajax.component":"j_idt5:checkId"} ,"sourceId":this} )' type="checkbox"><label for="j_idt5:checkId">
      Check me</label><span id="j_idt5:panelId">
      				<div>
      
      
      			<table>
      				<tbody><tr>
      					<td><a href="#" id="j_idt5:j_idt14" name="j_idt5:j_idt14" onclick='RichFaces.ajax("j_idt5:j_idt14",event,{"incId":"1"} );return false;'>Click RichFaces</a>
      					</td>
      				</tr>
      				<tr>
      					<td><a name="j_idt5:j_idt16" id="j_idt5:j_idt16" href="#" onclick="mojarra.ab(this,event,'action',0,'j_idt5:inputId');return false">Click Mojarra + Mojarra Ajax</a>
      					</td>
      				</tr>
      				<tr>
      					<td><a name="j_idt5:j_idt18" id="j_idt5:j_idt18" href="#" onclick='RichFaces.ajax(this,event,{"parameters":{"javax.faces.behavior.event":"action","org.richfaces.ajax.component":"j_idt5:j_idt18"} ,"sourceId":this} );return false'>Click Mojarra + RichFaces Ajax</a>
      					</td>
      				</tr>
      
      				<tr>
      					<td><input id="j_idt5:inputId" name="j_idt5:inputId" value="" type="text">
      					</td>
      				</tr>			
      
      			</tbody></table>
      
      				</div></span><input name="javax.faces.ViewState" id="javax.faces.ViewState" value="-6272535757919067026:415855145225480971" autocomplete="off" type="hidden">
      </form>
      </body></html>
      
      Show
      3 files: test.xhtml, testFrag.xhtml, test.java 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> test.java package foo 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(); } } Generated html: <html xmlns= "http: //www.w3.org/1999/xhtml" ><head> <meta http-equiv= "Content-Type" content= "text/html; charset=UTF-8" ><link type= "text/css" rel= "stylesheet" href= "/Copaiba/rfRes/skinning.ecss.xhtml?db=eAG7mShzEgAFjAIg" ><script type= "text/javascript" src= "/Copaiba/javax.faces.resource/jsf.js.xhtml?ln=javax.faces&amp;stage=Development" ></script><script type= "text/javascript" src= "/Copaiba/javax.faces.resource/jquery.js.xhtml" ></script><script type= "text/javascript" src= "/Copaiba/javax.faces.resource/richfaces.js.xhtml" ></script><script type= "text/javascript" src= "/Copaiba/javax.faces.resource/richfaces-queue.js.xhtml" ></script></head> <body><form id= "j_idt5" name= "j_idt5" method= "post" action= "/Copaiba/test.xhtml" enctype= "application/x-www-form-urlencoded" > <input name= "j_idt5" value= "j_idt5" type= "hidden" > <input id= "j_idt5:checkId" name= "j_idt5:checkId" onclick= 'RichFaces.ajax( this ,event,{ "parameters" :{ "javax.faces.behavior.event" : "click" , "org.richfaces.ajax.component" : "j_idt5:checkId" } , "sourceId" : this } )' type= "checkbox" ><label for = "j_idt5:checkId" > Check me</label><span id= "j_idt5:panelId" > <div> <table> <tbody><tr> <td><a href= "#" id= "j_idt5:j_idt14" name= "j_idt5:j_idt14" onclick= 'RichFaces.ajax( "j_idt5:j_idt14" ,event,{ "incId" : "1" } ); return false ;' >Click RichFaces</a> </td> </tr> <tr> <td><a name= "j_idt5:j_idt16" id= "j_idt5:j_idt16" href= "#" onclick= "mojarra.ab( this ,event, 'action' ,0, 'j_idt5:inputId' ); return false " >Click Mojarra + Mojarra Ajax</a> </td> </tr> <tr> <td><a name= "j_idt5:j_idt18" id= "j_idt5:j_idt18" href= "#" onclick= 'RichFaces.ajax( this ,event,{ "parameters" :{ "javax.faces.behavior.event" : "action" , "org.richfaces.ajax.component" : "j_idt5:j_idt18" } , "sourceId" : this } ); return false ' >Click Mojarra + RichFaces Ajax</a> </td> </tr> <tr> <td><input id= "j_idt5:inputId" name= "j_idt5:inputId" value= "" type=" text"> </td> </tr> </tbody></table> </div></span><input name= "javax.faces.ViewState" id= "javax.faces.ViewState" value= "-6272535757919067026:415855145225480971" autocomplete= "off" type= "hidden" > </form> </body></html>
    • Workaround:
      Workaround Exists
    • Workaround Description:
      Hide

      The workaround is use <f:ajax> and <h:commandLink> instead of <a4j:ajax> or <a4j:commandLink>

      Show
      The workaround is use <f:ajax> and <h:commandLink> instead of <a4j:ajax> or <a4j:commandLink>

      Description

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

      The problem is described here
      https://community.jboss.org/message/723859

      and here:
      https://community.jboss.org/thread/196867

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                tritibo Luca Nardelli
                Reporter:
                ivancosta Ivan Costa
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: