Wednesday, March 28, 2012

Check box group vs Hash Map in Xpage

In Client side javascript, it is a powerful script language for manipulating our DOM object.

I have a check box group in Xpages. And I added a hashMap value into that check box group.


key value
1 X
2 Y
3 Z

But I am not able to get the key's label name [1,2, 3]. I can get the X,Y,Z as values.

The following is the check Box group value in Xpage.,

<xp:checkBoxGroup id="checkBoxGroup1">
<xp:selectItem itemLabel="1" itemValue="X"></xp:selectItem>
<xp:selectItem itemLabel="2" itemValue="Y"></xp:selectItem>
<xp:selectItem itemLabel="3" itemValue="Z"></xp:selectItem>

But in backend HTML code is as follows...

<fieldset id="view:_id1:checkBoxGroup1" class="xspCheckBox"><table class="xspCheckBox">
<label><input name="view:_id1:checkBoxGroup1" value="X" type="checkbox"> 1</input></label></td>
<label><input name="view:_id1:checkBoxGroup1" value="Y" type="checkbox"> 2</input></label></td>
<label><input name="view:_id1:checkBoxGroup1" value="Z" type="checkbox"> 3</input></label></td>

So I am not to get this via its children...

So i used parentNode for finding its label name.,

Try the following is used to get the values of checkBoxGroup's Key value...

var check= document.forms[0].elements["#{id:Column}"]
var label=null;
var value1=null;
for(var i=0;i {



alert(label + "-- " +value1)

1 comment:

  1. In server side,

    return getComponent("checkBoxGroup1").getChildren().get(0).getAttributes().get("itemLabel")

    It is very useful but it is only for Manual value., It will not work with computed value.