Java – how to update the expression datatable in a specific cell
•
Java
I am creating a dynamic data filled with input fields Sometimes, when a user inserts a value into some input, a specific cell should be updated, and only that cell can be updated I thought it might be simple, but I didn't make it work
EDITED
I have tried F: Ajax with full ID and got "component and ID: lancancetonf: poplancancetonf: tabelaitensnf: 0: valortotaltitem not found" Change to P: Ajax, no errors occur, but it is not updated!
<h:panelGroup id="painelItensNF" layout="block" styleClass="hrgi-div-form aba-lancamento-nf clearfix" style="overflow:auto;"> <h:panelGroup layout="block" style="width: 1700px;"> <p:dataTable id="tabelaItensNF" value="#{modeloTabelaDinamicaItemNF.itens}" var="itemEmbrulhado" styleClass="tabelaDinamica" height="174" style="width: 100%;" rowIndexVar="indice"> ... (some columns) <p:column style="width: 5%" headerText="quantidade"> <hrgi:spinner id="quantidadeItem" value="#{itemEmbrulhado.item.produto.detalheTributavel.quantidade}" dinheiro="false" fator="#{itemEmbrulhado.item.produto.detalheTributavel.unidadeFracionada?0.01:1}" local="pt-BR" min="0.00" width="70"> <p:ajax event="change" update="lancamentoNF:popupLancamentoNF:tabelaItensNF:#{indice}:valorTotalItem" listener="#{controladorPopupLancamentoNF.calcularValorTotalItem(itemEmbrulhado)}" global="false" /> <f:convertNumber maxFractionDigits="#{itemEmbrulhado.item.produto.detalheTributavel.unidadeFracionada?2:0}" minFractionDigits="#{itemEmbrulhado.item.produto.detalheTributavel.unidadeFracionada?2:0}" locale="pt-BR" for="quantidadeItem"/> </hrgi:spinner> </p:column> <p:column style="width: 5%" headerText="valor unitario"> <hrgi:spinner id="valorUnitarioItem" value="#{itemEmbrulhado.item.produto.detalheTributavel.valorUnitario}" dinheiro="true" fator="0.01" local="pt-BR" min="0.00" width="70"> <p:ajax event="change" update="lancamentoNF:popupLancamentoNF:tabelaItensNF:#{indice}:valorTotalItem" listener="#{controladorPopupLancamentoNF.calcularValorTotalItem(itemEmbrulhado)}" global="false"/> <f:convertNumber type="currency" currencyCode="BRL" currencySymbol="R$" maxFractionDigits="10" minFractionDigits="2" locale="#{cc.attrs.local}" for="valorUnitarioItem"/> </hrgi:spinner> </p:column> <p:column style="width: 3%" headerText="valor total"> <h:outputText id="valorTotalItem" value="#{itemEmbrulhado.item.produto.valorTotal}"> <f:convertNumber type="currency" currencyCode="BRL" currencySymbol="R$" maxFractionDigits="2" minFractionDigits="2" locale="pt-BR" for="valorUnitarioItem"/> </h:outputText> </p:column> ... (more columns) </p:dataTable> </h:panelGroup> </h:panelGroup>
When I update the panelgroup "painel itensnf" with the full ID, it works, but the key point is lost. The user should find the input he is continuing to work
Solution
Just use update = "valortotaltitem" This is relative to the current line
So, replace
<p:ajax ... update="lancamentoNF:popupLancamentoNF:tabelaItensNF:#{indice}:valorTotalItem" />
adopt
<p:ajax ... update="valorTotalItem" />
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码