How do I apply Vaadin7 server push to a Navigated View. Basically I want to up date MyView class table components. Since Its a navigated View its not working as explained in Vaadin. Is there Any other way to update data from MyView class? such as inserting the thread in it.
UI class
@Push
public class MyUI extends UI{
Navigator navigator;
@WebServlet(value = "/*", asyncSupported = true)
@VaadinServletConfiguration(productionMode = false, ui = MyUI.class, widgetset = "com.example.myui.MyuiWidgetset")
public static class Servlet extends VaadinServlet {
}
@Override
protected void init(VaadinRequest request) {
new Navigator(this, this);
getNavigator().addView(MyView.MYVIEW, MyView.class);
new InitializerThread().start();
}
}
class InitializerThread extends Thread {
@Override
public void run() {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
access(new Runnable() {
@Override
public void run() {
//update MyView's table from this event
}
});
}
}
}
View Class
public class MyView extends CustomComponent implements View
{
public MainView()
{
final Table table = new Table();
table.addContainerProperty("Date & Time", String.class, null);
table.setSelectable(true);
table.setSizeFull();
table.setImmediate(true);
while(){
table.addItem(new Object[]{new Date()}, new String(""));
}
}