You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by aksarben <rw...@up.com> on 2011/11/17 18:00:37 UTC

Can't Reset Form After DropDownChoice OnChange Handled

I have a drop down choice component, and when the selection changes, I udpate
various form fields by Ajax, in the form as follows:

*public HistoryDropDown(final String id, final Map<K, ?> map, final
Component dateField, final
	TrackDetailModel model, final TrackAttribute attribute) {

	super(id, map);
	final String originalValue = model.getOriginalValue(attribute);
	add(new AjaxFormComponentUpdatingBehavior("onchange") {
		private static final long serialVersionUID = -1;
		@Override
		protected void onUpdate(final AjaxRequestTarget target) {		// When
selection changes

			final String newValue = model.getAttributeValue(attribute);	// What the
new choice?
			if (newValue.equals(originalValue)) {						// If back to original value
				dateField.setEnabled(false);							// Disable date field
				model.restoreOriginalDateAndUser(attribute);			// Restore original data
			} else {													// If changing to new value
				dateField.setEnabled(true);								// Enable date field
				model.setDefaultDateAndUser(attribute);					// Effective date = today
			}															// User = current user
			target.addComponent(dateField.getParent());					// Re-render fields
        }
    });
}
*
The updates work fine (the screen re-renders properly), but if I then click
the form's Reset button, nothing happens. I saw some other posts that said I
have to do a form.modelchanged(), but that didn't any effect.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Can-t-Reset-Form-After-DropDownChoice-OnChange-Handled-tp4080685p4080685.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: Can't Reset Form After DropDownChoice OnChange Handled

Posted by Martin Grigorov <mg...@apache.org>.
On Tue, Nov 22, 2011 at 3:17 PM, Richard W. Adams <RW...@up.com> wrote:
> Unless I misunderstand, this would erase the entire form, rather than
> reset the form fields to their original values. ???

Do whatever is the best for your logic.
If this is a "create form" then use empty Entity. Whatever 'empty'
means in your domain.
If this is an "edit form" then re-fetch the Entity from the DB by its
id and set it as model object.

>
>
>
>
> From:   Martin Grigorov <mg...@apache.org>
> To:     users@wicket.apache.org
> Date:   11/22/2011 01:15 AM
> Subject:        Re: Can't Reset Form After DropDownChoice OnChange Handled
>
>
>
> On Mon, Nov 21, 2011 at 11:30 PM, Richard W. Adams <RW...@up.com>
> wrote:
>> I've been doing a lot of Googling on this topic & found this page, which
>> seems to describe exactly the problem I'm having:
>>
>> http://www.jaxtut.com/Navigation.jsp
>>
>> It suggests calling resetFromSession(), though it doesn't give an
>> implementation & this method doesn't seem to be part of Wicket.
>>
>> Has anyone found a way to reset the form after the model has changed &
> the
>> form re-rendered thru Ajax? If there isn't a way to do this in Wicket,
> is
>> there a "Wicket wish list" to add it to?
>
> All you need is an AjaxButton with .setDefaultFormProcessing(false)
> and in its onClick(AjaxRequestTarget target) to do:
> getForm().setModelObject(new MyEntity());
> target.add(getForm());
>
> i.e. set a new empty model object for the form and all its form
> components.
>
>>
>>
>>
>> From:   Igor Vaynberg <ig...@gmail.com>
>> To:     users@wicket.apache.org
>> Date:   11/21/2011 02:18 PM
>> Subject:        Re: Can't Reset Form After DropDownChoice OnChange
> Handled
>>
>>
>>
>> I don't think the browser reset button supports ajax..
>>
>> -igor
>> On Nov 21, 2011 5:08 AM, "Richard W. Adams" <RW...@up.com> wrote:
>>
>>> The form just has a standard HTML reset button:
>>>
>>> <input wicket:id="reset-button"  type="reset"  value="Reset"  />
>>>
>>> There's no special code associated with the button. Should there be? I
>>> looked at "Wicket in Action," but it doesn't seem to address this
> issue.
>>>
>>> "RAM /abr./: Rarely Adequate Memory."
>>>
>>>
>>>
>>> From:   Igor Vaynberg <ig...@gmail.com>
>>> To:     users@wicket.apache.org
>>> Date:   11/17/2011 03:42 PM
>>> Subject:        Re: Can't Reset Form After DropDownChoice OnChange
>> Handled
>>>
>>>
>>>
>>> what does your reset code look like?
>>>
>>> -igor
>>>
>>> On Thu, Nov 17, 2011 at 9:00 AM, aksarben <rw...@up.com> wrote:
>>> > I have a drop down choice component, and when the selection changes,
> I
>>> udpate
>>> > various form fields by Ajax, in the form as follows:
>>> >
>>> > *public HistoryDropDown(final String id, final Map<K, ?> map, final
>>> > Component dateField, final
>>> >        TrackDetailModel model, final TrackAttribute attribute) {
>>> >
>>> >        super(id, map);
>>> >        final String originalValue =
> model.getOriginalValue(attribute);
>>> >        add(new AjaxFormComponentUpdatingBehavior("onchange") {
>>> >                private static final long serialVersionUID = -1;
>>> >                @Override
>>> >                protected void onUpdate(final AjaxRequestTarget
> target)
>> {
>>>              // When
>>> > selection changes
>>> >
>>> >                        final String newValue =
>>> model.getAttributeValue(attribute);     // What the
>>> > new choice?
>>> >                        if (newValue.equals(originalValue)) {
>>>                              // If back to original value
>>> >                                dateField.setEnabled(false);
>>>                                       // Disable date field
>>> >
>>>  model.restoreOriginalDateAndUser(attribute);                    //
>>> Restore original data
>>> >                        } else {
>>>                                                               // If
>>> changing to new value
>>> >                                dateField.setEnabled(true);
>>>                                              // Enable date field
>>> >
>  model.setDefaultDateAndUser(attribute);
>>>                              // Effective date = today
>>> >                        }
>>>                                                                      //
>>> User = current user
>>> >                        target.addComponent(dateField.getParent());
>>>                              // Re-render fields
>>> >        }
>>> >    });
>>> > }
>>> > *
>>> > The updates work fine (the screen re-renders properly), but if I then
>>> click
>>> > the form's Reset button, nothing happens. I saw some other posts that
>>> said I
>>> > have to do a form.modelchanged(), but that didn't any effect.
>>> >
>>> > --
>>> > View this message in context:
>>>
>>>
>>
> http://apache-wicket.1842946.n4.nabble.com/Can-t-Reset-Form-After-DropDownChoice-OnChange-Handled-tp4080685p4080685.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
>>>
>>>
>>>
>>>
>>> **
>>>
>>> This email and any attachments may contain information that is
>>> confidential and/or privileged for the sole use of the intended
>> recipient.
>>>  Any use, review, disclosure, copying, distribution or reliance by
>> others,
>>> and any forwarding of this email or its contents, without the express
>>> permission of the sender is strictly prohibited by law.  If you are not
>> the
>>> intended recipient, please contact the sender immediately, delete the
>>> e-mail and destroy all copies.
>>> **
>>>
>>
>>
>>
>> **
>>
>> This email and any attachments may contain information that is
> confidential and/or privileged for the sole use of the intended recipient.
>  Any use, review, disclosure, copying, distribution or reliance by others,
> and any forwarding of this email or its contents, without the express
> permission of the sender is strictly prohibited by law.  If you are not
> the intended recipient, please contact the sender immediately, delete the
> e-mail and destroy all copies.
>> **
>>
>
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
>
> **
>
> This email and any attachments may contain information that is confidential and/or privileged for the sole use of the intended recipient.  Any use, review, disclosure, copying, distribution or reliance by others, and any forwarding of this email or its contents, without the express permission of the sender is strictly prohibited by law.  If you are not the intended recipient, please contact the sender immediately, delete the e-mail and destroy all copies.
> **
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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


