Envíe la fila editada en un DataTable (Primefaces JSF)

I am having a Data table which has controls for inline editing of a row by showing a <p:inputText/> of styleClass="iteminput" en el lugar de <h:outputText /> con un styleClass="itemcell"

However I am really facing difficulties of submitting the entered values in the input for the table row corresponding to var="sc" and updating my list array in the controller via the <p:commandButton id="submit" ..../> del botón.

Agradezco cualquier ayuda.

        <p:dataTable value="#{SConfigsController.sConfigs}" var="sc" paginatorPosition="bottom" paginator="true" rows="12">

            <p:column headerText="id">
                <h:outputText value="#{sc.id}" styleClass="itemcell" />
                <p:inputText value="#{sc.id}" id="editId"  placeholder="..." style="display:none;"  styleClass="iteminput" />

            <p:column headerText="name">
                <h:outputText value="#{sc.name}" styleClass="itemcell" />
                <p:inputText value="#{sc.name}" id="editName"  placeholder="..." style="display:none;"  styleClass="iteminput" />

            <p:column headerText="edit">
                <p class="txtcent">
                    <p:commandButton onclick="peb.onedit(this)" onsuccess="" ajax="true" icon="ui-icon-pencil" title="Icon Only" />
                    <p:commandButton id="submit"  actionListener="#{SConfigsController.editConfig}"  ajax="true" icon="ui-icon-check" title="Icon Only" styleClass="btnok editbtn" style="display:none;"></p:commandButton>
                    <p:commandButton  ajax="true" icon="ui-icon-circlesmall-close" title="Icon Only" styleClass="btncancel editbtn" style="display:none;"/>

preguntado el 28 de mayo de 14 a las 11:05

what happen when you edit the value in the p:inputText and you focus on another field before submitting then you submit ? did the change affected ? -

I guess no. Actually I am having problem with a concept of submitting anything at all. The method SConfigsController.editConfig is triggered but I can't figure out how to submit the values and update the sConfigs array list in the controller. Perhaps it seems lame but I really have small experience with JSF -

Try to inspect the request sent to the server using Chrome's elements inspection or Firebug and look at what your browser write in the request. -

That was helpful it sends the new value in the request, indeed -

you can use row editor... -

1 Respuestas

You can use the row editor.

<p:dataTable editable="true" emptyMessage="No se encontraron elementos"
    rowIndexVar="rowIndex" id="tabla_listado" var="item" paginator="true"
    rows="12" rowKey="#{item.idGrupoEmpresarial}"

    <f:facet name="header">
        <h:outputText value="Listado de Grupos Empresariales" />
    <p:ajax event="rowSelect" update=":form2:growl :form2:dialog"
        listener="#{adminGruposEmpresariales.detallesGrupoEmpresarial}" />
    <p:ajax event="rowEdit" update=":form2:growl"
        listener="#{adminGruposEmpresariales.onEdit}" />
    <p:ajax event="rowEditCancel" update=":form2:growl" />
    <p:column headerText="Nombre">
            <f:facet name="output">
                <h:outputText value="#{item.nombre}" />
            <f:facet name="input">
                <p:inputText value="#{item.nombre}" style="width:98%" />

    <p:column headerText="Sigla">
            <f:facet name="output">
                <h:outputText value="#{item.descripcion}" />
            <f:facet name="input">
                <p:inputText value="#{item.descripcion}" style="width:98%" />
    <p:column style="width:20px">
        <p:rowEditor />

Respondido el 10 de enero de 22 a las 03:01

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.