Re: Processing a form before page components are created
On Wed, May 14, 2008 at 8:24 AM, Joel Halbert <[EMAIL PROTECTED]> wrote: > unless, i suppose, if you override getPageParameters, something like this: > >private void getLinkToUserProfile(final RatingModel r) { >return new BookmarkablePageLink("username", > ViewDetails.class) { >@Override >public PageParameters getPageParameters() { >PageParameters pp = new PageParameters(); >pp.put(Params.userId.toString(), > r.getRating().getUserId()); >return pp; >} > >}; >} Right, something like that. Eelco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Processing a form before page components are created
On Wed, May 14, 2008 at 8:21 AM, Joel Halbert <[EMAIL PROTECTED]> wrote: > What about the situation where one of the components on the Page is a > BookmarkeablePageLink and you need to pass it in some PageParameters? In > this case how do you load the page parameters from the model in a lazy > fashion? It doesn't appear to be possible since PageParameters does not > evaluate against a model, thus the values need to be supplied upfront, while > the page is being created... But you don't have to load the page parameters lazily, right? Eelco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Processing a form before page components are created
unless, i suppose, if you override getPageParameters, something like this: private void getLinkToUserProfile(final RatingModel r) { return new BookmarkablePageLink("username", ViewDetails.class) { @Override public PageParameters getPageParameters() { PageParameters pp = new PageParameters(); pp.put(Params.userId.toString(), r.getRating().getUserId()); return pp; } }; } -- From: "Joel Halbert" <[EMAIL PROTECTED]> Sent: Wednesday, May 14, 2008 4:21 PM To: Subject: Re: Processing a form before page components are created What about the situation where one of the components on the Page is a BookmarkeablePageLink and you need to pass it in some PageParameters? In this case how do you load the page parameters from the model in a lazy fashion? It doesn't appear to be possible since PageParameters does not evaluate against a model, thus the values need to be supplied upfront, while the page is being created... -- From: "Joel Halbert" <[EMAIL PROTECTED]> Sent: Wednesday, May 14, 2008 12:57 PM To: Subject: Re: Processing a form before page components are created I take your point, thanks for the pointer. -- From: "Eelco Hillenius" <[EMAIL PROTECTED]> Sent: Wednesday, May 14, 2008 1:31 AM To: Subject: Re: Processing a form before page components are created The reason I want to do this is that my pages are stateless, and I want to process the submitted form before all the components on the page are initialised, incase I need to load different data models, or redirect the request to another page, thus saving unnecessary database calls and component initialisation. At the moment what I am doing is processing the form by directly reading the page parameters in the constructor before I add any components to the page, and then redirecting the request or initializing the page as appropriate (bypassing the use of Form.onSubmit). If you make sure your models/ components work lazily you can avoid database calls being done until the components are actually rendered. Rendering is a separate phase executing after component construction and form handling. And you can let your form just populate a simple bean to avoid database access. I wouldn't worry about the creation of a few components, and you can break of any time with a RestartResponseException or set the next page (without breaking off current processing) using setResponsePage. Eelco - 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]
Re: Processing a form before page components are created
What about the situation where one of the components on the Page is a BookmarkeablePageLink and you need to pass it in some PageParameters? In this case how do you load the page parameters from the model in a lazy fashion? It doesn't appear to be possible since PageParameters does not evaluate against a model, thus the values need to be supplied upfront, while the page is being created... -- From: "Joel Halbert" <[EMAIL PROTECTED]> Sent: Wednesday, May 14, 2008 12:57 PM To: Subject: Re: Processing a form before page components are created I take your point, thanks for the pointer. -- From: "Eelco Hillenius" <[EMAIL PROTECTED]> Sent: Wednesday, May 14, 2008 1:31 AM To: Subject: Re: Processing a form before page components are created The reason I want to do this is that my pages are stateless, and I want to process the submitted form before all the components on the page are initialised, incase I need to load different data models, or redirect the request to another page, thus saving unnecessary database calls and component initialisation. At the moment what I am doing is processing the form by directly reading the page parameters in the constructor before I add any components to the page, and then redirecting the request or initializing the page as appropriate (bypassing the use of Form.onSubmit). If you make sure your models/ components work lazily you can avoid database calls being done until the components are actually rendered. Rendering is a separate phase executing after component construction and form handling. And you can let your form just populate a simple bean to avoid database access. I wouldn't worry about the creation of a few components, and you can break of any time with a RestartResponseException or set the next page (without breaking off current processing) using setResponsePage. Eelco - 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]
Re: Processing a form before page components are created
I take your point, thanks for the pointer. -- From: "Eelco Hillenius" <[EMAIL PROTECTED]> Sent: Wednesday, May 14, 2008 1:31 AM To: Subject: Re: Processing a form before page components are created The reason I want to do this is that my pages are stateless, and I want to process the submitted form before all the components on the page are initialised, incase I need to load different data models, or redirect the request to another page, thus saving unnecessary database calls and component initialisation. At the moment what I am doing is processing the form by directly reading the page parameters in the constructor before I add any components to the page, and then redirecting the request or initializing the page as appropriate (bypassing the use of Form.onSubmit). If you make sure your models/ components work lazily you can avoid database calls being done until the components are actually rendered. Rendering is a separate phase executing after component construction and form handling. And you can let your form just populate a simple bean to avoid database access. I wouldn't worry about the creation of a few components, and you can break of any time with a RestartResponseException or set the next page (without breaking off current processing) using setResponsePage. Eelco - 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]
Re: Processing a form before page components are created
> The reason I want to do this is that my pages are stateless, and I want to > process the submitted form before all the components on the page are > initialised, incase I need to load different data models, or redirect the > request to another page, thus saving unnecessary database calls and > component initialisation. > > At the moment what I am doing is processing the form by directly reading > the page parameters in the constructor before I add any components to the > page, and then redirecting the request or initializing the page as > appropriate (bypassing the use of Form.onSubmit). If you make sure your models/ components work lazily you can avoid database calls being done until the components are actually rendered. Rendering is a separate phase executing after component construction and form handling. And you can let your form just populate a simple bean to avoid database access. I wouldn't worry about the creation of a few components, and you can break of any time with a RestartResponseException or set the next page (without breaking off current processing) using setResponsePage. Eelco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]