Re: Can't Reset Form After DropDownChoice OnChange Handled

Posted by "Richard W. Adams" <RW...@UP.COM>.
Unless I misunderstand, this would erase the entire form, rather than 
reset the form fields to their original values. ???




From:   Martin Grigorov <mg...@apache.org>
To:     users@wicket.apache.org
Date:   11/22/2011 01:15 AM
Subject:        Re: Can't Reset Form After DropDownChoice OnChange Handled



On Mon, Nov 21, 2011 at 11:30 PM, Richard W. Adams <RW...@up.com> 
wrote:
> I've been doing a lot of Googling on this topic & found this page, which
> seems to describe exactly the problem I'm having:
>
> http://www.jaxtut.com/Navigation.jsp
>
> It suggests calling resetFromSession(), though it doesn't give an
> implementation & this method doesn't seem to be part of Wicket.
>
> Has anyone found a way to reset the form after the model has changed & 
the
> form re-rendered thru Ajax? If there isn't a way to do this in Wicket, 
is
> there a "Wicket wish list" to add it to?

All you need is an AjaxButton with .setDefaultFormProcessing(false)
and in its onClick(AjaxRequestTarget target) to do:
getForm().setModelObject(new MyEntity());
target.add(getForm());

i.e. set a new empty model object for the form and all its form 
components.

