I have this HTML:
<ui:composition template="/templates/layout.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:jsf="http://xmlns.jcp.org/jsf"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:p="http://xmlns.jcp.org/jsf/passthrough">
<ui:define name="titulo">Cadastro</ui:define>
<ui:define name="conteudo">
<div>
<h:selectOneMenu id="setores" value="#{pagCadastro.setor}" valueChangeListener="#{pagCadastro.aoMudarSetor}">
<f:selectItems value="#{pagCadastro.setores}" />
</h:selectOneMenu>
<fieldset jsf:rendered="#{pagCadastro.setor.id >= 1}">
<legend>E-mails dos Grupos</legend>
<h:commandLink id="novo" value="Novo" title="Inclui um novo e-mail de grupo" rendered="#{pagCadastro.estado == 'CONSULTA'}" action="#{pagCadastro.novo}" />
<h:dataTable id="emailsGruposSetor" value="#{pagCadastro.emailsGruposSetor}" var="email" rendered="#{!empty pagCadastro.emailsGruposSetor}">
<h:column>
<h:outputText value="#{email}" rendered="#{email != pagCadastro.emailGrupoEmEdicao}" />
<h:inputText value="#{email}" rendered="#{email == pagCadastro.emailGrupoEmEdicao}" p:autofocus="true" />
</h:column>
<h:column>
<h:commandLink value="Editar" rendered="#{pagCadastro.estado == 'CONSULTA'}" action="#{pagCadastro.editar(email)}">
<f:ajax render="form:novo form:emailsGruposSetor" />
</h:commandLink>
<h:commandLink value="Salvar" rendered="#{email == pagCadastro.emailGrupoEmEdicao}" />
<h:commandLink value="Cancelar" rendered="#{email == pagCadastro.emailGrupoEmEdicao}" title="Cancela a edição" action="#{pagCadastro.cancelar}" />
<h:commandLink value="Excluir" rendered="#{pagCadastro.estado == 'CONSULTA' || (pagCadastro.estado == 'EDICAO' and email == pagCadastro.emailGrupoEmEdicao)}" />
</h:column>
</h:dataTable>
<h:outputText id="nenhumEmailGrupoEncontrado" value="Nenhum e-mail de grupo encontrado." rendered="#{empty pagCadastro.emailsGruposSetor}" />
</fieldset>
</div>
</ui:define>
</ui:composition>
but when the command link with value "Editar" is clicked, only the data table is rendered when the ajax call returns, not the command link with id novo
.
If I wrap the command link novo
and the data table emailsGruposSetor
with a panel group and specify the id of the panel group in the ajax tag for rendering, both the command link and the data table are rendered as expected. Also, If I don't specify the form id in the ajax render attribute for the components, nothing is rendered, including the data table.
What am I doing wrong?
Here's the layout.xhtml with the form:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:jsf="http://xmlns.jcp.org/jsf"
xmlns:fn="http://xmlns.jcp.org/jsp/jstl/functions">
<ui:insert name="metadados" />
<h:head>
<title>Grupos de E-mail de Servidores</title>
<h:outputStylesheet library="css" name="gruposemailservidores.css" />
<h:outputScript library="script" name="jquery.js" />
<h:outputScript library="script" name="gruposemailservidores.js" />
<ui:insert name="importacoes" />
<h:outputStylesheet library="css" name="#{fn:substring(view.viewId, 1, fn:indexOf(view.viewId, '.'))}.css" />
<h:outputScript library="script" name="#{fn:substring(view.viewId, 1, fn:indexOf(view.viewId, '.'))}.js" />
</h:head>
<h:body>
<div id="cabecalho">
<img src="resources/img/ufca.png" alt="..." />
<span>Grupos de E-mail de Servidores</span>
</div>
<h:form id="form">
<div jsf:id="titulo" jsf:rendered="#{view.viewId != '/login.xhtml'}">
<ui:insert name="titulo" />
</div>
<div id="conteudo">
<ui:insert name="conteudo" />
</div>
</h:form>
<div id="rodape">
</div>
</h:body>
</html>
UPDATE:
The suggested answer here How to find out client ID of component for ajax update/render? Cannot find component with expression "foo" referenced from "bar" doesn't solve my problem.