当存在绑定属性时,PrimeFaces dataTable不会呈现

时间:2011-10-06 22:21:48

标签: ajax jsf jsf-2 datatable primefaces

我正在创建一个带有两个dataTable的dataTable:)。

但是这次当我尝试在包含第一个dataTable的h:panelGroup中使用绑定属性时,我遇到了渲染问题。 我正在使用绑定来帮助刷新panelGroup,就像BalusC在this question中所说的那样。当我删除绑定属性时,dataTable正常呈现,但当然没有使用f:ajax标记在dataTables中呈现。

这是xhtml:

<ui:component>
<h:panelGroup>
    <h:panelGroup layout="block;" id="#{id}"
        binding="#{painelTabelaContatos}" rendered="true">
        <p:dataTable id="tabela#{id}"
            value="#{modeloTabelaContatos.listaDeContatos}" var="contato"
            selectionMode="single"
            rowSelectListener="#{controladorTabelaContatos.processarSelecaoLinha}"
            rowUnselectListener="#{controladorTabelaContatos.processarDeselecaoLinha}"
            selection="#{modeloTabelaContatos.contatoSelecionado}">
            <p:column headerText="Contatos">
                <hrgi:editableText style="width:100%" value="#{contato.descricao}" />
            </p:column>
            <p:column headerText="Telefones">
                <h:dataTable value="#{contato.telefones}" var="telefone">
                    <h:column>
                        <h:inputText value="#{telefone}" />
                    </h:column>
                    <h:column>
                        <h:graphicImage library="img" name="default_trash.png"
                            style="cursor:pointer;">
                            <f:ajax event="click" render=":#{painelTabelaContatos.clientId}"
                                listener="#{controladorTabelaContatos.removerTelefone(contato, telefone)}" />
                        </h:graphicImage>
                    </h:column>
                </h:dataTable>
            </p:column>
            <p:column headerText="e-mails">
                <h:dataTable value="#{contato.emails}" var="email">
                    <h:column>
                        <h:inputText value="#{email}" />
                    </h:column>
                    <h:column>
                        <h:graphicImage library="img" name="default_trash.png"
                            style="cursor:pointer;">
                            <f:ajax event="click" render=":#{painelTabelaContatos.clientId}"
                                listener="#{controladorTabelaContatos.removerEmail(contato, email)}" />
                        </h:graphicImage>
                    </h:column>
                </h:dataTable>
            </p:column>
            <p:column>
                <h:graphicImage library="img" name="default_trash.png"
                    style="cursor:pointer;">
                    <f:ajax render=":#{painelTabelaContatos.clientId}" event="click"
                        listener="#{controladorTabelaContatos.removerContato(contato)}" />
                </h:graphicImage>
            </p:column>
        </p:dataTable>
    </h:panelGroup>
    <h:panelGroup layout="block">
        <p:commandButton value="ADICIONAR CONTATO" update="#{id}"
            immediate="true"
            action="#{controladorTabelaContatos.adicionarContato}" />
        <p:commandButton value="ADICIONAR TELEFONE" update="#{id}"
            immediate="true"
            action="#{controladorTabelaContatos.adicionarTelefone}" />
        <p:commandButton value="ADICIONAR E-MAIL" update="#{id}"
            immediate="true"
            action="#{controladorTabelaContatos.adicionarEmail}" />
    </h:panelGroup>
</h:panelGroup>
</ui:component>

我已经尝试删除p:dataTable中的h:dataTables,但没有成功。 此组件只是PrimeFaces选项卡的内容,此选项卡位于PrimeFaces对话框中。有人可以解释我为什么会这样吗?

1 个答案:

答案 0 :(得分:1)

在找到解决方案之后,我找到了错误的原因...... 问题是由于我在两个不同的页面中调用此组件引起的:

popupCadastroPessoa.xhtml

<ui:include src="../tabs/abaEdicaoContatos.xhtml">
    <ui:param name="id" value="painelContatoPessoa" />
</ui:include>

并在popupCadastroFuncionario.xhtml

<ui:include src="../tabs/abaEdicaoContatos.xhtml">
    <ui:param name="id" value="painelContatoFuncionario" />
</ui:include>

因为我没有真正创建绑定bean,JSF感到困惑。所以我刚创建了两个UIPanel bean并将其作为参数传递:

<ui:include src="../tabs/abaEdicaoContatos.xhtml">
    <ui:param name="id" value="painelContatoPessoa" />
    <ui:param name="painelTabelaContatos" value="#{bindingTabelaContatoPessoa}"/>
</ui:include>

是我的错。感谢您的关注,并对给您带来的不便表示歉意。