>
>
>
> From:   Igor Vaynberg <ig...@gmail.com>
> To:     users@wicket.apache.org
> Date:   11/21/2011 02:18 PM
> Subject:        Re: Can't Reset Form After DropDownChoice OnChange 
Handled
>
>
>
> I don't think the browser reset button supports ajax..
>
> -igor
> On Nov 21, 2011 5:08 AM, "Richard W. Adams" <RW...@up.com> wrote:
>
>> The form just has a standard HTML reset button:
>>
>> <input wicket:id="reset-button"  type="reset"  value="Reset"  />
>>
>> There's no special code associated with the button. Should there be? I
>> looked at "Wicket in Action," but it doesn't seem to address this 
issue.
>>
>> "RAM /abr./: Rarely Adequate Memory."
>>
>>
>>
>> From:   Igor Vaynberg <ig...@gmail.com>
>> To:     users@wicket.apache.org
>> Date:   11/17/2011 03:42 PM
>> Subject:        Re: Can't Reset Form After DropDownChoice OnChange
> Handled
>>
>>
>>
>> what does your reset code look like?
>>
>> -igor
>>
>> On Thu, Nov 17, 2011 at 9:00 AM, aksarben <rw...@up.com> wrote:
>> > I have a drop down choice component, and when the selection changes, 
I
>> udpate
>> > various form fields by Ajax, in the form as follows:
>> >
>> > *public HistoryDropDown(final String id, final Map<K, ?> map, final
>> > Component dateField, final
>> >        TrackDetailModel model, final TrackAttribute attribute) {
>> >
>> >        super(id, map);
>> >        final String originalValue = 
model.getOriginalValue(attribute);
>> >        add(new AjaxFormComponentUpdatingBehavior("onchange") {
>> >                private static final long serialVersionUID = -1;
>> >                @Override
>> >                protected void onUpdate(final AjaxRequestTarget 
target)
> {
>>              // When
>> > selection changes
>> >
>> >                        final String newValue =
>> model.getAttributeValue(attribute);     // What the
>> > new choice?
>> >                        if (newValue.equals(originalValue)) {
>>                              // If back to original value
>> >                                dateField.setEnabled(false);
>>                                       // Disable date field
>> >
>>  model.restoreOriginalDateAndUser(attribute);                    //
>> Restore original data
>> >                        } else {
>>                                                               // If
>> changing to new value
>> >                                dateField.setEnabled(true);
>>                                              // Enable date field
>> >                               
 model.setDefaultDateAndUser(attribute);
>>                              // Effective date = today
>> >                        }
>>                                                                      //
>> User = current user
>> >                        target.addComponent(dateField.getParent());
>>                              // Re-render fields
>> >        }
>> >    });
>> > }
>> > *
>> > The updates work fine (the screen re-renders properly), but if I then
>> click
>> > the form's Reset button, nothing happens. I saw some other posts that
>> said I
>> > have to do a form.modelchanged(), but that didn't any effect.
>> >
>> > --
>> > View this message in context:
>>
>>
> 
http://apache-wicket.1842946.n4.nabble.com/Can-t-Reset-Form-After-DropDownChoice-OnChange-Handled-tp4080685p4080685.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
>>
>>
>>
>>
>> **
>>
>> This email and any attachments may contain information that is
>> confidential and/or privileged for the sole use of the intended
> recipient.
>>  Any use, review, disclosure, copying, distribution or reliance by
> others,
>> and any forwarding of this email or its contents, without the express
>> permission of the sender is strictly prohibited by law.  If you are not
> the
>> intended recipient, please contact the sender immediately, delete the
>> e-mail and destroy all copies.
>> **
>>
>
>
>
> **
>
> This email and any attachments may contain information that is 
confidential and/or privileged for the sole use of the intended recipient. 
 Any use, review, disclosure, copying, distribution or reliance by others, 
and any forwarding of this email or its contents, without the express 
permission of the sender is strictly prohibited by law.  If you are not 
the intended recipient, please contact the sender immediately, delete the 
e-mail and destroy all copies.
> **
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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




**

This email and any attachments may contain information that is confidential and/or privileged for the sole use of the intended recipient.  Any use, review, disclosure, copying, distribution or reliance by others, and any forwarding of this email or its contents, without the express permission of the sender is strictly prohibited by law.  If you are not the intended recipient, please contact the sender immediately, delete the e-mail and destroy all copies.
**

Re: Can't Reset Form After DropDownChoice OnChange Handled

Posted by Martin Grigorov <mg...@apache.org>.
On Mon, Nov 21, 2011 at 11:30 PM, Richard W. Adams <RW...@up.com> wrote:
> I've been doing a lot of Googling on this topic & found this page, which
> seems to describe exactly the problem I'm having:
>
> http://www.jaxtut.com/Navigation.jsp
>
> It suggests calling resetFromSession(), though it doesn't give an
> implementation & this method doesn't seem to be part of Wicket.
>
> Has anyone found a way to reset the form after the model has changed & the
> form re-rendered thru Ajax? If there isn't a way to do this in Wicket, is
> there a "Wicket wish list" to add it to?

All you need is an AjaxButton with .setDefaultFormProcessing(false)
and in its onClick(AjaxRequestTarget target) to do:
getForm().setModelObject(new MyEntity());
target.add(getForm());

i.e. set a new empty model object for the form and all its form components.

