How to route to another URL with object as param

Hi,

I’m trying to navigate to a page with an object passed as a parameter, as such:

QueryParameters params = QueryParameters.simple(Collections.singletonMap("param", testObject));
UI.getCurrent().navigate("main/test", params);

However, the only acceptable types are integer, String, and long. Is there a way for me to navigate to the URL, maybe through constructor like this:

TestObject checkout = new TestObject(anotherObject, someOtherObject);
UI.getCurrent().navigate(checkout.getClass());

Or if there’s another solution, please do suggest. Thanks, and much appreciated!

I have the same situation and try to pass object but get the same error as.
It will be very nice if it becomes possible to make it generic.

Currently HasUrlParameter only supports the following parameter types: java.lang.Integer, java.lang.Boolean, java.lang.Long, java.lang.String

It will probably never be possible to pass any object as url parameter. However, there are multiple way to achieve what you need.

  1. Write the object into the UI or Session State, and read it from there again after the navigation.

  2. Pass the id of the object as the url parameter, and load it from db again in the setParameter method of the navigation target using the given id. [example]
    (https://stackoverflow.com/a/54443320/3441504)