I have created a Vaadin 21 project with the Vaadin App Starter. The application uses authentication, so the user first has to login on a LoginView:
@PageTitle("Login")
@Route(value = "login")
public class LoginView extends LoginOverlay implements BeforeEnterListener {
public LoginView() {
setAction("login");
LoginI18n i18n = LoginI18n.createDefault();
i18n.setHeader(new LoginI18n.Header());
i18n.getHeader().setTitle("My App");
i18n.getHeader().setDescription("Login using user/user or admin/admin");
i18n.setAdditionalInformation(null);
setI18n(i18n);
setForgotPasswordButtonVisible(false);
setOpened(true);
}
@Override
public void beforeEnter(BeforeEnterEvent beforeEnterEvent) {
Map<String,List<String>> parametersMap = beforeEnterEvent.getLocation().getQueryParameters().getParameters();
if (parametersMap.contains("myid")) {
// Do something
}
}
}
I want to transmit an id in the URL parameters to customize the LoginView, so I added the beforeEnter method to retrieve the URL parameter. But if I open my app in the browser with the URL http://localhost:8080/login?myid=5, the beforeEnter method is called but there is no URL parameter in the parametersMap, it is empty. How it is possible to transmit a URL parameter in a LoginOverlay View?