IMHO this code should work (navigate to a view and then back again) but when I test I can’t navigate back using the “Go back” button. Clicking on the button in the NavigationBar works. Seems like navigateBack() isn’t working properly. Can someone else confirm that this is a bug? Im using Vaadin 7 and TouchKit 3 Alpha 5:
public class MobileUI extends UI {
@Override
protected void init(VaadinRequest request) {
final NavigationManager manager = new NavigationManager();
setContent(manager);
final NavigationView c = new NavigationView();
Button back = new Button("Go back");
back.addClickListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
manager.navigateTo(c);
}
});
c.setContent(back);
manager.navigateTo(new NavigationView(new Button("Go to second level", new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
manager.navigateTo(c);
}
})));
}
}
You are most correct, sir. There’s something weird going on as the button in the navigation bar actually calls navigateBack() as well. I created a ticket for this and I’m currently investigating the problem.
Cheers
/Jonatan
PS. The code you pasted actually never calls navigateBack(), but tries to navigate to the visible view. The problem you describe is, however, quite accurate.
Just committed a fix to the repository, grab it from
there if you need it right away (building is as easy as “mvn install”). See
#11373 for a short description of what the problem was if you’re interested.
I’m using the SNAPSHOT as of just now (21:30 on April 18th 2013) and am seeing a similar (if not the same) problem.
To be exact, what I’m doing is replacing the left component with a custom button which, when clicked, prompts the user to confirm. If they confirm, it then calls navigateBack(), but it doesn’t appear to work. Here’s the code:
In my constructor I simply call:
setLeftComponent(createFinishButton());
And createFinishButton() looks like this:
private Component createFinishButton() {
Button button = new Button("Finish");
button.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
Button cancel = new Button("Finish");
HorizontalLayout prompt = new HorizontalLayout(cancel);
prompt.setMargin(true);
final Popover popover = new Popover(prompt);
popover.showRelativeTo(GameLobbyView.this);
cancel.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
getNavigationManager().navigateBack();
popover.close();
}
});
}
});
return button;
}
I tried to replicate the issue, but following example worked fine for me (latest SVN stuff ~ 3.0.0-beta1). If you don’t get it work, please file a ticket with a test case that we can use to reproduce the issue.
cheers,
matti
final NavigationManager manager = new NavigationManager();
final NavigationView first = new NavigationView();
final NavigationView second = new NavigationView();
second.setContent(new Label("Content"));
second.setLeftComponent(new Button("Finnish", new Button.ClickListener() {
public void buttonClick(Button.ClickEvent event) {
final Popover popover = new Popover();
VerticalLayout l = new VerticalLayout();
l.setSpacing(true);
l.addComponent(new Button("Save and go back", new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
manager.navigateBack();
popover.close();
}
}));
l.addComponent(new Button("Cancel", new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
popover.close();
}
}));
popover.setContent(l);
popover.showRelativeTo(event.getButton());
}
}));
NavigationButton c = new NavigationButton("Go to second level",second);
VerticalComponentGroup verticalComponentGroup = new VerticalComponentGroup();
verticalComponentGroup.addComponent(c);
first.setContent(verticalComponentGroup);
manager.navigateTo(first);
I was using alpha5, then tried the snapshot but vaadin:compile said it was up to date and didn’t do anything. So just to be sure I’m trying this beta and forcing a recompile.
Gwt maven plugin and our fork of it does bit bad job in that up to date detection in some cases. I most often have -Dgwt.compiler.force=true parameter in my eclipse launch. I trust myself more than gwt plugin to know when the compilation is actually needed