>
>
>
> From:   Igor Vaynberg <ig...@gmail.com>
> To:     users@wicket.apache.org
> Date:   11/21/2011 02:18 PM
> Subject:        Re: Can't Reset Form After DropDownChoice OnChange Handled
>
>
>
> I don't think the browser reset button supports ajax..
>
> -igor
> On Nov 21, 2011 5:08 AM, "Richard W. Adams" <RW...@up.com> wrote:
>
>> The form just has a standard HTML reset button:
>>
>> <input wicket:id="reset-button"  type="reset"  value="Reset"  />
>>
>> There's no special code associated with the button. Should there be? I
>> looked at "Wicket in Action," but it doesn't seem to address this issue.
>>
>> "RAM /abr./: Rarely Adequate Memory."
>>
>>
>>
>> From:   Igor Vaynberg <ig...@gmail.com>
>> To:     users@wicket.apache.org
>> Date:   11/17/2011 03:42 PM
>> Subject:        Re: Can't Reset Form After DropDownChoice OnChange
> Handled
>>
>>
>>
>> what does your reset code look like?
>>
>> -igor
>>
>> On Thu, Nov 17, 2011 at 9:00 AM, aksarben <rw...@up.com> wrote:
>> > I have a drop down choice component, and when the selection changes, I
>> udpate
>> > various form fields by Ajax, in the form as follows:
>> >
>> > *public HistoryDropDown(final String id, final Map<K, ?> map, final
>> > Component dateField, final
>> >        TrackDetailModel model, final TrackAttribute attribute) {
>> >
>> >        super(id, map);
>> >        final String originalValue = model.getOriginalValue(attribute);
>> >        add(new AjaxFormComponentUpdatingBehavior("onchange") {
>> >                private static final long serialVersionUID = -1;
>> >                @Override
>> >                protected void onUpdate(final AjaxRequestTarget target)
> {
>>              // When
>> > selection changes
>> >
>> >                        final String newValue =
>> model.getAttributeValue(attribute);     // What the
>> > new choice?
>> >                        if (newValue.equals(originalValue)) {
>>                              // If back to original value
>> >                                dateField.setEnabled(false);
>>                                       // Disable date field
>> >
>>  model.restoreOriginalDateAndUser(attribute);                    //
>> Restore original data
>> >                        } else {
>>                                                               // If
>> changing to new value
>> >                                dateField.setEnabled(true);
>>                                              // Enable date field
>> >                                model.setDefaultDateAndUser(attribute);
>>                              // Effective date = today
>> >                        }
>>                                                                      //
>> User = current user
>> >                        target.addComponent(dateField.getParent());
>>                              // Re-render fields
>> >        }
>> >    });
>> > }
>> > *
>> > The updates work fine (the screen re-renders properly), but if I then
>> click
>> > the form's Reset button, nothing happens. I saw some other posts that
>> said I
>> > have to do a form.modelchanged(), but that didn't any effect.
>> >
>> > --
>> > View this message in context:
>>
>>
> http://apache-wicket.1842946.n4.nabble.com/Can-t-Reset-Form-After-DropDownChoice-OnChange-Handled-tp4080685p4080685.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
>>
>>
>>
>>
>> **
>>
>> This email and any attachments may contain information that is
>> confidential and/or privileged for the sole use of the intended
> recipient.
>>  Any use, review, disclosure, copying, distribution or reliance by
> others,
>> and any forwarding of this email or its contents, without the express
>> permission of the sender is strictly prohibited by law.  If you are not
> the
>> intended recipient, please contact the sender immediately, delete the
>> e-mail and destroy all copies.
>> **
>>
>
>
>
> **
>
> This email and any attachments may contain information that is confidential and/or privileged for the sole use of the intended recipient.  Any use, review, disclosure, copying, distribution or reliance by others, and any forwarding of this email or its contents, without the express permission of the sender is strictly prohibited by law.  If you are not the intended recipient, please contact the sender immediately, delete the e-mail and destroy all copies.
> **
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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


Re: Can't Reset Form After DropDownChoice OnChange Handled

Posted by "Richard W. Adams" <RW...@UP.COM>.
Not sure what you mean, exactly. The only alternative I can see it to keep 
an "original" copy of the form model (assuming there IS a single) model, 
then add an onclick handler() to the reset button, then go back to the 
server, overwrite the current model with the original model, then add the 
form component to the AjaxRequestTarget so it's re-rendered. This could be 
ugly & error prone real fast, especially if all of the form fields weren't 
covered by a single model. \

Am I missing something here?




From:   Clint Checketts <ch...@gmail.com>
To:     users@wicket.apache.org
Date:   11/21/2011 03:37 PM
Subject:        Re: Can't Reset Form After DropDownChoice OnChange Handled



Yes, you can reset the form quite easily, with or without Ajax. I haven't
read the rest of the thread, but if you just reset the object that the 
form
is referencing all the fields would stay in sync and be 'reset'.

-Clint

On Mon, Nov 21, 2011 at 3:30 PM, Richard W. Adams <RW...@up.com> wrote:

