Following recommended best practice, what is the best way to pass/retrieve values between Views?

Hi all, I have a class called GuideCreationView. I have many other View classes that are used to populate various parts of the GuideCreationView, such as PerksSectionView, TextFieldView, ItemsSectionView, etc.

What is the best way to pass and retrieve values between these views? For example, in PerksSectionView one of the functions of this class is it allow the user to select various items from a list. Once selected, GuideCreationView needs to know this information. So far, I’ve been using getters and setters, for example:

setSelectedPerkItems(perksSectionView.getSelectedPerkItems) and passing the values up the chain like that…

…but something is telling me this might not be the right approach looking at the MVC model. What should I be doing instead?

Maybe create a spring component with session scope?

Could you expand further please if possible? I’m not entirely sure what you mean

Hello Johnny, I also struggled alot with this problem. If you want we can have a meeting next week to discuss some options.

The issue for me was not how to pass values, but to figure out what the pros/cons are with all the options available.

Mojmir was pointing out that one solution is to rely on spring session scope:

That would be amazing if we could do that!

Session scope is probably a bad idea since the data will be shared on multiple tabs in your browser.

Here you have the scopes specific to Vaadin. RouteScope might help you: Scopes | Spring | Integrations | Vaadin Docs

We’re using the Vaadin4spring eventbus,

But as you can see it is discouraged on the application level due to security issues.