I found that I was received the NPE with the transient variable when
executing the same class twice concurrently, which makes sense now.

I went with the following (stripped back show only necessary code):

@SpringBean
private SupplierConnector supplierPrices;

private class GetPrices extends AjaxLazyLoadPanel {
        public GetPrices(String id, final PageParameters changeDatesParam) {
                super(id);
        }
                
        public Component getLoadingComponent(String markupId) {
                return new Label(markupId, "");
        }

        @Override
        public Component getLazyLoadComponent(String markupId) {
                Wholesaler1 wholesaler1 = new Wholesaler1();
                Wholesaler2 wholesaler2 = new Wholesaler2();
                                        
                Future<List&lt;Result>> wholesaler1List =
supplierPrices.getWholesaler1Prices(wholesaler1, searchFields);
                Future<List&lt;Result>> wholesaler2List =
supplierPrices.getWholesaler2Prices(wholesaler2, searchFields);
                                        
                while(!(wholesaler1List.isDone() && wholesaler2List.isDone())) {
                        try {
                                Thread.sleep(100); //pause between each check
                        }
                        catch(Exception e) {
                                log.error("Thread sleep exception");
                        }
                }
                                        
                try {
                        SearchResults.this.results.addAll(wholesaler1.get());
                        SearchResults.this.results.addAll(wholesaler2.get());
                }
                catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
                catch (ExecutionException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
                
                AjaxRequestTarget resultsTarget =
resultsContainer.getRequestCycle().find(AjaxRequestTarget.class);
                resultsTarget.add(resultsContainer);    
                                        
                AjaxRequestTarget progressTarget =
progressBar.getRequestCycle().find(AjaxRequestTarget.class);    
                progressTarget.add(progressBar);

                return new Label(markupId, "");
        }
}


In the SupplierConnector class
@Async
public Future<List&lt;HotelRoomResult>> getWholesaler1Prices(Wholesaler
wholesaler, SearchFields searchFields) {
        //Do time consuming operation

        return new AsyncResult<List&lt;Result>>(results);
}

I am using a progress bar instead of an ajax indicator and the
resultsContainer contains the display showing the results obtained.

I hope it helps others

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/AjaxLazyLoadPanel-loading-asynchronously-tp4664035p4665188.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to