• Post Reply Bookmark Topic Watch Topic
  • New Topic

Convert List<SelectItem> to an Array

 
Binnie Fabian
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good Day,

I'm new to JSF as well as this forum.

I am working on an application where in I need to populate a textarea using the value of a drop-down menu.

What I would like to do is that, if I select an item, a description of the item would display on the textarea.

I have an ArrayList<SelectItem> that has the value of my back-end and I want to convert it to an Array
so that I can get all its value and compare.

The question is "HOW?".


Thanks in advance
 
Tim Holloway
Bartender
Posts: 18408
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Binnie!

I had to deal with this exact problem just the other day. I'm sure that sophisticated solutions can be found for this problem, but in my case, the simplest approach was the most efficient:


 
Vadym Baranenko
Greenhorn
Posts: 18
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys, why you doing it so complex? Is it be easier to to something like this:

 
Binnie Fabian
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply guys...

Vadim Baranenko, how about bean for the sample you showed?

I tried your code but I'm having trouble getting the selected value because my list is an ArrayList<SelectItem>.

Thanks is advance.



 
Binnie Fabian
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good Day,

Things are working now the way I wanted. The only problem on my BB was the scope.
When I used RequestScoped, the code doesnt fire.
When I used SessionScoped, it fired.

Again, Thanks for your help and ideas.








 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!