You should only need access to the Model on the Form, which you would set to 
empty, and then you have two options 

1. Get access to the TextField so you can repaint it with AjaxRequestTarget
2. Use FormComponent's IVisitor pattern to visit everything in that form to 
repaint

On Jan 26, 2010, at 8:36 PM, Flavius wrote:

> 
> 
> For anybody who's interested, I got this to work by just
> calling form.textField.setModelValue(new String[]{""});
> I had to make the fields member vars of the form, though.
> 
> If there's another cleaner way of doing it, I'd appreciate seeing it.
> 
> 
> Flavius wrote:
>> 
>> 
>> I have a panel with a form on it.  I've attached an ajaxButton to submit
>> the form.  Afterward, I want the inputs to be reset with the backing model
>> reset.  I've done a lot of refreshing with an ajax submit, but I can't
>> seem
>> to get the form's values to reset in the webpage.  The backing model seems
>> to be reset, but when I add the form (or it's individual children) to the
>> target,
>> they don't refresh.
>> 
>> I've done a variation of this where I have a repeating view up top and
>> when 
>> that row is selected, it would populate the form, but I had to put the
>> form
>> in a fragment and add the fragment to the target to get that to work.  Can
>> somebody tell me what I'm doing wrong here?
>> 
>> Thanks
>> 
>> public class MyPanel extends Panel
>> {
>>      public MyPanel(String id, Widget myWidget)
>>      {
>>              MyForm myForm = new MyForm("myForm", new MyWidget());
>>              add(myForm);
>>              add(new AjaxButton("saveLink", myForm)
>>              {
>>                      @Override
>>                      protected void onSubmit(AjaxRequestTarget target,
>> Form form)
>>                      {
>>                              //save stuff
>>                              //refresh repeating view
>>                              //now reset the form so the input fields are
>> cleared and there's
>>                              //a new backing model
>>                              form.clearInput();  //this isn't working
>>                              form.setDefaultModelObject(new MyWidget());
>> //this seems to reset the backing model, but the inputs are still popuated
>> on the page
>>                              target.addComponent(form);
>>                      }
>>              }
>>      }
>> 
>>      private MyForm myForm extends Form
>>      {
>>              public MyForm(String id, Widget myWidget)
>>              {               
>>                      TextField textField = new
>> TextField<String>("myField", new PropertyModel<String>(myWidget,
>> "myField"));
>>                      add(textField);
>>                      ...
>>              }
>>      }
>> }
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> For additional commands, e-mail: users-h...@wicket.apache.org
>> 
>> 
>> 
> 
> -- 
> View this message in context: 
> http://old.nabble.com/Resetting-a-form-after-ajax-submit-tp27318108p27334057.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
> 


To our success!

Mystic Coders, LLC | Code Magic | www.mysticcoders.com

ANDREW LOMBARDI | and...@mysticcoders.com
2321 E 4th St. Ste C-128, Santa Ana CA 92705
ofc: 714-816-4488
fax: 714-782-6024
cell: 714-697-8046
linked-in: http://www.linkedin.com/in/andrewlombardi
twitter: http://www.twitter.com/kinabalu

Eco-Tip: Printing e-mails is usually a waste.

========================================================
This message is for the named person's use only. You must not, directly or 
indirectly, use,
 disclose, distribute, print, or copy any part of this message if you are not 
the intended recipient.
========================================================

Reply via email to