cancel
Showing results for 
Search instead for 
Did you mean: 

Storing Data in Context from a table (multiple selection)

Former Member
0 Kudos

Hi,

I have created a node called cauverynode, which contains cauName and cauClient as its attribute. I have bound that node with the table. Now i have to store the selected clients into a context. How can i do that? Please help me out. i am unable to store the clients in a string context. Kindly solve it. Below is the code, which will store the selected item and put into a string variable.

public void supplyCauveryNode(IPrivateSampleComponent.ICauveryNodeNode node, IPrivateSampleComponent.IContextElement parentElement)

{

//@@begin supplyCauveryNode(IWDNode,IWDNodeElement)

IPublicSampleComponent.ICauveryNodeNode cauNode =

wdContext.nodeCauveryNode();

ArrayList selectedcauClients = new ArrayList(cauNode.size());

for (int i = 0, n = cauNode.size(); i < n; ++i) {

if (cauNode.isMultiSelected(i) || i == cauNode.getLeadSelection())

{

selectedcauClients.add(cauNode.getElementAt(i));

}

}

String strSelcaucli = null;

for (int i = 0, n = selectedcauClients.size(); i < n; i++) {

strSelcaucli = strSelcaucli + selectedcauClients.get(i);

}

wdContext.currentContextElement().setStrCauveryClient(strSelcaucli);

//@@end

}

Multiple selected data is been stored in this selectedcauClients arraylist, which is not working. Kindly help me out.

Thanks & Regards,

Dhana

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

What is the following code supposed to do?

String strSelcaucli = null;
for (int ix = 0, n = selectedcauClients.size(); ix < n; ix++) {
strSelcaucli = strSelcaucli + selectedcauClients.get(ix);
}
wdContext.currentContextElement().setStrCauveryClient(strSelcaucli);

I guess you want to create a string containing the names(?) of all selected elements.

Then you should use something like

StringBuffer sb = new StringBuffer();
for (Iterator it = selectedcauClients.iterator(); it.hasNext(); ) 
{
  ICauveryNodeElement e = (ICauveryNodeElement) it.next();
  sb.append(e.getName());
  if ( it.hasNext() ) sb.append(",");
}
String csv = sb.toString();

This gives you a comma-separated list of the names of the selected elements.

Armin

Answers (2)

Answers (2)

Former Member
0 Kudos

Thank u so much

Former Member
0 Kudos

Hi Dhana,

Create a Button on the form and write the following code on Click action of the button.

Press the button after selecting the data in the table.

ArrayList selectedcauClients = new ArrayList(cauNode.size());

for (int i = 0, n = cauNode.size(); i < n; ++i) {

if (cauNode.isMultiSelected(i))

{

selectedcauClients.add(cauNode.getElementAt(i));

}

}

Regards, Anilkumar