This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JSF and the fly likes How to create default value for radio button    Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "How to create default value for radio button    " Watch "How to create default value for radio button    " New topic
Author

How to create default value for radio button

Gopu Akraju
Ranch Hand

Joined: Jan 13, 2008
Posts: 242
I would like to check one of the radio button below as default value.. How do I do that in JSF. For example I owuld like to check/select Pass as default value. Thanks.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16019
    
  20

You might like to change your display name to "Gopu Lilly".

However, in answer to your question, your problem lies in that you've defined a hardcoded display. In real life, you'd normally be setting the display from a backing bean and probably setting the backing bean from the display as well.

Like so:

The default value would be whichever value you'd initialized carBean.currentCar to. I've copied an example that uses the selectItems tag instead of individual selectItem's, but operation is identical.

Here's a good place for JSF tag usage examples:

http://www.exadel.com/tutorial/jsf/jsftags-guide.html


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to create default value for radio button