So I have 2 views. Both with one textfield each. I can successfully navigate through it. But my only problem is every time I enter a certain view the data that I written on that textfield is still there. The only solution I found was using textField.setValue(“”); but according to my lead I need to avoid using setValue method. So I was thinking of there are any CloseListener method for Views?
Another problem is I’m trying to pass the value of the textField I wrote from the first view to the second view. Any solutions for that?
Your View.enter() method should initialize the view to the state you want. Alternatively, you might want to use the
Navigator.addView(String, Class) method so that the navigator creates a new clean instance of the view each time it is navigated to.
Passing values from a view to another - the best way to do this depends quite a bit on your specific use case, but you can, for instance, listen to ViewChangeEvents by adding a ViewChangeListener - the event object lets you access both of the views. Note, though, that someone might navigate to the “second” view directly via its URL - it should take into account that it might not have the information available that it expects to have.
There’s no specific use case for passing data from a view to another view. It’s just that when I click a button it should pass the data. And I’m also avoiding using Sessions on this one because it causes the whole page to reload.