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.

    <h:form>
        <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>

            <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>

            <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;"/>
                </p>
            </p:column>
        </p:dataTable>
    </h:form>

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}"
    value="#{comunMB.itemsGruposempresarialesUtil}">

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

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

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.