I have page with filter form, a few buttons and big grid. I can search data, based on filter form, and show data in grid. Searching data provides thread, it may take about secs to mins. When I want to click button to stop searching (basically to stop thread), the action is performed always after the thread is done. But I need to perform click event while thread is working. Does somebody know how to do it? :)
UI has @Push(PushMode.MANUAL), and pushing is working fine
Simplified code:
@SpringComponent
@UIScope
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class DistraintSearchComponent extends CustomComponent {
@Autowired
private Service service
private Button searchButton = new Button("Search");
private Button stopButton = new Button("Stop");
private Thread searchThread;
public void init(){
searchButton.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
searchThread = new Thread(new Runnable() {
@Override
public void run() {
List<Results> results = service.findByFilter(filter); //this can take some time
refreshGrid(results);
getUI().push();
}
});
searchThread.start();
}
});
stopButton.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
searchThread.interrupt();
}
});
}
}
Thank you