Dear Forum,
On implementing prevent-multiple-form-submits, ch 2 - Wicket Cookbook, I
found that when calling
getToken() {
return new FormToken(getPage().getPageReference(),
getPageRelativePath());
}
I get an error on getPage() because the current form doesn't have a page or
parent with a page.
I'll explain my layout.
I have a main page containing panels for navigating, instead of replacing
pages, I replace panels:
public class HomePage extends WebPage {
private Panel currentPanel = homePanel;
public HomePage(final String id, final Class<HomePage> c){
add(currentPanel);
...
currentPanel.replaceWith(createPersonPanel);
currentPanel = createPersonPanel;
}
I have a createPerson panel and declared it in the following manner:
public class CreatePersonPanel extends Panel {
..
public CreatePersonPanel(String id, WebPage parent){
add( new EventForm( "createPersonForm", (IModel<Person>) getDefaultModel() )
);
}
And I also have the form which is an extension of SubmitOnceForm described
on the Apache Wicket cookbook:
private class PersonForm extends SubmitOnceForm<Event> {
...
}
I noticed that that when I call getParent() inside CreatePersonPanel, that
throws an exception so maybe it's the way I am declaring my panels and
forms.
How can I solve this problem?
I got around it, but I haven't solved it.
process(IFormSubmittingComponent submittingComponent) on SubmitOnceForm
class calls updateProcessedForms(); and super.process(submittingComponent)
if the form hasn't been processed, so I changed the order of the above so
that it calls super.process(submittingComponent) FIRST, and then
updateProcessedForms();
That way getParent() inside getToken() doesn't throw an error any more and
the functionality works. Great!
Now, the confusing thing is that, after I created a person, if I go back
from the view person panel to the create person panel, the fields I have
entered are blank.
The blank fields happen only once. If I fill in the fields again, they stay
filled.
How can I have it so that after having created a person, if I go back the
fields are not blank?
Does it have anything to do with the order I am calling functions inside
SubmitOnceForm.process()?
Could it be with the way I am binding the fields: new
PropertyModel<String>(person,"description") ?
I do apologise for the lenghty post and thanks for looking into this long
post.
Lucas
--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/Wicket-Cookbook-preventing-multiple-form-submits-tp3535159p3535159.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]