0

How do I update the <p:dataTable id="dtCarg"> from the command button in the <p:dialog>?

I keep getting the following error:

Cannot find component with identifier "dtCarg" referenced from "table_servidoresxdependencia"

The code is:

<h:form id="formGestionServidores" prependId="false" style="font-size:10px;">
    <p:panel>
        <table id="tabla_objetivo_02">
            <tr>
                <td><p:fieldset id="tb_tabla_new" legend="Servidores" styleClass="ui-state-hover"
                        style="min-width:98%;height:100% ">

                        <p:dataTable id="dtCarg" var="cargo" value="#{mantePlazasController.listCargos}"
                            rowStyleClass="#{cargo.colorEstado}" emptyMessage="No existen plazas para la unidad seleccionada"
                            editable="true" style="font-weight: normal;overflow:auto;min-width:98%;">
                            <p:column headerText="Unidad">
                                <h:outputText value="#{cargo.serDescDep}"
                                    rendered="#{mantePlazasController.nivel!=2 and mantePlazasController.nivel!=3 and mantePlazasController.nivel!=4 and mantePlazasController.nivel!=5 and mantePlazasController.nivel!=6 and mantePlazasController.nivel!=7}" />
                                <h:outputText value="#{cargo.serDescDepNVL3}"
                                    rendered="#{mantePlazasController.nivel==2 or mantePlazasController.nivel==3 or mantePlazasController.nivel==4 or mantePlazasController.nivel==5 or mantePlazasController.nivel==6 or mantePlazasController.nivel==7}" />
                            </p:column>
                            <p:column headerText="Historial">
                                <center>
                                    <p:commandButton id="btnHistorial" icon="ui-icon-note" oncomplete="dlRegularizar.show()"
                                        title="Historial de Plaza" action="#{mantePlazasController.mostrarHistorial}">
                                        <f:setPropertyActionListener value="#{cargo}" target="#{mantePlazasController.cargoSelected}" />
                                    </p:commandButton>
                                    falta oncomplete falta actualizar
                                </center>
                            </p:column>
                        </p:dataTable>
                    </p:fieldset></td>
            </tr>
        </table>

        <p:dialog widgetVar="dlRegularizar" header="Regularizar Servidores" width="1210" modal="true">
            <p:dataTable id="table_servidoresxdependencia" var="servidorxdependencia"
                value="#{mantePlazasController.servidoresxdependencia}"
                emptyMessage="No existen trabajadores en el historial, para esa plaza"
                rowStyleClass="#{servidorxdependencia.color_his}">

                <p:ajax event="rowEdit" listener="#{mantePlazasController.onEditRowServidorxDependencia}"
                    update="tabla_objetivo_02:dtCarg,table_servidoresxdependencia,notificacionCalificacion,my_json_data" />

                <f:facet name="header">
                        Servidor-Dependencia HISTORIAL
                    </f:facet>
                <p:column headerText="Codigo">
                    <h:outputText value="#{servidorxdependencia.serCod}" />
                </p:column>
                <p:column headerText="Fecha de inicio">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{servidorxdependencia.serFech_in_unmsm_str}" />
                        </f:facet>
                        <f:facet name="input">
                            <p:calendar value="#{servidorxdependencia.serFech_in_unmsm}" navigator="true" inputStyle="width:70px"
                                locale="es" pattern="dd/MM/yyyy" showButtonPanel="true" readOnlyInputText="true" showOn="button">
                            </p:calendar>
                        </f:facet>
                    </p:cellEditor>
                </p:column>
                <p:column headerText="Edit" style="width:20px">
                    <p:rowEditor />
                </p:column>
                <p:column headerText="Elim">
                    <center>
                        <p:commandButton id="HisEliSer" icon="ui-icon-trash" oncomplete="puenteEliSerHis(),linea_ocultar()"
                            title="Eliminar">
                            <f:setPropertyActionListener value="#{servidorxdependencia}" target="#{mantePlazasController.servidorHisElim}" />
                        </p:commandButton>
                    </center>
                </p:column>
            </p:dataTable>
        </p:dialog>
    </p:panel>
</h:form>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555

1 Answers1

3

So, basically, you have a

<h:form id="formGestionServidores" prependId="false" ...>
    <p:panel>
        <table id="tabla_objetivo_02">
            <tr>
                <td>
                    <p:fieldset id="tb_tabla_new" ...>
                        <p:dataTable id="dtCarg" ...>

and you want to reference it in the update as follows

<p:ajax ... update="tabla_objetivo_02:dtCarg" />

This is indeed not going to work. The HTML <table> element does not represent a JSF component, so it is not available in the JSF component tree. For starters, the easiest way to find out the right client ID is to look in the generated HTML output by rightclick and View Source in browser. Locate the HTML representation of <p:dataTable id="dtCarg"> and use exactly its id attribute in the update, prefixed with :.

Based on the view markup posted so far, with <h:form prependId="false">, the generated HTML representation should just have id="dtCarg", so you should reference it as follows:

<p:ajax ... update=":dtCarg" />

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555