I’m using the progress indicator workaround mentioned in the forums to implement auto-refresh on some of the components of a page. The auto-refresh is split into refreshing the data for the component which needs to be read from a database and refreshing the UI Component which includes updating label captions, CSS styles, etc. based on the updated data. I’m using a background thread to update the refreshable components as indicated in the code below. I’m not too thrilled about the code as there is a potential for deadlock. Has anyone else come up with a good solution for implementing an auto-refresh capability on components using the ProgressIndicator workaround?
public void run() {
try {
while(true) {
if (running) {
for (AutoRefreshable c : refreshComponents) {
// refresh data outside synchronization block for
// better UI responsiveness
c.refreshData();
synchronized(c) {
if (c.isVisible()) {
synchronized(c.getApplication()) {
c.refreshAsyncComponent();
c.getProgressIndicator().setValue(Math.random());
}
}
}
}
}
Thread.sleep(sleepInterval);
}
} catch (InterruptedException e) {
}
}