4 Replies Latest reply: May 6, 2010 11:54 PM by chkiron chronos RSS

Problem with Richfaces and h:commandLink (does not have ajax involved)

chkiron chronos Newbie

Hi.


I am developing a small application using Richfaces 3.3.2. I work with Richfaces since 2008 and never saw this problem before.


I have this piece of code:

 

(...)

<rich:dataTable value="#{cadastroOrgaoAfetadoBean.listaOrgaosAfetados}"
                       var="orgao"
                       columnClasses="colunaNome, colunaOperacoes">

(...)

    <rich:column>
        <f:facet name="header">
                <h:outputText value="Operacoes" />
        </f:facet>


        <h:commandLink action="#{cadastroOrgaoAfetadoBean.goEditar}"
                         value="Editar" >
            <f:setPropertyActionListener value="#{orgao}"
                                        target="#{cadastroOrgaoAfetadoBean.orgaoSelecionado}" />
        </h:commandLink>
        <h:outputText value=" | " />
        <h:commandLink action="#{cadastroOrgaoAfetadoBean.doExcluir}"
                         value="Excluir"
                         onclick="if (!window.confirm('A exclusão é definitiva e irreversível. Deseja prosseguir?')) { return false };">
            <f:setPropertyActionListener value="#{orgao}"
                                         target="#{cadastroOrgaoAfetadoBean.orgaoSelecionado}" />
        </h:commandLink>
    </rich:column>

</rich:dataTable>

(...)

 

h:commandLink does not work, it simply provokes a javascript error about a null object. I copied this code from a project of mine in production and merely adapted it, so it was supposed to work, imho.


