You could use Wicket for the generation of the ids like you said. I
would create a grouping component - maybe it prints the 'header' like
'Person 1' - that you have to add your checkboxes to. This grouping
component would contribute some generic javascript function (one
script for all instances should be doable) that e.g. takes the ids of
the checkboxes to switch. Or maybe you could even make some smarter
use of DOM; I'm not a big javascript expert. Anyway, you then to let
the individual checkboxes call this function in their onselect
handlers. Generate that calling code e.g. by attaching an attribute
modifier. You probably want to extend from CheckBox too, so instead of
using attribute modifiers you can also decide to do this in
onComponentTag.

Eelco

On 10/17/05, Johannes Fahrenkrug <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have the following listview:
>
> Person 1
>
> [ ]   No insurance
> [ ]   insurance 1
> [ ]   insurance 2
> [ ]   insurance 3
>
>
> Person 2
>
> [ ]   No insurance
> [ ]   insurance 4
> [ ]   insurance 5
> [ ]   insurance 6
>
>
> Person 3
>
> [ ]   No insurance
> [ ]   insurance 7
> [ ]   insurance 8
> [ ]   insurance 9
>
> Every person can book individual insurances (because they depend on the
> price per person).
> I'd like to do this: When a person selects "No insurance", all the other
> insurances for that person should be unchecked, using JavaScript. When a
> person selects one of the insurances, though, the "No insurance"
> checkbox should be unchecked.
>
> I know Wicket has JavaScript support to some degree. What would be the
> best solution? I don't think Ajax would make sense. But on the other
> hand, it's not so easy to identify the checkboxes that should be
> unchecked, because the names are being generated at runtime. Maybe there
> is an elegant way to dynamically generate ids for the checkboxes. They
> could consist of the number of the person and the number to the checkbox
> field. And I'd call the JS function with the id of the checked checkbox
> as a parameter, ie:
>
> onSelect="uncheckBoxes(this.id)"
> where id might be "0-0" for the first person and the first checkbox (the
> "No insurance" one) or "2-1" for the 3rd person and the 2nd checkbox....
>
> I don't know, what would be the most elegant way to go?
>
> - Johannes.
>
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by:
> Power Architecture Resource Center: Free content, downloads, discussions,
> and more. http://solutions.newsforge.com/ibmarch.tmpl
> _______________________________________________
> Wicket-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to