You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please provide an additional overload for navigation: UI.navigate(Class, Object, QueryParameters) and also a static factory QueryParameters.of(String, String) so that the code can read:
Also provide QueryParameters.toString() and equals()/hashCode(), similar to RouteParameters.
Alternatives considered
QueryParameter.simple() still needs a map even though it's a bit better; QueryParameter.fromString() could work but will suffer from escaping issues.
For the massive UI.navigate() overload - perhaps a builder pattern could help? Not sure though, they all require a trailing go() call, which, when omitted, will simply run no navigation - that will be a frequent source of bugs. Not recommended:
@mstahv while you are currently cleaning up the router api ;) This could probably be a really interesting small topic for you as well with a huge benefit in DX.
I partly agree :) With your addition really complex objects can be easily exchanged without leveraging the URLs - that's true! But there are still use-cases where a bookmark-able URLs with query parameter are desired, like for example online portals with deep linking, search or filtering forms.
Now I actually figured out what the second object in UI.navigate(Class, Object, QueryParameters)was. @mvysny is using both "route parameters" and query parameters at the same time.
@mstahv That would work very well for my use-case, thank you. While you're working on it, could you please add:
hashCode()/equals()/toString() for QueryParameters
navigate(BookingFreightView.class, QueryParameters.of("prev_view", prevView.name())); - parameterless navigation which would help for other use-cases. Even though this will most probably clash with other navigate() overloads.
Having proper equals and hashCode methods could probably be really helpful for the upcoming unit testbench to allow checking of params before and after navigation
Added tests, PR ready. At the enhancement didn't come directly from needs, would appreciate if @mvysny & @knoobie can check the improvements are as expected!
Activity
knoobie commentedon Jun 21, 2022
@mstahv while you are currently cleaning up the router api ;) This could probably be a really interesting small topic for you as well with a huge benefit in DX.
mstahv commentedon Jun 22, 2022
Let's consider 😎 I noticed in my previous patch that working with QueryParameter would indeed have some low hanging fruits for DX enhancements.
@mvysny What is the Object in
UI.navigate(Class, Object, QueryParameters)that you are proposing?mstahv commentedon Jun 22, 2022
BTW. I'd guess the code examples by @mvysny might not be there if the latest patch was already in a release 🤓
knoobie commentedon Jun 22, 2022
I partly agree :) With your addition really complex objects can be easily exchanged without leveraging the URLs - that's true! But there are still use-cases where a bookmark-able URLs with query parameter are desired, like for example online portals with deep linking, search or filtering forms.
mstahv commentedon Jun 22, 2022
There sure is! And even if the "new approach was used" one might still want to update the deep linking URL and use QueryParameters with enhanced API.
mstahv commentedon Jun 22, 2022
Now I actually figured out what the second object in
UI.navigate(Class, Object, QueryParameters)was. @mvysny is using both "route parameters" and query parameters at the same time.mvysny commentedon Jun 22, 2022
Eh, sorry, my bad, typing too fast. It's the parameter for the view. Should be
Tor something :)Improving UX of Query parameters
mstahv commentedon Jun 22, 2022
@mvysny Would this work 🤔 Didn't test yet or write any tests, just drafted the APIs and implementation. #14034
mstahv commentedon Jun 22, 2022
Looks like
navigate(Class,QueryParameters)is missing as well. Should maybe add that in the same UX improvement patch as well 🤔mvysny commentedon Jun 22, 2022
@mstahv That would work very well for my use-case, thank you. While you're working on it, could you please add:
navigate(BookingFreightView.class, QueryParameters.of("prev_view", prevView.name()));- parameterless navigation which would help for other use-cases. Even though this will most probably clash with othernavigate()overloads.mstahv commentedon Jun 22, 2022
Added the missing navigate method.
Why do you need the equals/hashCode implementations? toString definitely would ease debugging.
mstahv commentedon Jun 22, 2022
toString ✅
knoobie commentedon Jun 22, 2022
Having proper equals and hashCode methods could probably be really helpful for the upcoming unit testbench to allow checking of params before and after navigation
mstahv commentedon Jun 22, 2022
Fair enough. Added simple solution delegating to the parameter maps.
mstahv commentedon Jun 23, 2022
Added tests, PR ready. At the enhancement didn't come directly from needs, would appreciate if @mvysny & @knoobie can check the improvements are as expected!
mvysny commentedon Jun 23, 2022
Looks perfect from my side, thanks a ton @mstahv
feat: Improving UX of Query parameters (#14034)
vaadin-bot commentedon Sep 7, 2022
This ticket/PR has been released with Vaadin 23.2.0.