cancel
Showing results for 
Search instead for 
Did you mean: 

about CheckBoxGroup.

Former Member
0 Kudos

anyone can tell how to bind (key,value) to the context of CheckBoxGroup.

For example: i have a node(named xNode) and its value attribute(xType),and bind it to the checkBoxGroup' <b>texts</b> attribute in my view.

I hope i can got following result by the following code.

<u><i>("A","OPEN") ,("B","CLOSE").</i></u>

this is to say,I need to got the real value "<i>A</i>" when "<b>OPEN</b>" is selected."<i>B</i>" value is for "<b>CLOSE</b>" selected.

<b>List list=new ArrayList();

for (int i = 0; i < wdContext.nodeXNode().size(); ++i) {

if (wdContext.nodeXNode().isMultiSelected(i)) {

// do something

String temp=wdContext.nodeXNode().getXNodeElementAt(i).getXType()

list.add(temp);

}</b>

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

The CheckBoxGroup does not use key/value-pairs (see Javadoc). It uses a context node (cardinality 0:N, selection 0:N) and an attribute A that stores the texts.

Just use a second attribute B for storing a key.

Example:

Context:

Items (node, card=0:N, selection=0:N)
-- Text (attribute, string)
-- Key (attribute, string)

Binding:

CheckBoxGroup.texts -> Items.Text

Create items:

{
  IItemsElement item = wdContext.nodeItems().createItemsElement();
  wdContext.nodeItems().addElement(item);
  item.setKey("A");
  item.setValue("Open");
}
{
  IItemsElement item = wdContext.nodeItems().createItemsElement();
  wdContext.nodeItems().addElement(item);
  item.setKey("B");
  item.setValue("Close");
}

Get selection:

for (int i = 0; i < wdContext.nodeItems().size(); ++i)
{
  if (wdContext.nodeItems().isMultiSelected(i))
  {
    String selectedKey = wdContext.nodeItems().getItemsElementAt(i).getKey();
  }
}

Armin

Answers (0)