I have a lazy
load on DataTable
of PrimeFaces, and on this table I upload I want to edit a record.
Clicking the line will open a dialog
with a form
to edit that record. However, when you click the line, it opens dialog
but does not load the registry data for editing.
This is the bean:
private LazyDataModel<LancamentoTributoCdg> model;
public PagamentoTributoCdgBean() {
this.limpar();
this.limparBaixa();
// Busca
filtro = new MovimentoPagarLancamentoFilterCdg();
lancamentosFiltrados = new ArrayList<>();
model = new LazyDataModel<LancamentoTributoCdg>() {
private static final long serialVersionUID = 1L;
@Override
public List<LancamentoTributoCdg> load(int first, int pageSize, String sortField, SortOrder sortOrder,
Map<String, Object> filters) {
filtro.setPrimeiroRegistro(first);
filtro.setQuantidadeRegistros(pageSize);
filtro.setPropriedadeOrdenacao(sortField);
filtro.setAscendente(SortOrder.ASCENDING.equals(sortOrder));
setRowCount(lancamentosTributos.quantidadeFiltrados(filtro));
return lancamentosTributos.filtrados(filtro);
}
@Override
public LancamentoTributoCdg getRowData(String rowKey) {
if (rowKey != null) {
for (LancamentoTributoCdg lancamento : lancamentosTributos.filtrados(filtro)) {
if (lancamento.getId().equals(rowKey))
lancamentoSelecionnado=lancamento;
return lancamentoSelecionnado;
}
}
return null;
}
};
}
// Datable (seleciona a linha e chama o metodo)
public void onRowSelect(SelectEvent event) {
lancamento = (LancamentoTributoCdg) event.getObject();
listaBancos = bancos.bancoRepository(StatusConta.ATIVA);
}
And here's the HTML:
<p:dataTable id="lancamentoTable" lazy="true"
value="#{pagamentoTributoCdgBean.model}"
widgetVar="lancamentoTableWidgetVar"
var="lancamento" scrollable="true" scrollHeight="460"
style="margin-top: 2px;" emptyMessage="Nenhum lançamento." rows="10"
paginator="true"
rowsPerPageTemplate="10,12,15,20" paginatorPosition="bottom"
selectionMode="single"
selection="#{pagamentoTributoCdgBean.lancamentoSelecionnado}"
rowKey="#{lancamento.id}">
<p:ajax event="rowSelect" disabled="#{not seguranca.administrador}"
listener="#{pagamentoTributoCdgBean.onRowSelect}"
oncomplete="PF('inserirBancoVar').show();" process="@this"
update=":incluirBanco:inclusaoPanelGroup :incluirBanco:botaoConfirmar :incluirBanco:botaoTrocarBanco :incluirBanco:botaoSalvar :incluirBanco:botaoAtivaNota :incluirBanco:botaoCancelarNota" />
<p:column headerText="NUMERO" style="width: 60px">
<h:outputText value="#{lancamento.numeroNota}"
style="float: right; #{lancamento.cancelada ? 'color: red' : ''}" />
</p:column>
Displays this error when dialog
is loaded:
GRAVE: Could not handle exception!
java.lang.IllegalStateException: Cannot call reset() after response has been committed