Hello i have spring micorservices with multiple UI, like in your docu:
https://vaadin.com/microservices/learn/ui-composition
Every Microservice comes with his own UI.
The Application has a LoginView with an InitListener, all is ok.
I have a MainView
@HtmlImport("frontend://styles/shared-styles.html")
@Viewport("width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes")
@Theme(value = Lumo.class)
@Route("")
public class MainView extends HorizontalLayout implements RouterLayout {
private static final long serialVersionUID = 1L;
private HorizontalLayout topNavigation;
private Button homeButton;
private Button mailButton;
private Button userButton;
public MainView() {
topNavigation = new HorizontalLayout();
Div header = new Div(topNavigation);
add(header);
}
@PostConstruct
void init() {
homeButton = new Button();
homeButton.addClickListener(e -> {
homeButton.getUI().ifPresent(view -> view.navigate("HomeView"));
});
mailButton = new Button("Email");
mailButton.addClickListener(e -> {
mailButton.getUI().ifPresent(view -> view.navigate("MailView"));
});
...
topNavigation.add(homeButton, mailButton, userButton);
}
}
In my MainView i have a Navigation on Top with Buttons, here homeButton, mailButton, userButton.
When i login succesfully and navigate to the HomeView with my homeButton all went well:
@Route(value = "HomeView", layout = MainView.class)
@PageTitle("Home")
public class HomeView extends VerticalLayout {
@Autowired
I18nProvider v18;
private static final long serialVersionUID = 1L;
public static final String VIEW_NAME = "HomeView";
public HomeView() {
initView();
Label label = new Label("About, das ist der Text zum anzeigen, danach kommt ein Logo");
add(label);
}
private void initView() {
setDefaultHorizontalComponentAlignment(Alignment.STRETCH);
}
}
With the mailButton i navigate to MailView.
In MailView i call with an iFrame-Hack the UI of my Microservice.
@Route(value = "MailView", layout = MainView.class)
@PageTitle("Mail")
public class MailView extends VerticalLayout {
private static final long serialVersionUID = 1L;
public static final String VIEW_NAME = "MailView";
public MailView() {
initView();
String iframe = " <style>" +
"iframe {margin: 0;padding: 0;border: none;}" +
"</style>" +
"<iframe src=\"http://localhost:8081\" width=\"100%\" height=\"1100px\"></iframe> ";
Label content = new Label();
content.getElement().setProperty("innerHTML", iframe);
add(content);
}
private void initView() {
setDefaultHorizontalComponentAlignment(Alignment.STRETCH);
}
When i navigate in this way via iFrame to MailView, all is ok.
My Problem is:
When i want then again navigate via the homeButton to the HomeView then it works not.
I always come to the LoginView.