unfortunately in this case the model is different in both cases.

--------------------------------------------------
From: "Maurice Marrink" <[EMAIL PROTECTED]>
Sent: Friday, May 09, 2008 2:16 PM
To: <users@wicket.apache.org>
Subject: Re: Form onSubmit called after Page components created

Personally i would not worry about the dual load. Usually hibernate or
even the database itself can cache these calls efficiently enough.
But if you must an alternative could be a model that gets the
information once and then does not detach it like a common
detachablemodel does, however since you are using statelesspages the
model should persist the data in the session and then next time the
statelesspage is created get it from the session instead of making the
database call. Note that you have to be very careful when storing
hibernate objects like this in the session. It certainly is not an
elegant solution just another option you could explore, it has the
added benefit that you do not have to tackle those pageparams
yourself.

just my 2c

Maurice

On Fri, May 9, 2008 at 1:07 PM, Joel Halbert <[EMAIL PROTECTED]> wrote:
Hi Igor,

Yes I take your point about being able to replace components within the
onSubmit, that's certainly a good option in some cases.

However - in the scenario that I'm looking there are components in the page
that initialise themselves dynamically from a database model. What's
happening  now is that they initialise themselves once when the page and
components are first created (some default arrangement say) and then during the onSubmit they need to be set up again, based on the values submitted in the form. This then means that the database is accessed twice, and not once,
and I'm trying to avoid multiple database access.

(actually to get around this for the time being I'm not using the forms
onSubmit() to access the form values, instead I'm reading directly off the PageParameters object when the page is first created, which avoids the dual
load issue described above, but it seems like a bit of a hack as I don't
feel I'm leveraging the framework correctly)

Cheers,
Joel

--------------------------------------------------
From: "Igor Vaynberg" <[EMAIL PROTECTED]>
Sent: Friday, May 09, 2008 3:03 AM
To: <users@wicket.apache.org>
Subject: Re: Form onSubmit called after Page components created

the stateless stuff has to recreate the component hierarchy first - eg
the form instance has to exist before you can call onsubmit on it :)

however, inside onsubmit you can do any component replacement you
want, just like in a non-stateless page.

-igor


On Thu, May 8, 2008 at 4:36 PM, Joel Halbert <[EMAIL PROTECTED]>
wrote:

Hi,

I've noticed that when submitting a (stateless) Form page the onSubmit() method of the form is only called once all the Page components have all been
created, and likewise any model objects relating to the form are only
populated once the page components have been rendered.

This means that it is hard to create dynamic content in the page that is dependent on the contents of the submitted form without "reloading the page"
using
 setResponsePage(MyPage.class, pageParams) at the end of the onSubmit()
call of the form.

Has anyone else noticed this and is there a way around it? i.e. can the
models be populated before the page components are created?

 Rgs
 Joel



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to