I Create one project. but when 2 clients try to access the same view, I got connector erro
Cannot remove from parent when the session is not locked
How annotation I need to put to fix? I try to put UIScope but dont work
I Create one project. but when 2 clients try to access the same view, I got connector erro
Cannot remove from parent when the session is not locked
How annotation I need to put to fix? I try to put UIScope but dont work
Can you post some code?
Sure.
My UI:
@SpringUI
@Theme("caixa")
@Widgetset("br.com.lumera.caixa.CaixaWidgetset")
public class CaixaUI extends UI{
private Navigator navigator;
@Autowired
private SpringViewProvider viewProvider;
@Override
protected void init(VaadinRequest request) {
VerticalLayout layout = new VerticalLayout();
Panel viewContent = new Panel();
viewContent.setSizeFull();
MenuBar menuBar = new MenuBar();
MenuItem itemCaixa = menuBar.addItem("",FontAwesome.BARS, null);
itemCaixa.addItem("Dashboard Caixa", FontAwesome.AREA_CHART, event -> navegar(DashboardCaixaView.VIEW_NAME));
itemCaixa.addItem("Relatório FCRCPN", FontAwesome.AREA_CHART, event -> navegar(RelatorioFCRView.VIEW_NAME));
itemCaixa.addItem("Dashboard Receitas", FontAwesome.AREA_CHART, event -> navegar(DashboardReceitaView.VIEW_NAME));
layout.addComponents(menuBar,viewContent);
layout.setSizeFull();
layout.setExpandRatio(viewContent, 1);
navigator = new Navigator(this, viewContent);
navigator.addProvider(viewProvider);
setContent(layout);
navigator.navigateTo(DashboardCaixaView.VIEW_NAME);
}
private void navegar(String viewName) {
navigator.navigateTo(viewName);
}
}
this is my View
@SpringView(name="dashboardCaixaView")
@Push
public class DashboardCaixaView extends DashboardCaixa implements View{
SimpleDateFormat sdfGrafico;
public static final String VIEW_NAME = "dashboardCaixaView";
@Autowired
private ObjectMapper jsonConverter;
@Autowired
ResourceLoader resourceLoader;
@Autowired
private FinanceiroService financeiroService;
@Autowired
private DetalheMovimentacaoView detalheMovimentacaoView;
@Autowired
private ListarChequesView listarChequesView;
private BeanItemContainer<ItemDashboard> entradasContainer;
private BeanItemContainer<CaixaVO> caixasContainer;
private BeanItemContainer<ItemDashboard> custasContainer;
private BeanItemContainer<ItemDashboard> resumoContainer;
private BeanItemContainer<ItemDashboard> saidasContainer;
private BeanItemContainer<ItemDashboard> outrasSaidasContainer;
private BeanItemContainer<ItemDashboard> outrasEntradasContainer;
private ObjectProperty<String> totalEntradas = new ObjectProperty<String>("0");
private ObjectProperty<String> totalSaidas = new ObjectProperty<String>("0");
private ObjectProperty<String> totalLiquido = new ObjectProperty<String>("0");
private ObjectProperty<String> totalTributavel = new ObjectProperty<String>("0");
private BigDecimal vlTotalEntradasRelatorio = new BigDecimal(BigInteger.ZERO);
private BigDecimal vlTotalSaidasRelatorio = new BigDecimal(BigInteger.ZERO);
private BigDecimal vlTotalTributavelRelatorio = new BigDecimal(BigInteger.ZERO);
private BigDecimal vlTotalLiquidoRelatorio = new BigDecimal(BigInteger.ZERO);
private List<ChequeVO> chequePreRecebido =new ArrayList<>();
private List<ChequeVO> chequePreDepositado =new ArrayList<>();
private List<ChequeVO> chequeDevolvido =new ArrayList<>();
private List<MovimentacaoDashboard> movimentacaos;
private BeanItemContainer<MovimentacaoDashboard> movimentacaosContainer;
private Locale ptBr = new Locale("pt", "BR");
private NumberFormat poundformat;
private MenuItem imprimirDashboard;
private NumberFormat decimalFormat;
public DashboardCaixaView() {
atualizarDashboard.addClickListener(event -> atualizarDashBoardEvent());
dtFinal.addValueChangeListener(event -> buscarCaixas());
dtInicial.addValueChangeListener(event -> buscarCaixas());
caixasList.setClearButtonCaption("Limpar");
caixasList.setSelectAllButtonCaption("Selecionar Todos");
MenuBar.Command imprimirDashboardCommand = new MenuBar.Command() {
@Override
public void menuSelected(MenuItem selectedItem) {
imprimirDashboard();
}
};
MenuItem item = menuImprimir.addItem("",FontAwesome.PRINT, null);
menuImprimir.setAutoOpen(false);
imprimirDashboard = item.addItem("Dashboard", imprimirDashboardCommand);
}
//I got the error here, When I have only one user, works fine, but if more than one user use the same view, after execute this method I got error
// the financeiroService.getDadosMovimentacao(movimentacao.getCodigo()); access one REST
private void mostrarDadosMovimentacao(Object obj){
MovimentacaoDashboard movimentacao = (MovimentacaoDashboard) obj;
try{
Window window = new Window(null);
window.setModal(true);
window.setSizeFull();
window.setResizable(false);
MovimentacaoDashboard retorno = financeiroService.getDadosMovimentacao(movimentacao.getCodigo());
detalheMovimentacaoView.setarDados(retorno);
window.setWidth(80, Unit.PERCENTAGE);
window.setContent(detalheMovimentacaoView);
UI.getCurrent().addWindow(window);
}catch(Exception e){
Utils.showNotification(e.getMessage(), Type.ERROR_MESSAGE, UI.getCurrent().getPage());
}
}
}
and my panel:
[code]
@SpringComponent
public class DetalheMovimentacaoView extends DetalheMovimentacao{
private Locale ptBr = new Locale("pt", "BR");
private NumberFormat poundformat;
private ObjectProperty<String> vlDeconto = new ObjectProperty<String>("0");
private ObjectProperty<String> vlMovimentacao = new ObjectProperty<String>("0");
private ObjectProperty<String> cdMovimentacao = new ObjectProperty<String>("");
private ObjectProperty<String> dtMovimentacao = new ObjectProperty<String>("");
private ObjectProperty<String> nmCaixaMovimentacao = new ObjectProperty<String>("");
private ObjectProperty<String> nmApresentanteMovimentacao = new ObjectProperty<String>("");
private SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
private BeanItemContainer<PendenciaMovimentacaoVO> pendenciaContainer;
private BeanItemContainer<PagamentoMovimentacaoVO> pagamentoContainer;
public DetalheMovimentacaoView() {
poundformat = NumberFormat.getCurrencyInstance(ptBr);
descontoMovimentacao.setPropertyDataSource(vlDeconto);
totalMovimentacao.setPropertyDataSource(vlMovimentacao);
caixaMovimentacao.setPropertyDataSource(nmCaixaMovimentacao);
apresentanteMovimentacao.setPropertyDataSource(nmApresentanteMovimentacao);
codigoMovimentacao.setPropertyDataSource(cdMovimentacao);
dataMovimentacao.setPropertyDataSource(dtMovimentacao);
pagamentoContainer = new BeanItemContainer<PagamentoMovimentacaoVO>(PagamentoMovimentacaoVO.class, new ArrayList<PagamentoMovimentacaoVO>());
pendenciaContainer = new BeanItemContainer<PendenciaMovimentacaoVO>(PendenciaMovimentacaoVO.class, new ArrayList<PendenciaMovimentacaoVO>());
gridPagamento.setContainerDataSource(pagamentoContainer);
gridServicos.setContainerDataSource(pendenciaContainer);
gridServicos.removeColumn("cdDivisor");
gridServicos.setColumnOrder("natureza","tpProtocoloReferencia","nrProtocoloReferencia", "nome", "idPendencia", "vlInformado","quantidade", "custas1","custas2","custas3","custas4","custas5","custas6","custas7","custas8","custas9","custas10","vlDesconto","divisor");
gridServicos.getColumn("vlInformado").setRenderer(new NumberRenderer(poundformat));
gridServicos.getColumn("custas1").setRenderer(new NumberRenderer(poundformat));
gridServicos.getColumn("custas2").setRenderer(new NumberRenderer(poundformat));
gridServicos.getColumn("custas3").setRenderer(new NumberRenderer(poundformat));
gridServicos.getColumn("custas4").setRenderer(new NumberRenderer(poundformat));
gridServicos.getColumn("custas5").setRenderer(new NumberRenderer(poundformat));
gridServicos.getColumn("custas6").setRenderer(new NumberRenderer(poundformat));
gridServicos.getColumn("custas7").setRenderer(new NumberRenderer(poundformat));
gridServicos.getColumn("custas8").setRenderer(new NumberRenderer(poundformat));
gridServicos.getColumn("custas9").setRenderer(new NumberRenderer(poundformat));
gridServicos.getColumn("custas10").setRenderer(new NumberRenderer(poundformat));
gridServicos.getColumn("vlDesconto").setRenderer(new NumberRenderer(poundformat));
gridPagamento.getColumn("valor").setRenderer(new NumberRenderer(poundformat));
gridPagamento.setColumnOrder("nome","id","tpProtocoloReferencia","nrProtocoloReferencia","movimentacaoReferencia","valor");
}
public void setarDados(MovimentacaoDashboard movimentacao){
vlDeconto.setValue(poundformat.format(movimentacao.getDesconto()));
vlMovimentacao.setValue(poundformat.format(movimentacao.getTotal().subtract(movimentacao.getDesconto())));
cdMovimentacao.setValue(movimentacao.getCodigo().toString());
dtMovimentacao.setValue(dateFormat.format(movimentacao.getData()));
nmCaixaMovimentacao.setValue(movimentacao.getCaixa());
nmApresentanteMovimentacao.setValue(movimentacao.getApresentante());
pendenciaContainer.removeAllItems();
pagamentoContainer.removeAllItems();
pagamentoContainer.addAll(movimentacao.getPagamentos());
pendenciaContainer.addAll(movimentacao.getPendencias());
for(int i = 1; i <= 10; i++){
if(gridServicos.getColumn("custas"+i) == null){
gridServicos.addColumn("custas"+i);
}
}
for (int i = 1; i <= movimentacao.getNomeCustas().size(); i++) {
gridServicos.getColumn("custas"+i).setHeaderCaption(movimentacao.getNomeCustas().get(i));
}
for (int i = movimentacao.getNomeCustas().size()+1; i <= 10; i++) {
gridServicos.removeColumn("custas"+i);
}
}
}
[/code]y
The error occurs when the method private void mostrarDadosMovimentacao(Object obj){ are executed
You can remove @Push annotation from the View; the annotation is meant to annotate UI classes.
Then add @ViewScope annotation to DetalheMovimentacaoView so it is view scoped and every view will have its own instance, otherwise ther will be a a sinlge application-wide instance.
Make me know if this will fix your problem
Marco
Dont works marco.
Hi Fabio,
where is the metod mostrarDadosMovimentacao invoked in your code?
Can you also post the exception stacktrace?
here
private void mostrarDadosMovimentacao(Object obj){
MovimentacaoDashboard movimentacao = (MovimentacaoDashboard) obj;
try{
Window window = new Window(null);
window.setModal(true);
window.setSizeFull();
window.setResizable(false);
MovimentacaoDashboard retorno = financeiroService.getDadosMovimentacao(movimentacao.getCodigo());
detalheMovimentacaoView.setarDados(retorno);
window.setWidth(80, Unit.PERCENTAGE);
window.setContent(detalheMovimentacaoView);
UI.getCurrent().addWindow(window);
}catch(Exception e){
Utils.showNotification(e.getMessage(), Type.ERROR_MESSAGE, UI.getCurrent().getPage());
}
}
and i have
@Autowired
DetalheMovimentacaoView detalheMovimentacaoView
but I try to replate to
DetalheMovimentacaoView detalheMovimentacaoView = new DetalheMovimentacaoView(); inside my method and still the same error
That’s weird. Could you post the stack trace please?
Another question. Is the method mostrarDadosMovimentacao invoked from a background thread?
I’m asking because I noticed you tried to add @Push annotation
Sorry man… works.
the @ViewScope works…
I was testing on wrong port and getting the old version
It’s monday effect, don’t worry
Glad I could help
Cheers
Marco