on 02-05-2009 11:16 PM
Hello there,
Is there a way to programmatically select checkbox group items and save them into the context.
Thanks
Srinivas
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I still can't make the check box group selected at runtime based on a comparison from a string array.
Here is the code.
String[] officeList;
officeList = wdContext.currentUser_Search_ResultsElement().getOffice_List().split(",");
int adminOfficeIndex = -1;
while(finalCheckbox.hasNext()){
adminOfficeIndex++;
String adminOffice = finalCheckbox.next().toString();
g_message_manager.reportSuccess("Admin Offices: "+adminOffice);
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++){
g_message_manager.reportSuccess("User office looping: "+i);
if(adminOffice.trim().equalsIgnoreCase(officeList<i>.trim())){
g_message_manager.reportSuccess("Match found: "+officeList<i>+": "+ adminOfficeIndex);
wdContext.nodeCheckbox_GroupList().setSelected(adminOfficeIndex, true);
break;
}
}
}
Thanks
Srinivas
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
9 | |
8 | |
6 | |
6 | |
6 | |
5 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.