You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by ruchi <ru...@gmail.com> on 2011/07/02 13:10:16 UTC

resetting form components

Hi, 

im taking input from user in the form components and trying to reset them
when they are shown next time, i have tried doing form.clearInput(), i have
also set model values to blank, and also done form.modelChanged() after
setting the default model. 
i have also specifically set the nameField.setModelValue(new String[] {""});
but nothings working. 
please could somebdy tell me what im doing wrong, here's the code snippet: 

im doing the following on button submit after my all other processing: 

model.setName(""); 
model.setDesc(""); 
model.getProducts().clear(); 
createTemplateForm.clearInput(); 
reateTemplateForm.setDefaultModelObject(new CreateTemplateModel()); 
createTemplateForm.modelChanged(); 
nameField.setModelValue(new String[] {""}); 
descField.setModelValue(new String[] {""}); 

thanks in advance 

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/resetting-form-components-tp3640382p3640382.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: resetting form components

Posted by Andrea Del Bene <ad...@ciseonweb.it>.
You should   add form reference to Ajax target.

target.addComponent(form)


Remeber to call setOutputMarkupId on form instance.
> thanks it worked but how do i refresh the ManageAATemplatePanel now?
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/resetting-form-components-tp3640382p3643093.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
>
>
>


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


Re: resetting form components

Posted by ruchi <ru...@gmail.com>.
thanks it worked but how do i refresh the ManageAATemplatePanel now?

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/resetting-form-components-tp3640382p3643093.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: resetting form components

Posted by Andrea Del Bene <an...@libero.it>.
Hi,

you should not recreate the whole ManageAATemplatePanel each time you 
submit your form.
In this way in addition to waste memory and cpu time, you are not able 
to update your form and components via AJAX because you replace them 
with new instances.
So adding your form to ajaxrequesttarget has no effect because in the 
meantime you have replaced it with a new one.
Try to refactor your code in order to avoid replacing your panels with 
new instance and simply update them  via AJAX.

> i did this target.addComponent(createTemplateForm);
> but still its not clearing.
>
> i actually have one page which has one panel(manageAATemplatePanel), this
> panel has one ajaxLink and one dailog(createDialog). On click of link this
> dialog box opens which contains one panel(createAATemplatePanel). The
> createAATemplatePanel contains a form and an ajaxButton. inside onSubmit of
> this button im doing some processing and want to clear the form inputs.
> after clearing the form input im refreshing the manageAATemplatePanel by
> doing new ManageAATemplatePanel("rightPanel") which will do following in its
> constructor
>
>   final Dialog createDialog = new Dialog("dialogPanel");
> 		createDialog.setCssClass("noTitleDialog");
> 		createDialog.setModal(true).setWidth(850).setHeight(475)
> 				.setOutputMarkupId(true).setMarkupId("create");
> 		createDialog.setAutoOpen(false);
>
> 		Panel createPanel = new CreateAATemplate("createAATemplatePanel");
> 		createDialog.add(createPanel);
>
> 		manageTemplateForm.add(createDialog);
> so actually im creating an altogether new createAATemplatePanel and which
> should not have any previous values but it still comes up with the
> previously filled values
>
> pls guide
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/resetting-form-components-tp3640382p3641651.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
>
>


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


Re: resetting form components

Posted by ruchi <ru...@gmail.com>.
i did this target.addComponent(createTemplateForm);
but still its not clearing.

i actually have one page which has one panel(manageAATemplatePanel), this
panel has one ajaxLink and one dailog(createDialog). On click of link this
dialog box opens which contains one panel(createAATemplatePanel). The
createAATemplatePanel contains a form and an ajaxButton. inside onSubmit of
this button im doing some processing and want to clear the form inputs.
after clearing the form input im refreshing the manageAATemplatePanel by
doing new ManageAATemplatePanel("rightPanel") which will do following in its
constructor

 final Dialog createDialog = new Dialog("dialogPanel");
		createDialog.setCssClass("noTitleDialog");
		createDialog.setModal(true).setWidth(850).setHeight(475)
				.setOutputMarkupId(true).setMarkupId("create");
		createDialog.setAutoOpen(false);

		Panel createPanel = new CreateAATemplate("createAATemplatePanel");
		createDialog.add(createPanel);

		manageTemplateForm.add(createDialog);
so actually im creating an altogether new createAATemplatePanel and which
should not have any previous values but it still comes up with the
previously filled values

pls guide  

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/resetting-form-components-tp3640382p3641651.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: resetting form components

Posted by vineet semwal <vi...@gmail.com>.
add form to ajaxrequesttarget in onsubmit so that form and its
formcomponents are rendered again

On Sun, Jul 3, 2011 at 1:16 PM, ruchi <ru...@gmail.com> wrote:
> yes the button im using is ajaxButton, could you pls expalin a bit what do u
> mean by adding form to ajaxrequesttarget.
>
> thanks
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/resetting-form-components-tp3640382p3641614.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
>
>



-- 
thank you,

regards,
Vineet Semwal

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


Re: resetting form components

Posted by ruchi <ru...@gmail.com>.
yes the button im using is ajaxButton, could you pls expalin a bit what do u
mean by adding form to ajaxrequesttarget.

thanks

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/resetting-form-components-tp3640382p3641614.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: resetting form components

Posted by vineet semwal <vi...@gmail.com>.
then it should work unless you are using ajaxbutton  if you are ...
add form in ajaxrequesttarget in button..

On Sun, Jul 3, 2011 at 12:23 PM, ruchi <ru...@gmail.com> wrote:
> yes i have debugged it, all the other code inside the onSubmit of button is
> executed perfectly fine.
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/resetting-form-components-tp3640382p3641578.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
>
>



-- 
thank you,

regards,
Vineet Semwal

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


Re: resetting form components

Posted by ruchi <ru...@gmail.com>.
yes i have debugged it, all the other code inside the onSubmit of button is
executed perfectly fine.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/resetting-form-components-tp3640382p3641578.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: resetting form components

Posted by Andrea Del Bene <an...@libero.it>.
HI,

are you sure that button submit is executed? Have you debugged it? Maybe 
the code is not executed because form has some validation errors...
> Hi,
>
> im taking input from user in the form components and trying to reset them
> when they are shown next time, i have tried doing form.clearInput(), i have
> also set model values to blank, and also done form.modelChanged() after
> setting the default model.
> i have also specifically set the nameField.setModelValue(new String[] {""});
> but nothings working.
> please could somebdy tell me what im doing wrong, here's the code snippet:
>
> im doing the following on button submit after my all other processing:
>
> model.setName("");
> model.setDesc("");
> model.getProducts().clear();
> createTemplateForm.clearInput();
> reateTemplateForm.setDefaultModelObject(new CreateTemplateModel());
> createTemplateForm.modelChanged();
> nameField.setModelValue(new String[] {""});
> descField.setModelValue(new String[] {""});
>
> thanks in advance
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/resetting-form-components-tp3640382p3640382.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
>
>


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