Reputation: 304
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:
What am I doing wrong? :-(
Thanks in advance.
Upvotes: 0
Views: 1352
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