Hi!

As the first A in AJAX  stands for Asynchronous, you may hit weird results
with this solution, especially on slow internet connection. Which means
that no one guarantees that if user clicks checkbox1 and then checkbox2
answers would arrive in such a manner.

What I would do in this case - I would just write a very simple JQuery
callback which would listen to checkbox check/uncheck events and would
disable remaining checkboxes once 5 are selected, plus show warning. It is
synchronous, immediate, and the rule - max 5 - seems to be easy to employ
on the client side.

Surely we need to leave the check for 'max 5' in the onsubmit validator as
we want it to be independent of the javascript.

Regards,
Alex.

2012/7/3 Martin Grigorov <[email protected]>

> You can assign AjaxFormChoiceComponentUpdatingBehavior to the group
> and check its model object's size in #onUpdate()
>
> But this will fire Ajax requests for each and every click on the
> checkboxes.
>
> On Tue, Jul 3, 2012 at 7:09 PM, Dan12321 <[email protected]> wrote:
> > Hi,
> >
> > I have CheckGroup<User> group = new CheckGroup<User>("usersGroup", list);
> > and in repeater I add checkbox: item.add(new Check<User>("checkboxUser",
> > group));
> >
> > I have got 20 checkboxes, but I want to allow only 5 checkboxes select.
> When
> > will be selected more than 5 checkboxes, it shows error (in feedback).
> > I want to check this when the checkbox is selected (not after submitting
> > form).
> > Could help me, how can I do it?
> >
> > Thanks.
> >
> > --
> > View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/chekbox-allow-only-5-selected-tp4650340.html
> > Sent from the Users forum mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [email protected]
> > For additional commands, e-mail: [email protected]
> >
>
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>


-- 
Alexander Cherednichenko

[ the only way out is the way up ]

Reply via email to