Reputation: 5725
I have a view:
@SpringUI(path="order")
@Title("order")
public class OrderGUI extends UI{
and I would pass parameter to other:
@SpringUI(path="orderNumber")
@Title("Order number")
public class GetOrderNumber extends UI {
I tried to send parameter(orderNumber) by:
getUI().getPage().setUriFragment(orderNumber);
getUI().getPage().setLocation("orderNumber");
then it goes to /orderNumber
but when tried to catch it by:
String fragment = getPage().getUriFragment();
but
System.out.println("Fragment: " + fragment);
says that Fragment: null
How to send parameter from one Vaadin view to another?
@Edit It is close to work. I have changed my View to:
@SpringView(name = "GetOrderNumber")
@Title("Order number")
public class GetOrderNumber extends VerticalLayout implements View {
and in @SpringUI made getUI().getNavigator().navigateTo("GetOrderNumber/" + orderNumber);
it actually still throws java.lang.IllegalArgumentException: Trying to navigate to an unknown state '' and an error view provider not present
but it works. I mean all the time when I go to localhost:8080/order the
@SpringUI(path="order")
public class OrderGUI extends UI {
throws an error but then works as expected - go to view and pass parameter right. I have no idea why navigator = new Navigator(this, this);
cause an error
Upvotes: 0
Views: 580
Reputation: 10643
@SpringUI annotation defines always just the name of the view, it is not the place where you give the URI parameter, the correct place is the navigateTo(..) method, e.g.:
getUI().getNavigator().navigateTo("myview/someparameter");
There is more information about Vaadin and Spring add-on here
https://vaadin.com/docs/v8/framework/advanced/advanced-spring.html
Upvotes: 2