You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Vishal Popat <vi...@cipriati.co.uk> on 2014/06/25 22:32:44 UTC

Model data lost when calling target.add before onSubmit

Hi,

I have two panels added to a form. The idea is to create a step 1, step 2 type functionality where after clicking next on panel 1, it hides and shows Panel 2.

I have a checkbox on Panel 1
		add(new CheckBox("single", new PropertyModel(SelectionPanel.this, "single")));

and I have the following link
		add(new AjaxLink("next") {
			@Override
			public void onClick(AjaxRequestTarget target) {
				panel1.add(new AttributeModifier("style", new Model<String>("display:none")));
				target.add(panel1);
					
				JQueryEffectBehavior effectBehavior = new JQueryEffectBehavior("#panel2", "slide", slideOptions, 400);
				target.appendJavaScript(effectBehavior.toString());
				target.add(panel2);
			}
		});

I submit the form using AjaxButton on panel2 where I log out the PropertyModel data. The data shows the defaults for single in panel1 but is fine for any data in Panel2

I have narrowed it down to when I call target.add(panel1) in the onClick.

Does this call clear any Model data that has not been submitted?

Regards
Vishal
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Model data lost when calling target.add before onSubmit

Posted by vp143 <vi...@cipriati.co.uk>.
Many thanks!
I solved my original issue using AjaxWizardButtonBar which I was not aware
of as I was using an older version of Wicket.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Model-data-lost-when-calling-target-add-before-onSubmit-tp4666385p4666458.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Model data lost when calling target.add before onSubmit

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

The browser doesn't send any data for form elements which are not visible.
When clicking the AjaxLink you make panel1 invisible (display:none). The
following form submit submits only the visible form elements, thus empty
value is set to the checkbox's model.

Martin Grigorov
Wicket Training and Consulting


On Wed, Jun 25, 2014 at 11:32 PM, Vishal Popat <vi...@cipriati.co.uk>
wrote:

> Hi,
>
> I have two panels added to a form. The idea is to create a step 1, step 2
> type functionality where after clicking next on panel 1, it hides and shows
> Panel 2.
>
> I have a checkbox on Panel 1
>                 add(new CheckBox("single", new
> PropertyModel(SelectionPanel.this, "single")));
>
> and I have the following link
>                 add(new AjaxLink("next") {
>                         @Override
>                         public void onClick(AjaxRequestTarget target) {
>                                 panel1.add(new AttributeModifier("style",
> new Model<String>("display:none")));
>                                 target.add(panel1);
>
>                                 JQueryEffectBehavior effectBehavior = new
> JQueryEffectBehavior("#panel2", "slide", slideOptions, 400);
>
> target.appendJavaScript(effectBehavior.toString());
>                                 target.add(panel2);
>                         }
>                 });
>
> I submit the form using AjaxButton on panel2 where I log out the
> PropertyModel data. The data shows the defaults for single in panel1 but is
> fine for any data in Panel2
>
> I have narrowed it down to when I call target.add(panel1) in the onClick.
>
> Does this call clear any Model data that has not been submitted?
>
> Regards
> Vishal
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>