Form fields change value when returning back using back button

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Form fields change value when returning back using back button

Marius Anton
Hello guys.

   I have a form containing an address(with fields for city, country, etc), and inside this form a DropDownChoice,
containing a list of Addresses.
   I am using AjaxFormComponentUpdatingBehavior to update the form fields when the user changes the address from drop down.
   
   The code looks like this :
   
  _addressesSelect.add(new AjaxFormComponentUpdatingBehavior("onchange") {
      @Override
      protected void onUpdate(AjaxRequestTarget target) {
        updateForm(_addressesSelect.getModelObject());
        target.addComponent(AddressForm.this);
      }
    });
   
   Everything works fine, the form fields are updated with the values taken from the address that is selected in the DropDown.
After the user submits the form, it is redirected to a new page.

   The problem appears if the user hits the back button.
After returning to the page that contains the form by pressing the back button,
the form is populated not with the values from the drop down, but with the values that where first there when the page loaded.

   Can someone help me what am I doing wrong? Please tell me if I should provide more information.
   
   Have a god day,
      Anton Marius