I don't understand your question. with the current code doing the POST is quite cheap. it just brings the value for the search to form#onSubmit and makes a redirect to HomePage(PageParameters) where you check for the existence of the 'q' parameter and either do the heavy calculation or not. You may also check StatelessForm and see whether it fits your needs. It will save you the redirect.
Otherwise you can do the calculation in form#onsubmit and use setResponsePage(new HomePage(calculationResult)) - the con here is that the url will have ?wicket:interface=......... and wont be nice looking. On Mon, May 16, 2011 at 1:34 PM, Peter Karich <[email protected]> wrote: > Hi Martin, > > thanks for the explanation! > > Why is the first call done to submit my form? > > Because my app is doing an 'expensive' search query for every > instantiation, > thus I would like to trigger the search only with the necessary > submitted query. > > Can I somehow distinguish a request with an empty q > and the pre-query with an empty q when submitting a form? > Or should I place my expensive operation somewhere else? > > Regards, > Peter. > > > 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. > > > --------------------------------------------------------------------- > 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/>