> I've been doing a lot of Googling on this topic & found this page, which
> seems to describe exactly the problem I'm having:
>
> http://www.jaxtut.com/Navigation.jsp
>
> It suggests calling resetFromSession(), though it doesn't give an
> implementation & this method doesn't seem to be part of Wicket.
>
> Has anyone found a way to reset the form after the model has changed & 
the
> form re-rendered thru Ajax? If there isn't a way to do this in Wicket, 
is
> there a "Wicket wish list" to add it to?
>
>
>
> From:   Igor Vaynberg <ig...@gmail.com>
> To:     users@wicket.apache.org
> Date:   11/21/2011 02:18 PM
> Subject:        Re: Can't Reset Form After DropDownChoice OnChange 
Handled
>
>
>
> I don't think the browser reset button supports ajax..
>
> -igor
> On Nov 21, 2011 5:08 AM, "Richard W. Adams" <RW...@up.com> wrote:
>
> > The form just has a standard HTML reset button:
> >
> > <input wicket:id="reset-button"  type="reset"  value="Reset"  />
> >
> > There's no special code associated with the button. Should there be? I
> > looked at "Wicket in Action," but it doesn't seem to address this 
issue.
> >
> > "RAM /abr./: Rarely Adequate Memory."
> >
> >
> >
> > From:   Igor Vaynberg <ig...@gmail.com>
> > To:     users@wicket.apache.org
> > Date:   11/17/2011 03:42 PM
> > Subject:        Re: Can't Reset Form After DropDownChoice OnChange
> Handled
> >
> >
> >
> > what does your reset code look like?
> >
> > -igor
> >
> > On Thu, Nov 17, 2011 at 9:00 AM, aksarben <rw...@up.com> wrote:
> > > I have a drop down choice component, and when the selection changes, 
I
> > udpate
> > > various form fields by Ajax, in the form as follows:
> > >
> > > *public HistoryDropDown(final String id, final Map<K, ?> map, final
> > > Component dateField, final
> > >        TrackDetailModel model, final TrackAttribute attribute) {
> > >
> > >        super(id, map);
> > >        final String originalValue = 
model.getOriginalValue(attribute);
> > >        add(new AjaxFormComponentUpdatingBehavior("onchange") {
> > >                private static final long serialVersionUID = -1;
> > >                @Override
> > >                protected void onUpdate(final AjaxRequestTarget 
target)
> {
> >              // When
> > > selection changes
> > >
> > >                        final String newValue =
> > model.getAttributeValue(attribute);     // What the
> > > new choice?
> > >                        if (newValue.equals(originalValue)) {
> >                              // If back to original value
> > >                                dateField.setEnabled(false);
> >                                       // Disable date field
> > >
> >  model.restoreOriginalDateAndUser(attribute);                    //
> > Restore original data
> > >                        } else {
> >                                                               // If
> > changing to new value
> > >                                dateField.setEnabled(true);
> >                                              // Enable date field
> > > model.setDefaultDateAndUser(attribute);
> >                              // Effective date = today
> > >                        }
> > //
> > User = current user
> > >                        target.addComponent(dateField.getParent());
> >                              // Re-render fields
> > >        }
> > >    });
> > > }
> > > *
> > > The updates work fine (the screen re-renders properly), but if I 
then
> > click
> > > the form's Reset button, nothing happens. I saw some other posts 
that
> > said I
> > > have to do a form.modelchanged(), but that didn't any effect.
> > >
> > > --
> > > View this message in context:
> >
> >
>
> 
http://apache-wicket.1842946.n4.nabble.com/Can-t-Reset-Form-After-DropDownChoice-OnChange-Handled-tp4080685p4080685.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
> >
> >
> >
> >
> > **
> >
> > This email and any attachments may contain information that is
> > confidential and/or privileged for the sole use of the intended
> recipient.
> >  Any use, review, disclosure, copying, distribution or reliance by
> others,
> > and any forwarding of this email or its contents, without the express
> > permission of the sender is strictly prohibited by law.  If you are 
not
> the
> > intended recipient, please contact the sender immediately, delete the
> > e-mail and destroy all copies.
> > **
> >
>
>
>
> **
>
> This email and any attachments may contain information that is
> confidential and/or privileged for the sole use of the intended 
recipient.
>  Any use, review, disclosure, copying, distribution or reliance by 
others,
> and any forwarding of this email or its contents, without the express
> permission of the sender is strictly prohibited by law.  If you are not 
the
> intended recipient, please contact the sender immediately, delete the
> e-mail and destroy all copies.
> **
>



**

This email and any attachments may contain information that is confidential and/or privileged for the sole use of the intended recipient.  Any use, review, disclosure, copying, distribution or reliance by others, and any forwarding of this email or its contents, without the express permission of the sender is strictly prohibited by law.  If you are not the intended recipient, please contact the sender immediately, delete the e-mail and destroy all copies.
**

Re: Can't Reset Form After DropDownChoice OnChange Handled

Posted by Clint Checketts <ch...@gmail.com>.
Yes, you can reset the form quite easily, with or without Ajax. I haven't
read the rest of the thread, but if you just reset the object that the form
is referencing all the fields would stay in sync and be 'reset'.

-Clint

On Mon, Nov 21, 2011 at 3:30 PM, Richard W. Adams <RW...@up.com> wrote:

