Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

adding a SelectItem object at particular index position in java.util.list

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 198
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
This tiny ad will self destruct in five seconds.
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic