| Author |
adding a SelectItem object at particular index position in java.util.list
|
srikanth Thandra
Ranch Hand
Joined: Mar 04, 2009
Posts: 39
|
|
Hi All,
I am having a Select Box in JSF with select options like Gender,Employee,Associate.
Now select box list contains 3 items with index 0 -- Gender,index 1 -- Employee and index 3 -- Associate.
Based on our requirement when user selects a select item and clicks a button i need to delete the selected option from select box i.e if user selects Employee and submits, select box shows only Gender And Associate.
Now what i want is, can the deleted Employee object will be added back at the same index position as it is like before when a previous button is clicked.
Up to now what i have done i am maintaining two lists one parent list and another selected items list.When user selects one item from parent list and clicks submit button i am removing the selected item from parent list and adding it into selected items list.
When user clicks previous button i am removing from the selected items list and adding into the parent list. But the added one is coming at last position
|
Thanx in advance,
Srikanth
|
 |
Manoj Kumar Jain
Ranch Hand
Joined: Aug 22, 2008
Posts: 153
|
|
I am not sure if I am addressing your problem but what I understand from your query I can suggest you one solution.
You need to maintain one more master list that is having all the list items in order you want, don't remove any item on selection from this list.
Initially show all the items from this master list. when user clicks on the submit button the logic will almost remain same, but when when user clicks on previous button just check your master list with the selected list. Now show the items form the master list. If masterlist.item==selectedlist.item then skip that item from showing in the box. also update your parent list at this time with the current items.
|
Do not wait to strike till the iron is hot; but make it hot by striking....
|
 |
 |
|
|
subject: adding a SelectItem object at particular index position in java.util.list
|
|
|