> I've been doing a lot of Googling on this topic & found this page, which
> seems to describe exactly the problem I'm having:
>
> http://www.jaxtut.com/Navigation.jsp
>
> It suggests calling resetFromSession(), though it doesn't give an
> implementation & this method doesn't seem to be part of Wicket.
>
> Has anyone found a way to reset the form after the model has changed & the
> form re-rendered thru Ajax? If there isn't a way to do this in Wicket, is
> there a "Wicket wish list" to add it to?
>
>
>
> From:   Igor Vaynberg <ig...@gmail.com>
> To:     users@wicket.apache.org
> Date:   11/21/2011 02:18 PM
> Subject:        Re: Can't Reset Form After DropDownChoice OnChange Handled
>
>
>
> I don't think the browser reset button supports ajax..
>
> -igor
> On Nov 21, 2011 5:08 AM, "Richard W. Adams" <RW...@up.com> wrote:
>
> > The form just has a standard HTML reset button:
> >
> > <input wicket:id="reset-button"  type="reset"  value="Reset"  />
> >
> > There's no special code associated with the button. Should there be? I
> > looked at "Wicket in Action," but it doesn't seem to address this issue.
> >
> > "RAM /abr./: Rarely Adequate Memory."
> >
> >
> >
> > From:   Igor Vaynberg <ig...@gmail.com>
> > To:     users@wicket.apache.org
> > Date:   11/17/2011 03:42 PM
> > Subject:        Re: Can't Reset Form After DropDownChoice OnChange
> Handled
> >
> >
> >
> > what does your reset code look like?
> >
> > -igor
> >
> > On Thu, Nov 17, 2011 at 9:00 AM, aksarben <rw...@up.com> wrote:
> > > I have a drop down choice component, and when the selection changes, I
> > udpate
> > > various form fields by Ajax, in the form as follows:
> > >
> > > *public HistoryDropDown(final String id, final Map<K, ?> map, final
> > > Component dateField, final
> > >        TrackDetailModel model, final TrackAttribute attribute) {
> > >
> > >        super(id, map);
> > >        final String originalValue = model.getOriginalValue(attribute);
> > >        add(new AjaxFormComponentUpdatingBehavior("onchange") {
> > >                private static final long serialVersionUID = -1;
> > >                @Override
> > >                protected void onUpdate(final AjaxRequestTarget target)
> {
> >              // When
> > > selection changes
> > >
> > >                        final String newValue =
> > model.getAttributeValue(attribute);     // What the
> > > new choice?
> > >                        if (newValue.equals(originalValue)) {
> >                              // If back to original value
> > >                                dateField.setEnabled(false);
> >                                       // Disable date field
> > >
> >  model.restoreOriginalDateAndUser(attribute);                    //
> > Restore original data
> > >                        } else {
> >                                                               // If
> > changing to new value
> > >                                dateField.setEnabled(true);
> >                                              // Enable date field
> > >                                model.setDefaultDateAndUser(attribute);
> >                              // Effective date = today
> > >                        }
> >                                                                      //
> > User = current user
> > >                        target.addComponent(dateField.getParent());
> >                              // Re-render fields
> > >        }
> > >    });
> > > }
> > > *
> > > The updates work fine (the screen re-renders properly), but if I then
> > click
> > > the form's Reset button, nothing happens. I saw some other posts that
> > said I
> > > have to do a form.modelchanged(), but that didn't any effect.
> > >
> > > --
> > > View this message in context:
> >
> >
>
> http://apache-wicket.1842946.n4.nabble.com/Can-t-Reset-Form-After-DropDownChoice-OnChange-Handled-tp4080685p4080685.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
> >
> >
> >
> >
> > **
> >
> > This email and any attachments may contain information that is
> > confidential and/or privileged for the sole use of the intended
> recipient.
> >  Any use, review, disclosure, copying, distribution or reliance by
> others,
> > and any forwarding of this email or its contents, without the express
> > permission of the sender is strictly prohibited by law.  If you are not
> the
> > intended recipient, please contact the sender immediately, delete the
> > e-mail and destroy all copies.
> > **
> >
>
>
>
> **
>
> This email and any attachments may contain information that is
> confidential and/or privileged for the sole use of the intended recipient.
>  Any use, review, disclosure, copying, distribution or reliance by others,
> and any forwarding of this email or its contents, without the express
> permission of the sender is strictly prohibited by law.  If you are not the
> intended recipient, please contact the sender immediately, delete the
> e-mail and destroy all copies.
> **
>

Re: Can't Reset Form After DropDownChoice OnChange Handled

Posted by "Richard W. Adams" <RW...@UP.COM>.
I've been doing a lot of Googling on this topic & found this page, which 
seems to describe exactly the problem I'm having:

http://www.jaxtut.com/Navigation.jsp

It suggests calling resetFromSession(), though it doesn't give an 
implementation & this method doesn't seem to be part of Wicket.

Has anyone found a way to reset the form after the model has changed & the 
form re-rendered thru Ajax? If there isn't a way to do this in Wicket, is 
there a "Wicket wish list" to add it to?



From:   Igor Vaynberg <ig...@gmail.com>
To:     users@wicket.apache.org
Date:   11/21/2011 02:18 PM
Subject:        Re: Can't Reset Form After DropDownChoice OnChange Handled



I don't think the browser reset button supports ajax..

-igor
On Nov 21, 2011 5:08 AM, "Richard W. Adams" <RW...@up.com> wrote:

