cancel
Showing results for 
Search instead for 
Did you mean: 

Reg: Removing duplicate values in context attribute.

Former Member
0 Kudos

Hi

I have a context node Vn_Node and Va_att is the attribute for it.

I am binding values to Va_att at runtime. How can i eliminate duplicates like if i get 3,3,3,10 in Va_att, I want only 3,10 to be there in Va_att.

Kindly suggest.

Accepted Solutions (0)

Answers (9)

Answers (9)

Former Member
0 Kudos

I didnt understand. Do u mean that for the same code i have written i need to add this for removing

Former Member
0 Kudos

can anybody suggest me what is the correct procedure to remove the duplicate values...

Former Member
0 Kudos

Hi,

to remove the elements from the node use the below code,

IPrivate<name>View.I<name>Node iNode = wdContext.node<name>Node();

for (int i = iNode.size(); i > 0; i--) {

iNode.removeElement(iNode.getElementAt(i - 1));

}

Regards,

ramesh

Former Member
0 Kudos

No, Its not giving the correct result.

Former Member
0 Kudos

if i put n=1, if it has duplicate values its working fine. Otherwise its not working.

former_member192434
Active Contributor
0 Kudos

Change M value not N.... see my above posting

Leave n as it is

Former Member
0 Kudos

Hi,

Instead of removing duplicate elements from the context node you can try to add only unique values to the context.

Just create the Set with the values, which u r getting dynamically, and then add this set values to node attributes.

I hope it solves your problem

Thanks

Former Member
0 Kudos

No, It removed all 3's.

former_member192434
Active Contributor
0 Kudos

Then make it m value 1 not zero

Former Member
0 Kudos

Hi,

In my case i have values in my att like 3,3,3,10. But I want to remove the repeated 3's.

When i use the following code it removes only one 3 and final values in my context after executing below code are 3,3,10.

Kindly suggest.

for(int m=0;m<wdContext.nodeVn_dlr3_1().size();m++)

{

for(int n=m1;n<wdContext.nodeVn_dlr3_1().size();n+)

{

if(wdContext.nodeVn_dlr3_1().getVn_dlr3_1ElementAt(m).getVa_dlr3_1().equals(wdContext.nodeVn_dlr3_1().getVn_dlr3_1ElementAt(n).getVa_dlr3_1()))

{

IWDNodeElement nodeelement=wdContext.nodeVn_dlr3_1().getVn_dlr3_1ElementAt(n);

wdContext.nodeVn_dlr3_1().removeElement(nodeelement);

}

}

}

former_member192434
Active Contributor
0 Kudos

Hi

Try this

for(int n=m; n<wdContext.nodeVn_dlr3_1().size();n++)

Instead of m+1 try only m

Thanks

former_member205363
Contributor
0 Kudos

Hi,

To filter duplicate values you can create new Node Vn_Node_Filtered and attribute Va_att_Filtered with filtered data and make use of this node.

IPrivateView.IVn_Node Model_node = wdContext.nodeFromModel();

IPrivateView.IVn_Node_Filtered Finalnode = wdContext.nodeVn_Node_Filtered();

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

int value = Model_node.getElementAt(i);

boolean flag=true;

for(int j=0;j<Finalnode.size() && flag == true;j++){

if(value == Finalnode.getElementAt(j)){

flag = false;

}

}

if(true){

addElement in FilteredNode = value.

}

}

Regards,

Lakshmi Prasad.

Former Member
0 Kudos

Hi,

Can u just post your code how are you binding values to attribute at runtime like are you using ArrayList or what, such that it will be easy to suggest you a solution or else i think the following code will help you

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

{

if(wdContext.currentVnNodeElement().getVaAttr()==wdContext.VnNode().getVnNodeElementAt(i).getVaAttr())

{

wdComponentAPI().getMessageManager().reportSuccess("you have entered duplicate values");

}

else

create the element and bind the element to node

}

Regards

Raghu