1

I do not know if I missed something but I have following problem. I am using wicket 6.5.0, i have simple form there with one field. Submitting the form redirect me on the other page. When I press the back button on my browser (firefox 14) i go back to my form, but it is empty. I would like to see it in the state i submitted it.

I also noticed that if i am on the first page with form, i have version /?0. Submitting take me to the page with version /second?2, the back button take me back to the page with version /?0. Why is this happening? why i am skipping version ?1 ?

here is my code: WicketApplication.java

public class WicketApplication extends WebApplication
{       

    @Override
    public Class<? extends WebPage> getHomePage()
    {
        return HomePage.class;
    }

    @Override
    public void init()
    {
        super.init();
        mountPage("second", SecondPage.class);
    }
}

HomePage.java :

public class HomePage extends WebPage {
    private static final long serialVersionUID = 1L;

    public HomePage(final PageParameters parameters) {
        super(parameters);
        add(new SimpleForm("form"));

    }

     public final class SimpleForm extends Form<Void>
        {
        private static final long serialVersionUID = -562538189475312724L;


            private final ValueMap properties = new ValueMap();

            public SimpleForm(final String id)
            {
                super(id);
                add(new TextField<String>("field", new PropertyModel<String>(properties, "field")));
            }

            @Override
            public final void onSubmit()
            {
                    setResponsePage(new SecondPage(getPageParameters()));
            }
        }
}

HomePage.html

...
    <form wicket:id="form">
        <input type="text" wicket:id="field" value="" size="50" /> <input
            type="submit" value="submit" />
    </form>
...

Thank you for your replies.

1 Answer 1

0

When you submit, because the model has changed, the page is dirtied and wicket increases the version of the page and adds it to the Page Manager. So there is a version 1 created that you could get to by plugging in ?1. If you try it out you should see the expected value in the html wicket is sending back.

You could get around this by overriding isVersioned on your page, returning false.

From Component - isVersioned():

If a Page is not versioned then it wont track changes in its components and will use the same Page#getPageId() during its lifetime

Meaning it will serialize the dirtied page against the existing page id.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.