I am using GWTP and I found this issue.
I have this code in CustPresenter:
private List<String> dataList=new List<String>();
@Ovvrride
public onBind(){
myTextBox.setText("Test");
dataList.add("test");
}
Ok, now first time opening the page, the page show the textbox has string "Text" & the dataList has "test" value. While on that page, I hit the "Go Back" and "Go Forward" button of Web Browser (like Chrome or IE). When click "Go Back", then of cause it will show the previous page. When clicking "Go Forward" it will show the customer page & I still see the string "Text" in the textbox of customer page, but dataList has no "test" value?
What is happening?
Is it a bug of GWTP or did i do anything wrong?
Note: I am using GWT 2.50 Last year version
the onBind()
method is only called once, when you first instantiate the Presenter. So it populates the TextBox
and dataList
as you want.
Then when you click back and go forward again what you are seeing is the View
that was populated by the first call to onBind()
. Pressing forward does not run onBind()
again so maybe you are re-instantiating the ArrayList
somehow and then NOT populating it because onBind()
has already been called.
Try this:
@Override
public onBind(){
private List<String> dataList = new ArrayList<String>();
myTextBox.setText("Test");
dataList.add("test");
}
Or just change onBind()
to onReset()
or onReveal()
, as those methods get called whenever a presenter is revealed.
Someone more knowledgeable may want to correct me here though.