wood burning stoves 2.0*
The moose likes JSF and the fly likes selectOneRadio, backing beans and mapping (ICEfaces) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "selectOneRadio, backing beans and mapping (ICEfaces)" Watch "selectOneRadio, backing beans and mapping (ICEfaces)" New topic
Author

selectOneRadio, backing beans and mapping (ICEfaces)

Peter Fat
Greenhorn

Joined: Oct 18, 2010
Posts: 24
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
Karanjit Singh
Greenhorn

Joined: Oct 17, 2010
Posts: 15
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

Joined: Oct 18, 2010
Posts: 24
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

Joined: Oct 17, 2010
Posts: 15
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

Joined: Oct 18, 2010
Posts: 24
Problem solved! (a long time ago, but only now, I had time to answer :-) )

Thank you!
 
Don't get me started about those stupid light bulbs.
 
subject: selectOneRadio, backing beans and mapping (ICEfaces)
 
Similar Threads
Problem in Icefaces Input binding attribute
Redirecting a page
How to retrieve string representation of <INPUT> value?
Page displaying in IE6 and older versions but not in Higher versions, chrome and firefox also.
JSF2 Populate SelectOneRadio with Enum values