Your solution can’t work, because it changes the visibility only on the server-side.
The usual way to initiate periodic calls to server is polling with ProgressIndicator. However, even though it causes calls to server, it does not have a way to actually cause any changes in the server-side state. You could do such changes in another server-side thread, such as your Timer there, but the thread would not run synchronously with the polling. The only way to run something with every client-initiated poll request is to use a transaction listener. Just notice that it is called also for any other request.
For example, in the following we have a counter (the example has some weird stuff just to get some proper references):
// A counter to increment each call
class Counter {
Integer value = 0;
public Integer increment() {
return ++value;
}
}
final Counter counter = new Counter();
// A component to display the counter value
final Label label = new Label("Count: -");
layout.addComponent(label);
// Progress indicator that causes server poll every second
ProgressIndicator indicator = new ProgressIndicator();
indicator.setIndeterminate(true);
// On every poll (OR any other server request),
// increment the counter
getApplication().getContext().addTransactionListener(
new TransactionListener() {
public void transactionStart(Application application,
Object transactionData) {
label.setValue("Count: " + counter.increment());
}
public void transactionEnd(Application application,
Object transactionData) {
}
});
layout.addComponent(indicator);
Well, I’m not sure what you are exactly trying to do, but polling is a rather heavy operation just to create a visual effect. Why don’t you just use “[tt]
.v-label {text-decoration: blink}
[/tt]” CSS to get the blinking effect?