> This means that your freshly created page instance loads data from a source
> which "caches" its data. E.g. your EntityFactory does not always return a
> fresh instance.
> 
> So the first question is: how do you link to your "Add a record" page?

Bas,

You are definitely describing the stateful nature of the behavior I'm seeing.  
I'm linking to add a record as follows:

Link<String> addJobLink = new Link<String>("addJobLink"){

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick() {
                        setResponsePage(new JobAddPage());
                }
                        
};

Mike

-----Original Message-----
From: Bas Gooren [mailto:b...@iswd.nl] 
Sent: Tuesday, February 19, 2013 9:20 AM
To: users@wicket.apache.org
Subject: Re: Forms do not reset after submit

Hi!

What you describe should only happen in certain cases:

- when you link to the page using a stored reference e.g.

in ctor:
myTargetPage = new MyTargetPage()

in click handler:
setResponsePage(myTargetPage);

This results in a single, shared page instance. The page will keep track of 
state, and thus the state is shared.

- when you create a new page instance (bookmarkable or not doesn't
matter) for every click, but it's data comes from a static source (page-static, 
session-based or other)

This means that your freshly created page instance loads data from a source 
which "caches" its data. E.g. your EntityFactory does not always return a fresh 
instance.

So the first question is: how do you link to your "Add a record" page?

Met vriendelijke groet,
Kind regards,

Bas Gooren

Op 19-2-2013 17:12, schreef Michael Chandler:
> Good morning all!  I thought I had a good handle on an issue I was having, 
> but it appears as though that problem is persisting.  When I present a form 
> to the user to collect information that saves on a domain object, the form 
> does not reset after the form has been submitted.  At first, I thought it was 
> related to how I link to pages, then I became convinced it was my use of a 
> LoadableDetachableModel.  Now, after refactoring the code several times, I'm 
> convinced that I have over-looked something simple but I cannot figure out 
> what it is.
>
> To summarize, I have a form that binds to an object as follows:
>
> CompoundPropertyModel<Job> jobModel = new 
> CompoundPropertyModel<Job>((Job) 
> EntityFactory.getInstance().getBean("job"));
> jobForm.setModel(jobModel);
>
> When the form fields are all completed and the form is submitted, the form's 
> onSubmit() successfully handles the submission and my implementation persists 
> the data to my domain object (Job) and the data is confirmed in the database. 
>  The last line conducts a redirect to the main screen with a 
> setResponsePage() call.
>
> When I click the link to add a new record to the database using the same 
> form, the form fields are populated with all of the same data I just entered, 
> suggesting to me that the previous domain object is still bound to that page 
> instead of refreshing and binding a clean, new instance of the Job class.
>
> Can anyone offer any tips or suggestions on what I am doing wrong?
>
> Best,
>
> Mike
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to