Skip to Content
avatar image
Former Member

Automate check box group selections.

Hello there,

Is there a way to programmatically select checkbox group items and save them into the context.

Thanks

Srinivas

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Feb 06, 2009 at 05:19 AM

    Hi,

    Check the below code

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

    {

    wdContext.nodeColor().setSelected(i, true);

    }

    this will give you all the checkboxes to true. You can make your own condition.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Srinivas,

      You are doing the selection part completely wrong.

      wdContext.nodeCheckbox_GroupList().setSelected(adminOfficeIndex, true);

      .

      The above code will not select a check box. This is used to select elements in a table.

      First you have to check to which attributes the checkboxes are bound in the context. Let us know the context structure.

      You should also know that Checkbox will take data only from the lead selected element of the context node. For instance you have a context node Checkbox_GroupList. The node should have a cardinality 1:1. If you have six checkboxes then you need to have six attributes of type boolean in that node. Each checkbox's checked property need to be bound to an attribute in the node Checkbox_GroupList node.

      For selecting the checkbox the code should be some thing like this.

      wdContext.nodeCheckbox_GroupList().currentCheckbox_GroupListElement().setCheckBox1(true);

      Like wise all the six attribute values need to be checked.

      In your case I guess you are comparing the attribute value with the contents of an array. If you know exactly what the names in officeList array is going to be then you can name the context attribute with the exact name then use your code like this,

      String[] officeList;
      			officeList = wdContext.currentUser_Search_ResultsElement().getOffice_List().split(",");	
      		int adminOfficeIndex = -1;	
      		while(finalCheckbox.hasNext()){			
      			adminOfficeIndex++;
      			String adminOffice = finalCheckbox.next().toString();		;		
      				IPublicRepNetAdminComp.ICheckbox_GroupListElement officeNames =
      						wdContext.createCheckbox_GroupListElement();
      				wdContext.nodeCheckbox_GroupList().addElement(officeNames);	
      				officeNames.setGroup_Names(adminOffice);
      							//loop through user group to compare, if present make the selection
      				for(int i =0; i < officeList.length ; i++){	
      					if(adminOffice.trim().equalsIgnoreCase(officeList<i>.trim())){
      						wdContext.nodeCheckbox_GroupList().currentCheckbox_GroupListElement().setAttributeValue(adminOffice.trim(), Boolean(true));
      						break;
      					}								
      				}
      		}

      Make sure that you make the node Checkbox_GroupList cardinality 1:1 and name the attributes exactly the values in officeList.

      Sanyev

  • avatar image
    Former Member
    Feb 06, 2009 at 03:54 AM

    Hi,

    u can write code like this

    wdContext.currentContextElement().setCheck(true);

    here check is the value attribute of type boolean. That attribute should be mapped to the checkbox property checked.

    Regards,

    H.V.Swathi

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Thanks for your replies. Although, I didn't quite understand.

      Here is my context

      CheckBoxList (node)

      |

      >Value (attribute)

      In the run time I have say 6 check boxes in this group. Now I have to make 3 of those check boxes checked. How should I write the code.

      Regards

      Srinivas

  • avatar image
    Former Member
    Feb 06, 2009 at 02:16 AM

    Hi Srinivas,

    The IWDCheckBox has a mandatory property called checked which is bound to a boolean value. If you change the value of the boolean attribute to true programmatically at runtime then you can make the checkbox checked. So you have to set the boolean value to true to all the concerned checkboxes.

    Regards,

    Sanyev

    Add comment
    10|10000 characters needed characters exceeded