> The form just has a standard HTML reset button:
>
> <input wicket:id="reset-button"  type="reset"  value="Reset"  />
>
> There's no special code associated with the button. Should there be? I
> looked at "Wicket in Action," but it doesn't seem to address this issue.
>
> "RAM /abr./: Rarely Adequate Memory."
>
>
>
> From:   Igor Vaynberg <ig...@gmail.com>
> To:     users@wicket.apache.org
> Date:   11/17/2011 03:42 PM
> Subject:        Re: Can't Reset Form After DropDownChoice OnChange 
Handled
>
>
>
> what does your reset code look like?
>
> -igor
>
> On Thu, Nov 17, 2011 at 9:00 AM, aksarben <rw...@up.com> wrote:
> > I have a drop down choice component, and when the selection changes, I
> udpate
> > various form fields by Ajax, in the form as follows:
> >
> > *public HistoryDropDown(final String id, final Map<K, ?> map, final
> > Component dateField, final
> >        TrackDetailModel model, final TrackAttribute attribute) {
> >
> >        super(id, map);
> >        final String originalValue = model.getOriginalValue(attribute);
> >        add(new AjaxFormComponentUpdatingBehavior("onchange") {
> >                private static final long serialVersionUID = -1;
> >                @Override
> >                protected void onUpdate(final AjaxRequestTarget target) 
{
>              // When
> > selection changes
> >
> >                        final String newValue =
> model.getAttributeValue(attribute);     // What the
> > new choice?
> >                        if (newValue.equals(originalValue)) {
>                              // If back to original value
> >                                dateField.setEnabled(false);
>                                       // Disable date field
> >
>  model.restoreOriginalDateAndUser(attribute);                    //
> Restore original data
> >                        } else {
>                                                               // If
> changing to new value
> >                                dateField.setEnabled(true);
>                                              // Enable date field
> >                                model.setDefaultDateAndUser(attribute);
>                              // Effective date = today
> >                        }
>                                                                      //
> User = current user
> >                        target.addComponent(dateField.getParent());
>                              // Re-render fields
> >        }
> >    });
> > }
> > *
> > The updates work fine (the screen re-renders properly), but if I then
> click
> > the form's Reset button, nothing happens. I saw some other posts that
> said I
> > have to do a form.modelchanged(), but that didn't any effect.
> >
> > --
> > View this message in context:
>
> 
http://apache-wicket.1842946.n4.nabble.com/Can-t-Reset-Form-After-DropDownChoice-OnChange-Handled-tp4080685p4080685.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
>
>
>
>
> **
>
> This email and any attachments may contain information that is
> confidential and/or privileged for the sole use of the intended 
recipient.
>  Any use, review, disclosure, copying, distribution or reliance by 
others,
> and any forwarding of this email or its contents, without the express
> permission of the sender is strictly prohibited by law.  If you are not 
the
> intended recipient, please contact the sender immediately, delete the
> e-mail and destroy all copies.
> **
>



**

This email and any attachments may contain information that is confidential and/or privileged for the sole use of the intended recipient.  Any use, review, disclosure, copying, distribution or reliance by others, and any forwarding of this email or its contents, without the express permission of the sender is strictly prohibited by law.  If you are not the intended recipient, please contact the sender immediately, delete the e-mail and destroy all copies.
**

Re: Can't Reset Form After DropDownChoice OnChange Handled

Posted by Igor Vaynberg <ig...@gmail.com>.
I don't think the browser reset button supports ajax..

-igor
On Nov 21, 2011 5:08 AM, "Richard W. Adams" <RW...@up.com> wrote:

> The form just has a standard HTML reset button:
>
> <input wicket:id="reset-button"  type="reset"  value="Reset"  />
>
> There's no special code associated with the button. Should there be? I
> looked at "Wicket in Action," but it doesn't seem to address this issue.
>
> "RAM /abr./: Rarely Adequate Memory."
>
>
>
> From:   Igor Vaynberg <ig...@gmail.com>
> To:     users@wicket.apache.org
> Date:   11/17/2011 03:42 PM
> Subject:        Re: Can't Reset Form After DropDownChoice OnChange Handled
>
>
>
> what does your reset code look like?
>
> -igor
>
> On Thu, Nov 17, 2011 at 9:00 AM, aksarben <rw...@up.com> wrote:
> > I have a drop down choice component, and when the selection changes, I
> udpate
> > various form fields by Ajax, in the form as follows:
> >
> > *public HistoryDropDown(final String id, final Map<K, ?> map, final
> > Component dateField, final
> >        TrackDetailModel model, final TrackAttribute attribute) {
> >
> >        super(id, map);
> >        final String originalValue = model.getOriginalValue(attribute);
> >        add(new AjaxFormComponentUpdatingBehavior("onchange") {
> >                private static final long serialVersionUID = -1;
> >                @Override
> >                protected void onUpdate(final AjaxRequestTarget target) {
>              // When
> > selection changes
> >
> >                        final String newValue =
> model.getAttributeValue(attribute);     // What the
> > new choice?
> >                        if (newValue.equals(originalValue)) {
>                              // If back to original value
> >                                dateField.setEnabled(false);
>                                       // Disable date field
> >
>  model.restoreOriginalDateAndUser(attribute);                    //
> Restore original data
> >                        } else {
>                                                               // If
> changing to new value
> >                                dateField.setEnabled(true);
>                                              // Enable date field
> >                                model.setDefaultDateAndUser(attribute);
>                              // Effective date = today
> >                        }
>                                                                      //
> User = current user
> >                        target.addComponent(dateField.getParent());
>                              // Re-render fields
> >        }
> >    });
> > }
> > *
> > The updates work fine (the screen re-renders properly), but if I then
> click
> > the form's Reset button, nothing happens. I saw some other posts that
> said I
> > have to do a form.modelchanged(), but that didn't any effect.
> >
> > --
> > View this message in context:
>
> http://apache-wicket.1842946.n4.nabble.com/Can-t-Reset-Form-After-DropDownChoice-OnChange-Handled-tp4080685p4080685.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
>
>
>
>
> **
>
> This email and any attachments may contain information that is
> confidential and/or privileged for the sole use of the intended recipient.
>  Any use, review, disclosure, copying, distribution or reliance by others,
> and any forwarding of this email or its contents, without the express
> permission of the sender is strictly prohibited by law.  If you are not the
> intended recipient, please contact the sender immediately, delete the
> e-mail and destroy all copies.
> **
>

