cancel
Showing results for 
Search instead for 
Did you mean: 

Removing duplicate entries in a dropdownlist

Former Member
0 Kudos

Hi Experts,

How to remove duplicate entries from dropdownlist in web dynpro java? Can someone please help me

I have maintained the data in the z table wherein the records of particular fields are repeated but when i show that record in the Web Dynpro application dropdown list, the user should only be able to view the unique data for selection of that particular field.

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member193379
Active Contributor
0 Kudos

Hi Preetam,

I think, you can use your java skills for this. You can follow any of the way as mentioned below

1. Keep all the String values into ArrayList and put a loop to find out the duplicate values and delete.
2. With less code for removing repeated string is to add ArrayList to a Set (as it will not allow duplicates) and then add the Set back to ArrayList

ArrayList hamArrList = new ArrayList();
/* Add all the data to hamArrList */
HashSet hamHSet = new HashSet();
hamHSet.addAll(hamArrList);
/* To clear ArrayList'd data */
hamArrList.clear();
/* Now add the Set back to ArrayList */
hamArrList.add(hamHSet);


Thanks,
Hamendra

Former Member
0 Kudos

Hi Hamendra,

I am new to this, so could you please elaborate this with an example so that i can understand properly.

former_member193379
Active Contributor
0 Kudos

Hi Preetam,

As I have updated above, this is the way to handle it via java code.

Thanks,

Hamendra