You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "Kogel, Jonck-van-der" <jo...@bmw.nl> on 2010/01/06 14:03:18 UTC

DropDownChoice losing selection after ajax update

Hi,
 
I have a simple DropDownChoice that holds male/female option. The
selected value is retrieved from the database fine. Now I have a modal
panel and when it closes it refreshes a certain portion of my screen
using ajax. However, when the ajax refresh comes back the selected value
gets lost. When I look in the ajax debug screen I see the list of
options coming back and the selected value is empty. This happens even
when I don't do anything with the value of the dropdown in the modal
panel, but simply refresh the dropdown. Any ideas? Here is some code:
 
The dropdown: (the list of options is an enum, mergedModel is a
LoadableDetatchableModel)
 
DropDownChoice<Sex> sex = new DropDownChoice<Sex>("sex",
  new PropertyModel<Sex>(mergedModel, "user.sex"), 
  Utility.arrayToList(new Sex[]{Sex.MALE, Sex.FEMALE}));
sex.setOutputMarkupId(true);
add(sex);
 
What happens when I close the modal panel: (the contentPanel gets passed
a reference to the modalPanel and the objects that need refreshing)
 
form.add(new AjaxSubmitLink("save") {
 @Override
 protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
  for (Component comp : updateList) {
   target.addComponent(comp);
  }
  modalWindow.close(target);
 }
});
 
The ajax response:
 
<?xml version="1.0" encoding="UTF-8"?><ajax-response><component
id="sex11" ><![CDATA[<select name="tabs:tabUser:sex" id="sex11">
<option selected="selected" value="">Kies er een</option>
<option value="0">Man</option>
<option value="1">Vrouw</option>
</select>]]>
 
 
 
Thanks for any help!
 
Kind regards, Jonck
 

RE: DropDownChoice losing selection after ajax update

Posted by "Kogel, Jonck-van-der" <jo...@bmw.nl>.
Martin thank you!! It was indeed the form in the ModalWindow causing the error. I thought that nested forms was not an issue with Wicket but I guess it is? Anyway, replacing the form on the ModalWindow with the one you suggested works like a charm. Thanks again! 

-----Original Message-----
From: Martin Makundi [mailto:martin.makundi@koodaripalvelut.com] 
Sent: woensdag 6 januari 2010 14:11
To: users@wicket.apache.org
Subject: Re: DropDownChoice losing selection after ajax update

There can be many reasons... maybe you show more of the html and java pages? Here is some previous discussion about such situations:
http://mail-archives.apache.org/mod_mbox/wicket-users/200904.mbox/%3C23274595.post@talk.nabble.com%3E

2010/1/6 Kogel, Jonck-van-der <jo...@bmw.nl>:
> Hi,
>
> I have a simple DropDownChoice that holds male/female option. The 
> selected value is retrieved from the database fine. Now I have a modal 
> panel and when it closes it refreshes a certain portion of my screen 
> using ajax. However, when the ajax refresh comes back the selected 
> value gets lost. When I look in the ajax debug screen I see the list 
> of options coming back and the selected value is empty. This happens 
> even when I don't do anything with the value of the dropdown in the 
> modal panel, but simply refresh the dropdown. Any ideas? Here is some code:
>
> The dropdown: (the list of options is an enum, mergedModel is a
> LoadableDetatchableModel)
>
> DropDownChoice<Sex> sex = new DropDownChoice<Sex>("sex",
>  new PropertyModel<Sex>(mergedModel, "user.sex"),
>  Utility.arrayToList(new Sex[]{Sex.MALE, Sex.FEMALE})); 
> sex.setOutputMarkupId(true); add(sex);
>
> What happens when I close the modal panel: (the contentPanel gets 
> passed a reference to the modalPanel and the objects that need 
> refreshing)
>
> form.add(new AjaxSubmitLink("save") {
>  @Override
>  protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
>  for (Component comp : updateList) {
>   target.addComponent(comp);
>  }
>  modalWindow.close(target);
>  }
> });
>
> The ajax response:
>
> <?xml version="1.0" encoding="UTF-8"?><ajax-response><component
> id="sex11" ><![CDATA[<select name="tabs:tabUser:sex" id="sex11"> 
> <option selected="selected" value="">Kies er een</option> <option 
> value="0">Man</option> <option value="1">Vrouw</option> </select>]]>
>
>
>
> Thanks for any help!
>
> Kind regards, Jonck
>
>

---------------------------------------------------------------------
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: DropDownChoice losing selection after ajax update

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
There can be many reasons... maybe you show more of the html and java
pages? Here is some previous discussion about such situations:
http://mail-archives.apache.org/mod_mbox/wicket-users/200904.mbox/%3C23274595.post@talk.nabble.com%3E

2010/1/6 Kogel, Jonck-van-der <jo...@bmw.nl>:
> Hi,
>
> I have a simple DropDownChoice that holds male/female option. The
> selected value is retrieved from the database fine. Now I have a modal
> panel and when it closes it refreshes a certain portion of my screen
> using ajax. However, when the ajax refresh comes back the selected value
> gets lost. When I look in the ajax debug screen I see the list of
> options coming back and the selected value is empty. This happens even
> when I don't do anything with the value of the dropdown in the modal
> panel, but simply refresh the dropdown. Any ideas? Here is some code:
>
> The dropdown: (the list of options is an enum, mergedModel is a
> LoadableDetatchableModel)
>
> DropDownChoice<Sex> sex = new DropDownChoice<Sex>("sex",
>  new PropertyModel<Sex>(mergedModel, "user.sex"),
>  Utility.arrayToList(new Sex[]{Sex.MALE, Sex.FEMALE}));
> sex.setOutputMarkupId(true);
> add(sex);
>
> What happens when I close the modal panel: (the contentPanel gets passed
> a reference to the modalPanel and the objects that need refreshing)
>
> form.add(new AjaxSubmitLink("save") {
>  @Override
>  protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
>  for (Component comp : updateList) {
>   target.addComponent(comp);
>  }
>  modalWindow.close(target);
>  }
> });
>
> The ajax response:
>
> <?xml version="1.0" encoding="UTF-8"?><ajax-response><component
> id="sex11" ><![CDATA[<select name="tabs:tabUser:sex" id="sex11">
> <option selected="selected" value="">Kies er een</option>
> <option value="0">Man</option>
> <option value="1">Vrouw</option>
> </select>]]>
>
>
>
> Thanks for any help!
>
> Kind regards, Jonck
>
>

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