aspose file tools*
The moose likes JSF and the fly likes select a RADIO option by default Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "select a RADIO option by default" Watch "select a RADIO option by default" New topic
Author

select a RADIO option by default

Anwarul Kabir
Greenhorn

Joined: Dec 17, 2008
Posts: 6
Hi

I have this code to produce a radio options


now it shows up in html like this
Validation: 0 Passed 0 Failed 0 Both

The problem is i want to select Both by default but i am clue less what to do.

Please help

BTW when one of the radio button gets selected the value is held here
searchBean.validationType

and this is giving the different types from an enum named validationTypes
model.ui.Lookup.validationTypes

And this is getting the label from Application Properties file
#{m[option.name]}


Please Help!
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Preset validationType to the desired default value. You can do that in for example the constructor of the bean.
Rahul Juneja
Ranch Hand

Joined: Aug 03, 2002
Posts: 425
You can do something like this.

In your view:



where f refers to:

and you bean can have something like this:



bean.setSelectedValue("Put the value you want to select from the enum or bean);

Thanks,
Rahul


Rahul Juneja
ThoughtClicks - http://techlabs.thoughtclicks.com
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Now the first value added in the array will be selected by default.
This is untrue.
Rahul Juneja
Ranch Hand

Joined: Aug 03, 2002
Posts: 425
Bauke Scholtz wrote:
Now the first value added in the array will be selected by default.
This is untrue.


You are right, I did change my statement above so that the new user who sees doesn't get confused.

Thanks,
Rahu
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
This question was already answered in the 1st reply. There is no need to repeat the answer and also not to add irrelevant information to it (the problem was not how to populate the list, but how to set a default value).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: select a RADIO option by default
 
Similar Threads
JSF SelectOneRadio and inputText
h:selectOneRadio automatically creates Table
Want a Default Selected Radio Button. What to Do?
How to create default value for radio button
default values to set for radio / pulldown lists