cancel
Showing results for 
Search instead for 
Did you mean: 

How to know if CheckBox is selected/checked ?

Former Member
0 Kudos

Hi Gurus,

I have a CheckBoxGroup, so I provide the check boxes using code at runtime.

Suppose, in my context I have following, structure

                                        Fruits (Node)

                                             ---FruitName (Element)

On my view layout, I have CheckBoxGroup ( and Text property is set to Fruits.FruitName) and a 'Count' button. On click of count I want to know how many check boxes or options did I select.

I dont want to use onToggle Action and want to calculate number of options ticked only on click of Count button.

Waiting.

Thanks and Regards,

Rahul

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member185086
Active Contributor
0 Kudos

Hi,

A property called isSelected of CheckBoxGroup/CheckBoxKey can be count during loop, if true increnent it or let it be.

Hope it help.

My Best,

Satish

former_member197472
Active Participant
0 Kudos

Assign boolean attribute 'CheckFlag' to your checkbox and check as below -

 

if(wdContext.currentNode1Element().getCheckFlag())

{

.....

}

else

{

....

}

Sharathmg
Active Contributor
0 Kudos

Try :

Node fruits and elements fruitsname. Loop through the number of elements in fruits node( i.e. at runtime number fo check boxes added).

Check if the selected property of the element is enabled when the user checks the check box.

Ex:

// loop though node fruits

     // get the element

     // check if its selected

// end loop.

Regards,

Sharath

Sharathmg
Active Contributor
0 Kudos

Still, onToggle is the easiest way to do it.

Check the tutorial in the link for simpler usage of onToggle button to maybe update a context variable(of type int) and keep it incremented or decremeneted based on user check or uncheck.

If user checks, the on toggle method will be called and the int attribute is incremented. On uncheck, int attribute is decrimented.

Later if need be on button click, just display/read the value in int attribute. this should say the number if check boxes checked.

Regards,

Sharath

Former Member
0 Kudos

You can follow this document - "How to Add Dynamic Checkboxes in a Web Dynpro Java Page" by Tathagata Pal.

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/90915916-c158-2c10-6fa0-f0e25f3cc...