Search code examples
javawicketwicket-6

DropDownChoice and press back Button


Hi I created webapp and I have DropDownChoice (default value "A") but when I selected some item ("B") from DropDownChoice and then I do some Action (for example sumbmit) and after I press back button at browser so my DropDownChoice is selected to "B" but I want "A" because it is default value

HOW can I handle back press and set DropDownChoice on default value ???


Solution

  • Wicket keep page state even after you leave the page. If you visit the same page more than once, the state of your page is stored by Apache Wicket, and will be displayed to the user exactly before they leave the page.

    You need to clear your model.

    public class AnyPage extends WebPage{
    
    public AnyPage(PageParameters pageParameters){
        super(pageParameters);
    }
    @Override
    public void onConfigure(){
        // Clear the List of choices here
        this.listDropdown.clear();
        // set dropdown model to null
        this.setDropdown(null);
    }
    

    }

    @Override public void onConfigure(); is executed everytime your page is loaded.