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

selectOneRadio, backing beans and mapping (ICEfaces)

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I need to have a table with 3 radio buttons. And I need to store the value of the radio button selected on a mapping.
This is the code:



And my backing bean:


Where do I put the values (Type 1, 2 and 3) for each radio button? Is it on the selectOneRadio tag? The f:selectItems tag? The java code?

After each radio button has a value associated in case of being checked, how do I get that value from the selectItems object, so I can store it in a map?

Thanks in advance
tirwit
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Peter Fat

First of all "selectItemsForRadioButtons" function should be defined in your backing bean, in which you will create a list of selectItems as follows:

List<SelectItem> abc = new ArrayList<SelectItem>();

This list will contain SelectItem object which will inturn be initialized by a label and value. That label will be the display name for your radio button & value will be the value defined for corresponding radio button.

You can populate the list by any means, with the help of any query, or anything.
Hope this help you.

Regards
Karanjeet Singh
 
Peter Fat
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey!

The "selectItemsForRadioButtons" not being in the bean I noted after I posted, but that's not the problem. The selectItem list can also be initialized without a value or label, which I prefer since I don't want labels on my radio buttons.

The real problem is that I can't get the selected item out of the list, to store it in another place. That's what I really wanted to know. But thanks anyway!
 
Karanjit Singh
Greenhorn
Posts: 15
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Peter Pat

Okey, I got it. You just need to include the value attribute in the <ice:selectOneRadio> tag and map the same to any variable declared in the backing bean or any type of reference you want to give.

And while computation, you just need to check the value of variable which will contain the value for selected radio button.

Regards
Karanjeet Singh
 
Peter Fat
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Problem solved! (a long time ago, but only now, I had time to answer :-) )

Thank you!
 
Destiny's powerful hand has made the bed of my future. And this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic