6 Replies Latest reply on Jun 11, 2013 6:02 PM by Brian Leathem

    a4j:commandLink not working

    Fernando Martins Newbie

      I have richfaces version 4.3.2 running in JBOSS 7.1.1

       

      a4j:commandButton does work

       

      But I can't make a4j:commandLink to work

       

      the IE browser indicates a page error

       

      jsf:ajax is null or is not an object

       


      my files :

       

      WEB.XML

      ------------------------------------

      <?xml version="1.0" encoding="ISO-8859-1"?>

      <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"

          xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee

          http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">

          <description>iDigital.pedPagamento</description>

       

          <context-param> 

                  <param-name>org.richfaces.skin</param-name> 

                  <param-value>wine</param-value> 

           </context-param> 

             

          <context-param>

              <description>Nome da aplicacao</description>

              <param-name>NOME</param-name>

              <param-value>iDigital.pedPagamento</param-value>

          </context-param>

          <context-param>

              <description>Versao da aplicacao que se encontra no ambiente</description>

              <param-name>VERSAO</param-name>

              <param-value>@VERSAO@</param-value>

          </context-param>

          <context-param>

              <description>Prefixo do ambiente em que a  aplicacao esta a correr</description>

              <param-name>PREFIXO_AMBIENTE</param-name>

              <param-value>@PREFIXO_AMBIENTE@</param-value>

          </context-param>

          <context-param>

              <description>Email de suporte da aplicacao</description>

              <param-name>EMAIL_SUPORTE</param-name>

              <param-value>desenv-icand@ifap.pt</param-value>

          </context-param>

          <context-param>

              <description>URL do Report Servlet</description>

              <param-name>REPORT_SERVLET_URL</param-name>

              <param-value>http://dsv.aplj.ifap.local/iDigital.controloAnexos/ReportServlet</param-value>

          </context-param>

          <context-param>

              <description>SID da Base de dados em que a aplica??o est? a correr</description>

              <param-name>SID_BASE_DADOS</param-name>

              <param-value>BDOIDIG</param-value>

          </context-param>

       

          <filter>

              <filter-name>LoginFilter</filter-name>

              <filter-class>pt.ifap.infra.web.filters.LoginFilter</filter-class>

          </filter>

          <filter-mapping>

              <filter-name>LoginFilter</filter-name>

              <url-pattern>*.jsp</url-pattern>

          </filter-mapping>

          <servlet>

              <servlet-name>Faces Servlet</servlet-name>

              <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>

              <load-on-startup>1</load-on-startup>

          </servlet>

          <servlet-mapping>

              <servlet-name>Faces Servlet</servlet-name>

              <url-pattern>/faces/*</url-pattern>

          </servlet-mapping>

          <session-config>

              <session-timeout>15</session-timeout>

          </session-config>

          <mime-mapping>

              <extension>html</extension>

              <mime-type>text/html</mime-type>

          </mime-mapping>

          <mime-mapping>

              <extension>txt</extension>

              <mime-type>text/plain</mime-type>

          </mime-mapping>

          <error-page>

              <exception-type>java.lang.Throwable</exception-type>

              <location>/faces/pages/error.xhtml</location>

          </error-page>

          <listener>

              <listener-class>pt.ifap.infra.web.listeners.SessionListener</listener-class>

          </listener>

         

          <jsp-config/>

      </web-app>

       

       

      FACES-CONFIG

      -------------------------------

       

      <?xml version="1.0" encoding="windows-1252"?>

      <faces-config

          xmlns="http://java.sun.com/xml/ns/javaee"

          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

          xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_1.xsd"

          version="2.0">

        <application>

          <locale-config>

            <default-locale>pt</default-locale>

            <supported-locale>en</supported-locale>

          </locale-config>

          <message-bundle>Messages</message-bundle>

         </application>

       

       

      <managed-bean>

          <managed-bean-name>form_pedPagamentoSeleccao</managed-bean-name>

          <managed-bean-class>pt.ifap.pedPagamento.backing.Seleccao</managed-bean-class>

          <managed-bean-scope>session</managed-bean-scope>

        </managed-bean>

       

      </faces-config>

       

       

      BEAN

      -------------------------

       

       

      @ViewScoped

      public class Seleccao extends CRUDBackingBean {

       

      public String consultarBen_action() throws ErroNegocio {

       

         //something

      }

       

      }

       

       

      TEMPLATE PAGE

      ----------------------------

       

      <?xml version="1.0" encoding="windows-1252"?>

      <!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:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"

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

            xmlns:rich="http://richfaces.org/rich" xmlns:t="http://myfaces.apache.org/tomahawk">

          <f:loadBundle basename="mensagens" var="msgs"/>

          <f:loadBundle basename="imagens" var="imgs"/>

          <h:head>

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

              <meta http-equiv="Expires" content="0"/>

              <meta http-equiv="Cache-Control" content="no-cache, must-revalidate"/>

              <meta http-equiv="Pragma" content="no-cache"/>

              <meta name="viewport" content="width=device-width, initial-scale=1.0"/>

              <meta name="description" content="Men? do iDigital"/>

              <meta name="author" content="IFAP"/>

              <link rel="icon" href="/idigital.weblib/resources/idigital/2.0/ico/favicon-16x16.png" sizes="16x16"/>

              <link rel="icon" href="/idigital.weblib/resources/idigital/2.0/ico/favicon-32x32.png" sizes="32x32"/>

              <link rel="icon" href="/idigital.weblib/resources/idigital/2.0/ico/favicon-64x64.png" sizes="64x64"/>

              <link rel="shortcut icon" href="/idigital.weblib/resources/idigital/2.0/favicon.ico" type="image/x-icon"/>

              <link rel="apple-touch-icon" href="/idigital.weblib/resources/idigital/2.0/ico/apple-touch-icon-57x57.png"/>

              <link rel="apple-touch-icon" sizes="72x72"

                    href="/idigital.weblib/resources/idigital/2.0/ico/apple-touch-icon-72x72.png"/>

              <link rel="apple-touch-icon" sizes="114x114"

                    href="/idigital.weblib/resources/idigital/2.0/ico/apple-touch-icon-114x114.png"/>

              <link rel="apple-touch-icon" sizes="144x144"

                    href="/idigital.weblib/resources/idigital/2.0/ico/apple-touch-icon-144x144.png"/>

              <title>

                  <h:outputText value="#{initParam.NOME}"/>

              </title>

              <link rel="stylesheet" href="/idigital.weblib/resources/idigital/1.0/css/reset.css" type="text/css"/>

              <link rel="stylesheet" href="${pageContext.request.contextPath}/css/tiles.css" type="text/css"></link>

              <link rel="stylesheet" href="/idigital.weblib/resources/idigital/1.0/css/default.css" type="text/css"/>

          </h:head>

          <h:body>

             <h:form id="form">

              <a4j:status onstart="block();" onstop="unblock();"/>

                  <t:div styleClass="principal">

                      <t:div styleClass="header">

                          <ui:include src="/pages/cabecalho.xhtml"/>

                      </t:div>

                      <t:div styleClass="mensagens">

                          <ui:include src="/pages/cabecalhomensagens.xhtml"/>

                      </t:div>

                      <t:div styleClass="body">

                                <ui:insert name="corpo"/>

                       </t:div>

                  </t:div>

              </h:form>

          </h:body>

      </html>

       

       

       

      CLIENT PAGE that uses the template

       

      ---------------------------------------------------------

       

      <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"

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

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

                      xmlns:t="http://myfaces.apache.org/tomahawk" template="/pages/modelo.xhtml">

          <ui:define name="corpo">

              <a4j:outputPanel id="panCriterios">

                  <rich:panel>

                 

                          <t:panelGrid columns="4" align="center" styleClass="form-layout" cellspacing="5">

                              <p class="center">

                                  <h:outputLabel value="NIFAP" styleClass="first"/>

                                  

                                  <h:inputText required="true" disabled="#{form_pedPagamentoSeleccao.userMutuario}"

                                               value="#{form_pedPagamentoSeleccao.nifap}" id="nifap" size="9" maxlength="9">

                                      <t:validateRegExpr pattern="[0-9]*"/>

                                  </h:inputText>

                                  

                                  <a4j:commandButton value="Consultar" styleClass="operacao" id="consultarBen"

                                                     disabled="#{form_pedPagamentoSeleccao.userMutuario || !form_pedPagamentoSeleccao.contextoAplicacional.acesso.consultar}"

                                                     action="#{form_pedPagamentoSeleccao.consultarBen_action()}"

                                                     render="operacoes pedidos"/>

                                           

                                  <br/>

                                  

                                  <a4j:outputPanel ajaxRendered="true">

                                      <h:messages/>

                                     

                                      <h:message for="consultarBen" infoClass="infoMessage" warnClass="warnMessage"

                                                 errorClass="errorMessage" fatalClass="fatalMessage"/>

                                      <h:message for="nifap" infoClass="infoMessage" warnClass="warnMessage"

                                                 errorClass="errorMessage" fatalClass="fatalMessage"/>

                                  </a4j:outputPanel>

                              </p>

                          </t:panelGrid>

                     </rich:panel>

              </a4j:outputPanel>

              <a4j:outputPanel id="operacoes" rendered="#{form_pedPagamentoSeleccao.dataTableOperacoes.rowCount > 0}">

                  <rich:panel header="Projetos">

                          <p class="legend">

                              <h:outputText value="#{msgs.label_ope}"/>

                          </p>

                          <rich:dataTable value="#{form_pedPagamentoSeleccao.dataTableOperacoes}" var="item" id="table"

                                          rows="20" rowClasses="odd-row, even-row" styleClass="data">

                              <rich:column>

                                  <f:facet name="header">

                                      <h:outputText value="#{msgs.can_pedido_pagto_operacao}"/>

                                  </f:facet>

                                 <a4j:commandLink id="cmdlnkPedidosDetalhe"

                                                   action="#{form_pedPagamentoSeleccao.pedidosDetalhe()}"

                                                   render="pedidos" value="#{item.numero}"/>

                              </rich:column>

                              <rich:column>

                                  <f:facet name="header">

                                      <h:outputText value="Reanalise"/>

                                  </f:facet>

                                  <h:outputText value="#{item.reanalise}" styleClass="first"/>

                              </rich:column>

                              <rich:column>

                                  <f:facet name="header">

                                      <h:outputText value="#{msgs.can_pedido_pagamento_seleccao_programa_medida}"/>

                                  </f:facet>

                                  <h:outputText value="#{item.programaMedida}" styleClass="first"/>

                              </rich:column>

                              <rich:column filter="#{carsFilteringBean.mileageFilterImpl}">

                                  <f:facet name="header">

                                      <h:outputText value="#{msgs.can_pedido_pagto_tipologia}"/>

                                  </f:facet>

                                  <h:outputText value="#{item.tipologiaComponente}" styleClass="first"/>

                              </rich:column>

                              <rich:column>

                                  <f:facet name="header">

                                      <h:outputText value="#{msgs.data_inicio}"/>

                                  </f:facet>

                                  <h:outputText value="#{item.dataIni}" styleClass="first"/>

                              </rich:column>

                              <rich:column>

                                  <f:facet name="header">

                                      <h:outputText value="#{msgs.data_fim}"/>

                                  </f:facet>

                                  <h:outputText value="#{item.dataFim}" styleClass="first"/>

                              </rich:column>

                              <rich:column>

                                  <f:facet name="header">

                                      <h:outputText value="#{msgs.can_pedido_pagamento_seleccao_situcao_projecto}"/>

                                  </f:facet>

                                  <h:outputText value="#{item.estado}" styleClass="first"/>

                              </rich:column>

                              <rich:column>

                                  <f:facet name="header">

                                      <h:outputText value="#{msgs.can_pedido_pagamento_seleccao_observacoes}"/>

                                  </f:facet>

                                  <h:outputText style="#{item.fundo_branco}" value="#{item.observacoes}" styleClass="first"/>

                              </rich:column>

                              <rich:column>

                                  <f:facet name="header">

                                      <h:outputText value=""/>

                                  </f:facet>

                                  <t:commandButton action="#{form_pedPagamentoSeleccao.criarPedidoPagamento}"

                                                   disabled="#{!form_pedPagamentoSeleccao.podeCriarPP}" value="#{msgs.criar}"></t:commandButton>

                                  <t:commandButton action="#{form_pedPagamentoSeleccao.recuperaPedidoPagamento}"

                                                   onclick="if (!confirm(\\'#{msgs.cmd_substituicao_rea}\\')) return false;"

                                                   rendered="#{item.mostrarBotaoRea}" value="#{msgs.can_rea_recuperar}"></t:commandButton>

                              </rich:column>

                          </rich:dataTable>

                     </rich:panel>

              </a4j:outputPanel>

             <a4j:outputPanel rendered="#{form_pedPagamentoSeleccao.dataTablePedidos.rowCount > 0}" id="pedidos"></a4j:outputPanel>

          </ui:define>

      </ui:composition>

       

       

      what I'm making wrong ?!

        • 1. Re: a4j:commandLink not working
          Brian Leathem Master

          Inspect your WAR, make sure you don't have multiple versions of RichFaces in there, and make sure you aren't bundling a JSF impl (it's provided by the app server).

          • 2. Re: a4j:commandLink not working
            Fernando Martins Newbie

            thanks,

             

            but it seems ok

             

            why  a4j:commandButton works ??? even rich components like the panel and dataTable works

             

            is strange

             

            a4j:commandLink just doesn't execute

            • 3. Re: a4j:commandLink not working
              Brian Leathem Master

              a4j:commandButton and a4j:commandLink use much of the same underlying code, so it is indeed surprising that one works, and another doesn't.

               

              Does it work in browsers other than IE?  Are there any additional details provided in the browser error console?  Can you use the developer tools to see if an ajax communication with the server is initiated when you click the link is clicked?  Are there any server-side errors?

              • 4. Re: a4j:commandLink not working
                Fernando Martins Newbie

                Tried in Google Chrome with the same results, but something is wrong

                 

                I use JDeveloper to compile the project

                 

                I notice this warning :

                 

                WARNING: JMS API was found on the classpath; if you want to enable RichFaces Push JMS integration, set context-param 'org.richfaces.push.jms.enabled' in web.xml

                 

                what is that ?

                 

                the browser error console gives this error when I click on a4jcommandLink  :

                 

                 

                Message: 'jsf.ajax' is null or is not an object

                Line: 580

                Caráct: 9

                Code: 0

                URL: http://localhost:8080/iDigital.pedPagamento/faces/javax.faces.resource/richfaces.js

                 

                google chrome console gives this

                 

                 

                Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:8080/css/tiles.css

                 

                2Uncaught TypeError: Cannot call method 'request' of undefined richfaces.js:580

                2

                1. Uncaught TypeError: Cannot call method 'request' of undefined richfaces.js:580

                 


                 

                My WAR includes Richfiles libraries, but also I mention that in file jboss-deployment-structure

                 

                 

                <?xml version="1.0" encoding="UTF-8"?>

                <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">

                    <ear-subdeployments-isolated>false</ear-subdeployments-isolated>

                      <sub-deployment name="@WAR_FILE_NAME@">

                        <exclusions>

                            <module name="org.apache.log4j" slot="main"/>

                        </exclusions>

                        <dependencies>

                            <module name="pt.ifap.iDigitalWeb"/>

                        </dependencies>

                        <resources>

                            <resource-root path="lib/@JAR_FILE_NAME@"/>

                        </resources>

                    </sub-deployment>

                </jboss-deployment-structure>

                 

                 

                iDigitalWeb is a module in JBOSS :

                 

                 

                <module xmlns="urn:jboss:module:1.1" name="pt.ifap.iDigitalWeb">

                    <properties>

                        <property name="jboss.api" value="private"/>

                    </properties>

                   

                    <dependencies>

                         <module name="javax.faces.api"/>

                        <module name="javax.el.api"/>

                        <module name="javax.servlet.api"/>

                        <module name="javax.servlet.jsp.api"/>

                        <module name="javaee.api"/>

                        <module name="org.apache.commons.logging"/>

                        <module name="org.apache.commons.beanutils"/>

                        <module name="org.apache.commons.collections"/>

                        <module name="org.apache.commons.lang"/>

                        <module name="com.sun.jsf-impl"/>

                          

                        <module name="org.w3c.css.sac"/>

                        <module name="net.sourceforge.cssparser"/>

                        <module name="com.google.guava"/>

                      

                    </dependencies>  

                   

                    <resources>   

                    <resource-root path="commons-digester-1.8.1.jar"/>

                    <resource-root path="commons-digester-1.6.jar"/>   

                    <resource-root path="commons-fileupload-1.2.1.jar"/>

                    <resource-root path="commons-validator-1.3.0.jar"/>

                    <resource-root path="j4j.jar"/>   

                    <resource-root path="jakarta-oro-2.0.8.jar"/>       

                    <resource-root path="richfaces-core-impl-4.3.2.Final.jar"/>

                    <resource-root path="richfaces-components-ui-4.3.2.Final.jar"/>

                    <resource-root path="richfaces-core-api-4.3.2.Final.jar"/>

                    <resource-root path="richfaces-components-api-4.3.2.Final.jar"/>

                 

                    <resource-root path="tomahawk20-1.1.14.jar"/>

                 

                   

                    </resources> 

                 

                 

                </module>

                • 5. Re: a4j:commandLink not working
                  Fernando Martins Newbie

                  google console gives more info about richfaces.js

                   

                   

                   

                          // propagates some options to process it in jsf.ajax.request

                          parameters.rfExt = {};

                          parameters.rfExt.status = options.status;

                          for (var eventName in AJAX_EVENTS) {

                              parameters.rfExt[eventName] = options[eventName];

                          }

                   

                          jsf.ajax.request(source, event, parameters);

                  Uncaught TypeError: Cannot call method 'request' of undefined (repeated 3 times)

                   

                      };

                   

                      if (window.jsf) {

                  • 6. Re: a4j:commandLink not working
                    Brian Leathem Master

                    Running RichFaces from a JBoss EAP/Wildfly module is not yet supported.  See:

                    https://issues.jboss.org/browse/RF-12008