Problem with Richfaces and h:commandLink (does not have ajax involved)
chkiron May 4, 2010 9:21 PMHi.
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>