Re: Can't Reset Form After DropDownChoice OnChange Handled

Posted by "Richard W. Adams" <RW...@UP.COM>.
The form just has a standard HTML reset button:

<input wicket:id="reset-button"  type="reset"  value="Reset"  />

There's no special code associated with the button. Should there be? I 
looked at "Wicket in Action," but it doesn't seem to address this issue.

"RAM /abr./: Rarely Adequate Memory." 



From:   Igor Vaynberg <ig...@gmail.com>
To:     users@wicket.apache.org
Date:   11/17/2011 03:42 PM
Subject:        Re: Can't Reset Form After DropDownChoice OnChange Handled



what does your reset code look like?

-igor

On Thu, Nov 17, 2011 at 9:00 AM, aksarben <rw...@up.com> wrote:
> I have a drop down choice component, and when the selection changes, I 
udpate
> various form fields by Ajax, in the form as follows:
>
> *public HistoryDropDown(final String id, final Map<K, ?> map, final
> Component dateField, final
>        TrackDetailModel model, final TrackAttribute attribute) {
>
>        super(id, map);
>        final String originalValue = model.getOriginalValue(attribute);
>        add(new AjaxFormComponentUpdatingBehavior("onchange") {
>                private static final long serialVersionUID = -1;
>                @Override
>                protected void onUpdate(final AjaxRequestTarget target) { 
              // When
> selection changes
>
>                        final String newValue = 
model.getAttributeValue(attribute);     // What the
> new choice?
>                        if (newValue.equals(originalValue)) {             
                              // If back to original value
>                                dateField.setEnabled(false);             
                                       // Disable date field
>                               
 model.restoreOriginalDateAndUser(attribute);                    // 
Restore original data
>                        } else {                                         
                                                               // If 
changing to new value
>                                dateField.setEnabled(true);               
                                              // Enable date field
>                                model.setDefaultDateAndUser(attribute);   
                              // Effective date = today
>                        }                                                 
                                                                      // 
User = current user
>                        target.addComponent(dateField.getParent());       
                              // Re-render fields
>        }
>    });
> }
> *
> The updates work fine (the screen re-renders properly), but if I then 
click
> the form's Reset button, nothing happens. I saw some other posts that 
said I
> have to do a form.modelchanged(), but that didn't any effect.
>
> --
> View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Can-t-Reset-Form-After-DropDownChoice-OnChange-Handled-tp4080685p4080685.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




**

This email and any attachments may contain information that is confidential and/or privileged for the sole use of the intended recipient.  Any use, review, disclosure, copying, distribution or reliance by others, and any forwarding of this email or its contents, without the express permission of the sender is strictly prohibited by law.  If you are not the intended recipient, please contact the sender immediately, delete the e-mail and destroy all copies.
**

Re: Can't Reset Form After DropDownChoice OnChange Handled

Posted by Igor Vaynberg <ig...@gmail.com>.
what does your reset code look like?

-igor

On Thu, Nov 17, 2011 at 9:00 AM, aksarben <rw...@up.com> wrote:
> I have a drop down choice component, and when the selection changes, I udpate
> various form fields by Ajax, in the form as follows:
>
> *public HistoryDropDown(final String id, final Map<K, ?> map, final
> Component dateField, final
>        TrackDetailModel model, final TrackAttribute attribute) {
>
>        super(id, map);
>        final String originalValue = model.getOriginalValue(attribute);
>        add(new AjaxFormComponentUpdatingBehavior("onchange") {
>                private static final long serialVersionUID = -1;
>                @Override
>                protected void onUpdate(final AjaxRequestTarget target) {               // When
> selection changes
>
>                        final String newValue = model.getAttributeValue(attribute);     // What the
> new choice?
>                        if (newValue.equals(originalValue)) {                                           // If back to original value
>                                dateField.setEnabled(false);                                                    // Disable date field
>                                model.restoreOriginalDateAndUser(attribute);                    // Restore original data
>                        } else {                                                                                                        // If changing to new value
>                                dateField.setEnabled(true);                                                             // Enable date field
>                                model.setDefaultDateAndUser(attribute);                                 // Effective date = today
>                        }                                                                                                                       // User = current user
>                        target.addComponent(dateField.getParent());                                     // Re-render fields
>        }
>    });
> }
> *
> The updates work fine (the screen re-renders properly), but if I then click
> the form's Reset button, nothing happens. I saw some other posts that said I
> have to do a form.modelchanged(), but that didn't any effect.
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Can-t-Reset-Form-After-DropDownChoice-OnChange-Handled-tp4080685p4080685.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