Hello,
I’ve run into a problem applying the UriFragmentUtility to my application.
Basicly, I’m trying to set the fragment like that:
public class VaadinApplication extends Application {
public void init() {
final Window mainWindow = new Window("Vaadin Application");
final Label label = new Label("Hello Vaadin users");
mainWindow.addComponent(label);
final UriFragmentUtility history = new UriFragmentUtility();
mainWindow.addComponent(history);
history.setFragment("hello");
this.setMainWindow(mainWindow);
}
}
When called in a browser, nothing happens. Of course, the label is rendered, but the URL is not appended with “#hello”.
But if I add a Button and set the fragmet onClick, it works:
public class VaadinApplication extends Application {
public void init() {
final Window mainWindow = new Window("Vaadin Application");
final Label label = new Label("Hello Vaadin users");
mainWindow.addComponent(label);
final UriFragmentUtility history = new UriFragmentUtility();
mainWindow.addComponent(history);
final Button button = new Button("Click me");
button.addListener(new ClickListener() {
@Override
public void buttonClick(final ClickEvent event) {
history.setFragment("clicked");
}
});
mainWindow.addComponent(button);
this.setMainWindow(mainWindow);
}
}
Where is the difference? As far as I understand, the setFragment is called within a Vaadin Transaction both times, and the UFU is added to the main window.
Any hints?
Thanks in advance!
Kind regards,
Michael