我有这个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>
但是当单击带有值&#34; Editar&#34; 的命令链接时,仅在ajax调用返回时呈现数据表,而不是具有标识{{1}的命令链接}。
如果我将命令链接novo
和数据表novo
与面板组包装在一起,并在ajax标记中指定面板组的id以进行渲染,则命令链接和数据表都是如此按预期呈现。另外,如果我没有在组件的ajax render属性中指定表单id,则不会呈现任何内容,包括数据表。
我做错了什么?
这里是 layout.xhtml ,格式为:
emailsGruposSetor
更新
这里建议的答案How to find out client ID of component for ajax update/render? Cannot find component with expression "foo" referenced from "bar"并不能解决我的问题。