I have the following problem, I have a dataTable
that contains the possibility to edit the data using editing by the line, using the tag rowEditor
and cellEditor
. Next to it I have a button to delete that line. When I click the edit button I would like to block the delete button, so as not to allow the user to use this button during editing and others, but the main focus is the delete button.
I tried to use the events of dataTable
with ajax
but it is not possible. Does anybody indicate any way out for such a problem?
This datatable
is within a form
with id="form"
and a panelgroup
that includes another datatable
that I want to implement the same functionality.
How can I accomplish this and if I can ...
<p:dataTable id="tabelaVigenciaCorrente" editable="true"
value="#{tabelaTaxaBean.pojo.vigenciaCorrente.faixas}"
emptyMessage="Adicione pelo menos uma faixa" var="corrente"
sortBy="prazoMinimo">
<p:ajax event="rowEditInit" listener="#{tabelaTaxaBean.setBotaoDesativado(true)}" update="btnExcluirFaixaCorrente"/>
<p:ajax event="rowEdit" update=":form:messages"/>
<p:ajax event="rowEditCancel" listener="#{tabelaTaxaBean.setBotaoDesativado(false)}" update="btnExcluirFaixaCorrente"/>
<f:facet name="header">
<div align="left">
<p:outputLabel value="#{tabelaTaxaBean.cabecalhoVigenciaCorrente}" />
</div>
</f:facet>
<p:column headerText="Prazo (em meses)">
<p:cellEditor>
<f:facet name="output">
<p:outputLabel
value="#{corrente.prazoMinimo} a #{corrente.prazoMaximo}" />
</f:facet>
<f:facet name="input">
<p:inputText label="Prazo inicial"
value="#{corrente.prazoMinimo}" size="8" maxlength="3"
onkeypress="mascara(this, soNumeros)" required="true" />
<p:inputText label="Prazo final" value="#{corrente.prazoMaximo}"
size="8" maxlength="3" onkeypress="mascara(this, soNumeros)"
required="true" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Taxa de juros">
<p:cellEditor>
<f:facet name="output">
<p:outputLabel value="#{corrente.taxaJuros}">
<f:convertNumber locale="pt_BR" minFractionDigits="2"
maxFractionDigits="2" />
</p:outputLabel>
<p:outputLabel value="%" />
</f:facet>
<f:facet name="input">
<p:inputText label="Taxa de juros" value="#{corrente.taxaJuros}"
onkeypress="mascara(this,valorMonetario)" size="11"
maxlength="6" required="true">
<f:convertNumber locale="pt_BR" minFractionDigits="2"
maxFractionDigits="2" />
</p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Taxa diferenciada para o banco/empresa">
<p:cellEditor>
<f:facet name="output">
<p:outputLabel value="#{corrente.taxaDiferenciadaParaBanco}">
<f:convertNumber locale="pt_BR" minFractionDigits="2"
maxFractionDigits="2" />
</p:outputLabel>
<p:outputLabel
value="#{corrente.taxaDiferenciadaParaBanco == null ? '' : '%'}" />
</f:facet>
<f:facet name="input">
<p:inputText label="Taxa diferenciada para o banco/empresa"
value="#{corrente.taxaDiferenciadaParaBanco}"
onkeypress="mascara(this,valorMonetario)" size="11"
maxlength="6">
<f:convertNumber locale="pt_BR" minFractionDigits="2"
maxFractionDigits="2" />
</p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Comissão">
<p:cellEditor>
<f:facet name="output">
<p:outputLabel value="#{corrente.comissao}">
<f:convertNumber locale="pt_BR" minFractionDigits="2"
maxFractionDigits="2" />
</p:outputLabel>
<p:outputLabel value="%" />
</f:facet>
<f:facet name="input">
<p:inputText label="Comissão" value="#{corrente.comissao}"
onkeypress="mascara(this,valorMonetario)" size="11"
maxlength="6" required="true">
<f:convertNumber locale="pt_BR" minFractionDigits="2"
maxFractionDigits="2" />
</p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Complemento">
<p:cellEditor>
<f:facet name="output">
<p:outputLabel value="#{corrente.complementoComissao}">
<f:convertNumber locale="pt_BR" minFractionDigits="2"
maxFractionDigits="2" />
</p:outputLabel>
<p:outputLabel
value="#{corrente.complementoComissao == null ? '' : '%'}" />
</f:facet>
<f:facet name="input">
<p:inputText label="Complemento"
value="#{corrente.complementoComissao}"
onkeypress="mascara(this,valorMonetario)" size="11"
maxlength="6">
<f:convertNumber locale="pt_BR" minFractionDigits="2"
maxFractionDigits="2" />
</p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Ação" style="width: 7%"
styleClass="coluna-acao">
<p:rowEditor />
<p:commandButton id="btnExcluirFaixaCorrente" process="@this" styleClass="botaoImagem"
icon="botaoExcluir" title="Excluir" disabled="#{tabelaTaxaBean.botaoDesativado}"
oncomplete="confirmationFaixaExclusao.show()">
<f:setPropertyActionListener
target="#{tabelaTaxaBean.vigenciaTipo}" value="corrente" />
<f:setPropertyActionListener target="#{tabelaTaxaBean.faixa}"
value="#{corrente}" />
</p:commandButton>
</p:column>
<f:facet name="footer">
<div align="right">
<p:commandButton
disabled="#{tabelaTaxaBean.pojo.vigenciaCorrente == null}"
process="@this" value="Adicionar faixa"
update=":dialogAdicionarFaixa" oncomplete="dlgFaixa.show();"
action="#{tabelaTaxaBean.criarFaixa}" >
<f:setPropertyActionListener
target="#{tabelaTaxaBean.vigenciaTipo}" value="corrente" />
</p:commandButton>
<p:commandButton process="@this" update=":dialogVigencia"
oncomplete="dlgVigencia.show()" value="Editar vigência"
action="#{tabelaTaxaBean.editarVigencia}"
disabled="#{(tabelaTaxaBean.pojo.vigenciaCorrente == null) || (tabelaTaxaBean.pojo.vigenciaProxima != null)}" >
<f:setPropertyActionListener
target="#{tabelaTaxaBean.vigenciaTipo}" value="corrente" />
</p:commandButton>
<p:commandButton process="@this" update=":dialogVigencia"
oncomplete="confirmationVigenciaExclusao.show()"
value="Excluir vigência"
disabled="#{(tabelaTaxaBean.pojo.vigenciaCorrente == null) || (tabelaTaxaBean.pojo.vigenciaProxima != null)}">
<f:setPropertyActionListener
target="#{tabelaTaxaBean.vigenciaTipo}" value="corrente" />
</p:commandButton>
</div>
</f:facet>
</p:dataTable>