You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "Richard W. Adams" <RW...@UP.COM> on 2012/11/15 21:13:37 UTC
No Ajax Model Update in FormComponentPanel
I have a drop down choice in a FormComponentPanel, and & need to update
other parts of the panel when the user changes the selected value in the
drop down. My panel class is defined as:
PointLocationPanel extends FormComponentPanel<PointLocation>
Its constructor begins like this:
public PointLocationPanel(final String id, final IModel<PointLocation>
model,
final String boxTitle, final MapURL mapURL) {
super(id, model);
setType(PointLocation.class);
...
This is the method where I create the drop down.
private SubdivisionDropDown createSubdivisionDropdown() {
final SubdivisionDropDown dropdown = new SubdivisionDropDown
(SUBDIVISION, new PropertyModel<Integer>(this, SUBDIVISION
));
dropdown.add(new AjaxFormComponentUpdatingBehavior(ONCHANGE) {
private static final long serialVersionUID =
-1285532100134482101L;
/*
* When the user picks a different subdivision, update the
segment
* drop down list to show segments in the newly chosen
subdivision.
*/
@Override protected void onUpdate(final AjaxRequestTarget
target) {
final Integer newSubdivision =
getModelObject().getSubdivision();
smrDropdown.update(newSubdivision);
target.addComponent(smrDropdown);
}
});
return dropdown;
}
However, when the onUpdate() method is called & I call
getModelObject.getSubdivision(), it returns the old value, not the newly
selected one. Can anyone see what I'm doing wrong?
Our app runs under Wicket 1.4.17.
**
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: No Ajax Model Update in FormComponentPanel
Posted by "Richard W. Adams" <RW...@UP.COM>.
You were right, Sven. It was that simple! Sometimes I can't see the forest
for the trees.
From: Sven Meier <sv...@meiers.net>
To: users@wicket.apache.org
Date: 11/15/2012 03:41 PM
Subject: Re: No Ajax Model Update in FormComponentPanel
> final Integer newSubdivision = getModelObject().getSubdivision();
You're using the wrong model object, this should be:
final Integer newSubdivision = dropdown.getModelObject();
or:
final Integer newSubdivision = PointLocationPanel.this.subdivision
Sven
On 11/15/2012 09:13 PM, Richard W. Adams wrote:
> I have a drop down choice in a FormComponentPanel, and & need to update
> other parts of the panel when the user changes the selected value in the
> drop down. My panel class is defined as:
>
> PointLocationPanel extends FormComponentPanel<PointLocation>
>
> Its constructor begins like this:
>
> public PointLocationPanel(final String id, final IModel<PointLocation>
> model,
> final String boxTitle, final MapURL mapURL) {
>
> super(id, model);
> setType(PointLocation.class);
> ...
>
> This is the method where I create the drop down.
>
> private SubdivisionDropDown createSubdivisionDropdown() {
>
> final SubdivisionDropDown dropdown = new SubdivisionDropDown
> (SUBDIVISION, new PropertyModel<Integer>(this,
SUBDIVISION
> ));
> dropdown.add(new AjaxFormComponentUpdatingBehavior(ONCHANGE) {
> private static final long serialVersionUID =
> -1285532100134482101L;
> /*
> * When the user picks a different subdivision, update
the
> segment
> * drop down list to show segments in the newly chosen
> subdivision.
> */
> @Override protected void onUpdate(final
AjaxRequestTarget
> target) {
> final Integer newSubdivision =
> getModelObject().getSubdivision();
> smrDropdown.update(newSubdivision);
> target.addComponent(smrDropdown);
> }
> });
> return dropdown;
> }
>
> However, when the onUpdate() method is called & I call
> getModelObject.getSubdivision(), it returns the old value, not the
newly
> selected one. Can anyone see what I'm doing wrong?
>
> Our app runs under Wicket 1.4.17.
>
> **
>
> 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.
> **
>
---------------------------------------------------------------------
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: No Ajax Model Update in FormComponentPanel
Posted by Sven Meier <sv...@meiers.net>.
> final Integer newSubdivision = getModelObject().getSubdivision();
You're using the wrong model object, this should be:
final Integer newSubdivision = dropdown.getModelObject();
or:
final Integer newSubdivision = PointLocationPanel.this.subdivision
Sven
On 11/15/2012 09:13 PM, Richard W. Adams wrote:
> I have a drop down choice in a FormComponentPanel, and & need to update
> other parts of the panel when the user changes the selected value in the
> drop down. My panel class is defined as:
>
> PointLocationPanel extends FormComponentPanel<PointLocation>
>
> Its constructor begins like this:
>
> public PointLocationPanel(final String id, final IModel<PointLocation>
> model,
> final String boxTitle, final MapURL mapURL) {
>
> super(id, model);
> setType(PointLocation.class);
> ...
>
> This is the method where I create the drop down.
>
> private SubdivisionDropDown createSubdivisionDropdown() {
>
> final SubdivisionDropDown dropdown = new SubdivisionDropDown
> (SUBDIVISION, new PropertyModel<Integer>(this, SUBDIVISION
> ));
> dropdown.add(new AjaxFormComponentUpdatingBehavior(ONCHANGE) {
> private static final long serialVersionUID =
> -1285532100134482101L;
> /*
> * When the user picks a different subdivision, update the
> segment
> * drop down list to show segments in the newly chosen
> subdivision.
> */
> @Override protected void onUpdate(final AjaxRequestTarget
> target) {
> final Integer newSubdivision =
> getModelObject().getSubdivision();
> smrDropdown.update(newSubdivision);
> target.addComponent(smrDropdown);
> }
> });
> return dropdown;
> }
>
> However, when the onUpdate() method is called & I call
> getModelObject.getSubdivision(), it returns the old value, not the newly
> selected one. Can anyone see what I'm doing wrong?
>
> Our app runs under Wicket 1.4.17.
>
> **
>
> 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.
> **
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org