I read a post (http://community.jboss.org/message/19056#19056) and tried changing from h: to a4j:, but without success, although I did not get a js error again.


However, changing h:commandLink to h:commandButton did the trick and the page worked as designed.


Does anyone please have any clue about this problem? I cannot use only h:commandButtons in my application.


Thanks in advance,


Rodrigo


PS: entire page follows:

 

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!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:ui="http://java.sun.com/jsf/facelets"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:a4j="http://richfaces.org/a4j"
        xmlns:rich="http://richfaces.org/rich">

 

     <body>

 

         <ui:composition template="../layout/template.xhtml">

 

             <ui:define name="head">
                <link     rel="stylesheet"
                        type="text/css"
                        href="../../styles/cadastroOrgaoAfetado/cadastroOrgaoAfetado.css" />
            </ui:define>

 

             <ui:define name="titulo">Cadastro de Órgãos Afetados</ui:define>
            <ui:define name="conteudo">
                <h:form id="mainForm">

 

                     <h:panelGrid columns="1" columnClasses="celulaBotaoNovo" styleClass="panelGridBotaoNovo" >
                        <h:commandButton action="#{cadastroOrgaoAfetadoBean.goNovo}" value="Novo" styleClass="bt"/>

                    </h:panelGrid>

 

                     <rich:panel style="contorno" header="Órgãos Afetados Pelo Lúpus">
                        <rich:dataTable value="#{cadastroOrgaoAfetadoBean.listaOrgaosAfetados}"
                                        var="orgao"
                                        columnClasses="colunaNome, colunaOperacoes">
                            <rich:column>
                                <f:facet name="header">
                                        <h:outputText value="Orgao" />
                                </f:facet>
                                <h:outputText value="#{orgao.nome}" />
                            </rich:column>

 

                             <rich:column>
                                <f:facet name="header">
                                        <h:outputText value="Operacoes" />
                                </f:facet>

 

                                 <h:commandButton action="#{cadastroOrgaoAfetadoBean.goEditar}"
                                                 value="Editar" >
                                    <f:setPropertyActionListener value="#{orgao}"
                                                                  target="#{cadastroOrgaoAfetadoBean.orgaoSelecionado}" />
                                </h:commandButton>
                                <h:outputText value=" | " />
                                <h:commandButton action="#{cadastroOrgaoAfetadoBean.doExcluir}"
                                                 value="Excluir"
                                                 onclick="if (!window.confirm('A exclusão é definitiva e irreversível. Deseja prosseguir?')) { return false };">
                                    <f:setPropertyActionListener value="#{orgao}"
                                                                  target="#{cadastroOrgaoAfetadoBean.orgaoSelecionado}" />
                                </h:commandButton>
                            </rich:column>

 

                        </rich:dataTable>
                    </rich:panel>

 

                 </h:form>

 

             </ui:define>


       </ui:composition>

 

     </body>

 

</html>

 

  • 1. Re: Problem with Richfaces and h:commandLink (does not have ajax involved)
    Ilya Shaikovsky Master

    show please also the code from

     

    ../layout/template.xhtml

  • 2. Re: Problem with Richfaces and h:commandLink (does not have ajax involved)
    chkiron chronos Newbie

    Sure, Ilya, thank you for your time and interest!


    By the way, the h:commandLinks in template are working.


    Thanks!

     

     

    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!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:ui="http://java.sun.com/jsf/facelets"
            xmlns:h="http://java.sun.com/jsf/html"
            xmlns:f="http://java.sun.com/jsf/core"
            xmlns:a4j="http://richfaces.org/a4j"
            xmlns:rich="http://richfaces.org/rich">

     

        <head>
            <title>Sistema de Apoio ao Atendimento ao Associado</title>
            <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
            <ui:insert name="head"></ui:insert>
            <link     rel="stylesheet" type="text/css" href="../../styles/layout/template.css" />
        </head>
        <body bgcolor="#FFFFFF">
            <h:form id="formMenu">
                <table id="Table_01" width="780" border="0" cellpadding="0" cellspacing="0">
                    <!-- topo -->
                    <tr>
                        <td colspan="2">
                            <img id="imgTopo" src="../../img/topo.png" width="780" height="149" alt="" /></td>
                    </tr>
                    <!-- fim topo -->

     

                    <tr>
                        <!-- menu -->
                        <td style="width: 110px; vertical-align: top; padding-left: 10px">
                             <rich:simpleTogglePanel switchType="client" label="Cadastros" width="110px" opened="false" >
                                 <f:facet name="openMarker"><h:outputText value="&#x25BA;" /></f:facet>
                                <f:facet name="closeMarker"><h:outputText value="&#x25BC;" /></f:facet>

     

                                <h:commandLink action="#{cadastroOrgaoAfetadoBean.goListarOrgaoAfetado}" value="Associados" styleClass="zzz" /> <br />
                                <h:commandLink action="#{cadastroDoencaSecundariaBean.goListarDoencaSecundaria}" value="Doenças" styleClass="zzz" /> <br />
                                <h:commandLink action="#{cadastroOrgaoAfetadoBean.goListarOrgaoAfetado}" value="Fornecedores" styleClass="zzz" /> <br />
                                <h:commandLink action="#{cadastroOrgaoAfetadoBean.goListarOrgaoAfetado}" value="Médicos" styleClass="zzz" /> <br />
                                <h:commandLink action="#{cadastroOrgaoAfetadoBean.goListarOrgaoAfetado}" value="Órgãos" styleClass="zzz" /> <br />
                                <h:commandLink action="#{cadastroOrgaoAfetadoBean.goListarOrgaoAfetado}" value="Remédios" styleClass="zzz" /> <br />
                                <h:commandLink action="#{cadastroOrgaoAfetadoBean.goListarOrgaoAfetado}" value="Representantes" styleClass="zzz" /> <br />

     

                             </rich:simpleTogglePanel>

     

                            <rich:simpleTogglePanel switchType="client" label="Doações"  width="110px" opened="false">
                                 <f:facet name="openMarker"><h:outputText value="&#x25BA;" /></f:facet>
                                <f:facet name="closeMarker"><h:outputText value="&#x25BC;" /></f:facet>
                                - Entradas <br />
                                - Saídas <br />
                             </rich:simpleTogglePanel>

     

                             <rich:simpleTogglePanel switchType="client" label="Relatórios"  width="110px" opened="false">
                                 <f:facet name="openMarker"><h:outputText value="&#x25BA;" /></f:facet>
                                <f:facet name="closeMarker"><h:outputText value="&#x25BC;" /></f:facet>
                                - Relatorio 1 <br />
                                - Relatorio 2 <br />
                                - Relatorio 3 <br />
                                - Relatorio 4 <br />
                                - Relatorio 5 <br />
                                - Relatorio 6 <br />
                             </rich:simpleTogglePanel>

     

                             <rich:simpleTogglePanel switchType="client" label="Administração"  width="110px" opened="false">
                                 <f:facet name="openMarker"><h:outputText value="&#x25BA;" /></f:facet>
                                <f:facet name="closeMarker"><h:outputText value="&#x25BC;" /></f:facet>
                                  - usuários <br />
                                - permissões <br />
                                - backup banco <br />
                             </rich:simpleTogglePanel>

     

                             <rich:simpleTogglePanel switchType="client" label="Sair"  width="110px" opened="false">
                                 <f:facet name="openMarker"><h:outputText value="&#x25BA;" /></f:facet>
                                <f:facet name="closeMarker"><h:outputText value="&#x25BC;" /></f:facet>
                                Confirma? <br />
                             </rich:simpleTogglePanel>

     


                        </td>
                        <!-- fim menu -->

     

                        <!-- conteúdo -->
                        <td style="width: 660px;  vertical-align: top; padding-right: 10px; padding-left: 20px;">
                            <table border="0" width="100%" cellpadding="0" cellspacing="0" >
                                <tr style="padding-bottom: 50px">
                                    <td>
                                        <h1><ui:insert name="titulo"></ui:insert></h1>
                                        <rich:messages     id="errorMessages"
                                                        layout="list"
                                                        errorClass="error"
                                                        fatalClass="fatal"
                                                        infoClass="info"
                                                        warnClass="warn">
                                            <f:facet name="errorMarker">
                                                <h:graphicImage url="../../img/erro.gif" />
                                            </f:facet>
                                            <f:facet name="fatalMarker">
                                                <h:graphicImage url="../../img/erro.gif" />
                                            </f:facet>
                                            <f:facet name="infoMarker">
                                                <h:graphicImage url="../../img/sucesso.gif" />
                                            </f:facet>
                                            <f:facet name="warnMarker">
                                                <h:graphicImage url="../../img/aviso.png" />
                                            </f:facet>
                                        </rich:messages>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <ui:insert name="conteudo"></ui:insert>
                                    </td>
                                </tr>
                            </table>
                        </td>
                        <!-- fim conteúdo -->
                    </tr>
                </table>
            </h:form>
        </body>
    </html>

  • 3. Re: Problem with Richfaces and h:commandLink (does not have ajax involved)
    Ilya Shaikovsky Master

    nested forms not allowed in JSF. remove inner and all should works fine.

  • 4. Re: Problem with Richfaces and h:commandLink (does not have ajax involved)
    chkiron chronos Newbie

    Hi, Ilya!

     

    You were right, thank you very much! I did not perceive the nested forms