[Logo] Enterprise Client Community
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
how to find out weather a checkbox is selected or not  XML
Forum Index -> Development
Author Message
kretzler

Power User

Joined: 21/11/2007 13:00:57
Messages: 73
Location: Karlsruhe
Offline

Hello,

I create many checkboxes and put this checkboxes into an arrayList. Then I want to know which checkboxes in the arrayList are checked or not.

There is some code to explain my problem.

Code:
 private ArrayList<CHECKBOXComponentTag> checkboxes = new ArrayList<CHECKBOXComponentTag>();
 
 // create checkboxes
 for (int i = 0; i < 5; i++) {
   ...
   CHECKBOXComponentTag cct = new CHECKBOXComponentTag();
   checkboxes.add(cct);
   ...
 }
 
 // which checkboxes are checked?
 for (CHECKBOXComponentTag cct : checkboxes) {
   //there is no cct.getSelected or cct.isSelected
 }
 


Cheers,

Ralph
[WWW]
CaptainCasa

Power User
[Avatar]

Joined: 21/11/2007 12:23:06
Messages: 5510
Offline

Hi Ralph,

you need to bind the checkbox value to a managed bean property. (Alway imagine doing the assembly in the layout editor). Then you check the value of the checkbox in the managed bean.

In case you have a dynamic number of checkboxes and - as consequence - you have a dynamic number of proeprties, please use the Map-binding which is part of expression language:

#{x.map.prop} is transkated into getX(), getMap(). map.get("prop").

Hope this helps you...

Björn

Björn Müller, CaptainCasa GmbH
 
Forum Index -> Development
Go to:   
Powered by JForum 2.1.6 © JForum Team