Hi
I am new to Vaadin, trying to learn Vaadin CDI following the examples and webinar by Matti Tahvonen. The example applications runs well and i have added few more views to it. After login successfully, when I call the Viewgetting exception. Is there anything wrong in my following navigation code? Thanks for any help.
@CDIView("country")
public class CountryTableView extends MHorizontalLayout implements View {
@Inject
CountryFacade cf;
@Inject
CountryMaddonForm form;
@Inject
UserInfo uinfo;
..................
public void enter(ViewChangeListener.ViewChangeEvent viewChangeEvent) {
if (uinfo.getName() == null){
Notification.show("Sorry, you have to login before useing this option.."+ uinfo.getName());
getUI().getNavigator().navigateTo("");
return;
}
getUI().getNavigator().navigateTo("country");
}
}
the CDI part seems OK; but why are you navigating in the enter method? the enter method is called when the user arrives at that particular view. It should be used to initialize data on that view. Nothing wrong with firing another navigation event there, I just want to know why. Also, It would be helpful if you provided relevant parts of the stacktrace you get.
Thanks for your reply. I am firing navigation event inside the enter method to direct the user to log-in page if not logged in. Is there any better way to manage this?