Rafael Simonelli
Rafael Simonelli

Reputation: 304

Primefaces Datatable rowEditInit update components fails

I have a dataTable with cellEditors. When I start editing some line, there are 2 buttons outside the table that should change visibility. As follows:

        <h:form id="formExigencias">
            <p:panel id="pnlBotoes" columns="3">
                <div class="direita">
                    <p:commandButton value="One Button to Change Visibility"
                        rendered="#{not exigenciaMinimaBean.emAlteracao}"
                        action="#{myBean.someAction()}" />
                    <p:commandButton value="Another Button to Change Visibility"
                        rendered="#{exigenciaMinimaBean.emAlteracao}"
                        action="#{myBean.someOtherAction()}" >
                        <p:confirm header="Confirmação"
                            message="OK?" 
                            icon="ui-icon-alert" />
                    </p:commandButton>
                    <p:spacer height="8px" />
                </div>

                <p:fieldset legend="Resultado da Pesquisa">
                    <p:dataTable id="tabelaExigencias"
                        emptyMessage="Nenhuma exigência cadastrada."
                        value="#{exigenciaMinimaBean.exigencias}" var="exigencia"
                        paginator="true" rows="10" paginatorPosition="bottom"
                        rowsPerPageTemplate="5,10,15"
                        paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                        rowKey="#{exigencia.id}"
                        selection="#{exigenciaMinimaBean.exigenciaEdicao}"
                        selectionMode="single" editable="true">

                        <p:ajax event="rowEditInit"
                            listener="#{exigenciaMinimaBean.rowEditInit}" 
                            process="@this"
                            update=":formExigencias:pnlBotoes"/>

                        <!-- declarations supressed to optimize reading -->
                    </p:dataTable>
                </p:fieldset>
            </p:panel>
            <p:spacer height="20px" />              
        </h:form>


@ManagedBean
@ViewScoped
public class ExigenciaMinimaBean {
    public void rowEditInit(RowEditEvent evento) {
        emAlteracao = true;
    }
}

Here's what I've accomplished so far:

  1. If I update the panel "pnlBotoes", the buttons are correctly updated, but the row exits Editing Mode (becomes non editable again)
  2. If I update the buttons individually, no renders are changed and the table keeps its original state.
  3. Update from Backing Bean did not work.
  4. Presence of 'process="@this"' changes nothing

What am I doing wrong? :-(

Thanks in advance.

Upvotes: 0

Views: 1352

Answers (1)

user2880020
user2880020

Reputation:

You are trying to update the panel which contains the datatable, so editMode is being reset to its "default" state.

I suggest you to replace the div which contains the <p:commandButton> with <h:panelGroup layout="block" id="aDiv"> and update that component after the rowEditInit event (i.e: update=":formExigencias:pnlBotoes:aDiv")

Upvotes: 2

Related Questions