Page A has this code in its constructor:
                Link b = new Link("b"){
                        public void onClick(){
                             setResponsePage(B.class);
                        }
                };
                add(b);

Page B has a no-args constructor. It has a link to page A. It also has a
form (with a bit of Ajax) which takes some user input. The no args
constructor writes a debug message "In constructor of class B".

The user starts on page A, clicks the link to B, enters some data into the
form on B, clicks on the link to A and then clicks on the link on A to go
back to B; all the user's data has disappeared. 
In fact, B's constructor has been called twice. 
Is it not the case that the setResponsePage(B.class);   (as opposed to
setResponsePage(new B());)  should use the _original_ instance of B, which
was stored in the user's session (as per the perfectly reasonable post
below)?
How can I achieve the desired effect (ie not losing the user's input on
returning to B) ?
Is the only way to achieve this to manually put the user's input data into
some sort of dumb object, put that dumb object into the session, and then
pass it as a PageParameter when heading back to B ?



Alastair Maw wrote:
> 
> howzat wrote:
>> Al, that is a very helpful reply, thank you!
> 
> No problem. ;-)
> 
>> Yes, I have a lot to learn about wicket, but I know a lot more than I did
>> a
>> few days ago, and I like it so far.
> 
> Great!
> 
>> In my particular case, the page in question is the HomePage, so, since
>> the
>> user has already been there on her way to Page2, I suppose I will always
>> need to create a new instance if I want to show an alert (for example) as
>> the HomePage is visited from Page2's submit (eg user saved some data
>> entered
>> on a Page2 form by hitting submit).
>> I acheived this, albeit by dubious methods (as you kindly pointed out),
>> by
>> including an alert in the <head> of the HomePage if the constructor that
>> takes a message (eg HomePage(String successMessage)) is called using a
>> StringHeaderContributor.
>> I suppose I need to review this.
>> On the other hand, it is still a useful learning exercise, either way,
>> and I
>> will now study your post in detail before I try again, cheers.
> 
> If you wish, you can pass the home page into your Page2.
> 
> add(new Link("someId") {
>     public void onClick() {
>         setResponsePage(new Page2(HomePage.this));
>     }
> });
> 
> And take the Page arg in Page2's constructor.
> That way, you have a reference to it, and can link back to that.
> 
> It's probably better to do status alert type stuff using Wicket's
> FeedbackPanel (if it's for a form) or via some other Session-based
> mechanism, though.
> 
> Have fun playing.
> 
> Regards,
> 
> 
> Al
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user
> 
> 

-- 
View this message in context: 
http://www.nabble.com/HomePage-url-changes-when-user-returns-from-a-second-wicket-page-tf3732701.html#a11160780
Sent from the Wicket - User mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to