• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Convert List<SelectItem> to an Array

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:


 
Greenhorn
Posts: 18
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.








 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic