RE: Forms do not reset after submit

2013-02-19 Thread Michael Chandler
>  And is the EntityFactory class something you've built yourself?

It is and a quick test revealed that was the culprit!  I've got some work to do 
there.  Thanks so much, Bas!

Regards,

Mike

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



RE: Forms do not reset after submit

2013-02-19 Thread Michael Chandler
> 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, following up on your second consideration, that my EntityFactory was 
caching, you were spot on.  That is exactly my problem.  Everything from a 
Wicket standpoint was good, but my EntityFactory was returning the same 
instance of that object.

Thanks for opening my eyes!  Sometimes it's the little things that nail me! :)  
A thousand thanks!

Mike


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



Re: Forms do not reset after submit

2013-02-19 Thread Bas Gooren

Mike,

That looks normal; you are creating a new JobAddPage for every click, so 
that's not the problem.


Can you share some code from the JobAddPage? And is the EntityFactory 
class something you've built yourself?


Met vriendelijke groet,
Kind regards,

Bas Gooren

Op 19-2-2013 18:37, schreef Michael Chandler:

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 addJobLink = new Link("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 jobModel = new
CompoundPropertyModel((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





RE: Forms do not reset after submit

2013-02-19 Thread Michael Chandler
> 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 addJobLink = new Link("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 jobModel = new 
> CompoundPropertyModel((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



Re: Forms do not reset after submit

2013-02-19 Thread Bas Gooren

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 jobModel = new CompoundPropertyModel((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