On Tue, Dec 21, 2010 at 1:50 PM, eugenebalt <eugeneb...@yahoo.com> wrote:

>
> I have a piece of Ajax code, attached to some field (let's call it
> sourceField), which looks like this:
>
>
> sourceField.add(new AjaxFormChoiceComponentUpdatingBehavior()
> {
>
>     protected void onUpdate(AjaxRequestTarget target)
>     {
>           target.addComponent(Field2);
>     }
> }
>
>
> As you can see, Field2 is not changed in any way, it is not cleared or
> modified (so this code shouldn't really do anything).
>
> However, when this Ajax runs on changing the sourceField, the Field2's
> values get erased! Field2 is actually a CheckBoxMultipleChoice, and all the
> checkbox selections get erased as soon as I do target.addComponent().
>
> Why does this happen? Any ideas on what's causing this?
>
> (Field2 is a CheckBoxMultipleChoice, initially initialized with some list,
> and its outputMarkerId = true, to make it work with Ajax.)
>

Because you're doing this in an AJAX request that is only submitting the
value(s) of sourceField, and not Field2.  Then you repaint Field2, and it
has no values, and gets replaced on the client side.  You need to submit the
whole form or at least both fields.


-- 
Jeremy Thomerson
http://wickettraining.com
*Need a CMS for Wicket?  Use Brix! http://brixcms.org*

Reply via email to