Good day, I wanted to create a price checking application for a local retail company. Is there a way to change parameter/variable in the URL. I ask this because the store has two locations. The item price differ base on location.
The easiest way is probably to use Vaadin’s Navigator-API and work with a View Parameter. See
https://vaadin.com/docs/-/part/framework/advanced/advanced-navigator.html#advanced.navigator.urifragment
You can use the
Navigator#navigateTo(
String navigationState
)
method and just add the parameter. For example, if the name of your store view is "
store",
then when navigating to a particular store you could have something like:
getUI().getNavigator().navigateTo("store" + "/" + "id_of_store");
This will navigate you to the store view and add the id parameter to the URL. Then in the store view implementation, read the parameter from the
ViewChangeEvent
object that is passed to the
View#enter(ViewChangeEvent event)
method such as:
[code]
@Override
public void enter(ViewChangeEvent event) {
String storeId = event.getParameters();
//… fetch prices for store and update UI
}
[/code]After this fetch the prices based on the store id and update the prices in the UI accordingly.
Hope this helps,
Goran