Hi Peter, Here is how it should work: - Home page constructor is called initially without 'q' thus null - the submit makes a POST call to Form.onSubmit() (the print is not called because the page is not re-instanciated, unless it is stateless) - onSubmit() calls setResponsePage(Class, PageParameters) which causes a redirect to the Home page with the parameters you pass - HomePage's ctor is called with 'q' and a value
This is how it should be! Now you take a look and tell us where are the differences. On Mon, May 16, 2011 at 12:41 PM, Peter Karich <[email protected]> wrote: > Anybody? > > > Hi, > > > > when I'm doing [1] in 1.4.17 in a quickstart then I'm getting nice urls > > ala ?q=something e.g. for typing something in the textfield. The problem > > is that it prints two GET requests (why not POST + GET?): > > > > NOW: q = "[todo]" query=todo GET > > NOW: query=null GET > > > > In firebug I can see POST + GET: > > > > POST > > > http://localhost:8080/wicket1.4.17/?wicket:interface=:0:searchform::IFormSubmitListener > :: > > GET http://localhost:8080/wicket1.4.17/?q=test > > > > How can I avoid the second call of HomePage with query=null?? When I do > > setRedirect(false) after setResponsePage I don't get the nice url but it > > prints only one POST request with the correct parameter: > > > > NOW: q = "test" query=test POST > > > > Finally I tried to explicitely set the form method to GET: > > > > @Override protected String getMethod() { return METHOD_GET; } > > > > but then I would need to declare every url parameter as hidden field or > > can I somehow overwrite the form action with my need parameters? About a > > similar problem was blogged here [2] > > > > Could someone enlight me whats going wrong here? > > > > Regards, > > Peter. > > > > > > [1] > > public HomePage(final PageParameters parameters) { > > > > Form form = new Form("searchform") { > > @Override protected void onSubmit() { > > PageParameters pp = new PageParameters(); > > pp.add("q", query); > > // add other params from previous request > > setResponsePage(HomePage.class, pp); > > } > > }; > > add(form); > > query = parameters.getString("q"); > > TextField text = new TextField("textField", new PropertyModel(this, > > "query")); > > form.add(text); > > > > logger.info("NOW: " + parameters + " query=" + query + " " + > getMethod()); > > > > } > > > > public String getMethod() { > > return ((WebRequest) getRequest()).getHttpServletRequest().getMethod(); > > } > > > > > > [2] > > http://blog.solidcraft.eu/2010/10/wicket-form-submit-not-safe-for.html > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com <http://jweekend.com/>
