For Apex:SelectRadio components do they always have a default value selected when first rendered on the visualforce page and when the selectOptions are specified directly in the visualforce page as opposed to from a list binded from the Controller?

For the following code "No" is selected as default when the page loads. I do not want a default option selected. Any help on how i can achieve this would be appreciated.


<apex:selectRadio value="{!triedToReturnCall}" id="returnedCall" layout="pageDirection" borderVisible="false" required="true">
    <apex:selectOption itemValue="true" itemLabel="Yes"/>
    <apex:selectOption itemValue="false" itemLabel="No"/>


The doc states that SelectOption class is created as:

public SelectOption(String value, String label)

Hence, the value bound to the controller property triedToReturnCall will be a string. If you default (in the controller) triedToReturnCall to null, no radio button is default selected. Otherwise, SFDC looks for a match between the itemValue of the apex:selectOption and the value of triedToReturnCall to default the radio.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.