class Page2 extends WebPage {
public Page2(PurchaseOrder order) {
...
}
}
onsubmit() {
PurcharOrder o=getPurchaseOrder();
setResponsePage(new Page2(o));
}
this has the benefit of strong typing and simplicity over using the pageparams object to pass in the values. the pageparams constructor is used for bookmarkable pages where the parameters come from a url. its not meant to be used when page transitions are internal to wicket, for that the cosntructor params are a much better choice.
at the end its just java. your page is an ordinary object, you can pass the data in any way you want, its up to you.
-Igor
On 1/20/06, Rosenstrauch, David
<[EMAIL PROTECTED]> wrote:
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Igor Vaynberg
Sent: Friday, January 20, 2006 4:42 PM
To: [email protected]
Subject: Re: [Wicket-user] Another noob question
On 1/20/06, Rosenstrauch, David < [EMAIL PROTECTED]> wrote:Been surfing (and googling) the docs for about an hour now, but haven't found the answer to this:
In a typical web app you submit a form and (assuming it validates OK) you save the data and then navigate/forward to a different page.
How does similar functionality work in Wicket?
1) I didn't see any capability to navigate or forward (or how to use <form action="">
in the form's onsubmit or the button's onsubmit you call one of the variants of Page.setResponsePage() method
[Rosenstrauch, David]OK, thanks.
2) I wasn't clear how to get 2 different WebPage objects to access the same piece of state (other than statics/singletons). IIRC, it's frowned upon for your code to access the Session directly. How else should one do it then?
not really sure what you mean here. please explain.
[Rosenstrauch, David]Well, say I've got:class Page1 extends WebPage {}
andclass Page2 extends WebPage {}
And say that a successful submission of the form on Page1 will navigate you to Page 2.Now, say that the form submission on Page1 calculated some value or created something new (a new Purchase Order (with an ID #)) and I want Page2 to display that value. How does Page 2 get access to that object? Should I, say, put the purchase order # in the session? Or should I do something like this:
protected void onSubmit() {
Map parms = new HashMap();
parms.put("purchaseOrderNo", new Integer(orderNo ));
setResponsePage(new Page2 (new PageParameters(parms)));
}In other words, how should one best share state between 2 page objects?
Thanks,DR==============================================================================
Please access the attached hyperlink for an important electronic communications disclaimer:
http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
==============================================================================
