[SalesForce] How to render VisualForce components based on default values

I am trying to render one component based on whether another one has a specific value set on a Visualforce page.

Using the following, it works fine EXCEPT on the initial load (i.e. once I start toggling the driving question, the dependent question starts hiding/showing fine).

<apex:pageBlockSection id="myId">
    <apex:inputField value="{!My_Object__c.Question_1__c}">
        <apex:actionSupport event="onchange" reRender="myId"/>
    </apex:inputField> 
    <apex:inputField value="{!My_Object__c.Dependent_Question__c}" rendered="{!My_Object__c.Question_1__c == 'Yes'}">
</apex:pageBlockSection>

"Question_1__c" is a pick-list with the values Yes and No, defaulting to Yes.

I'm wondering if there is something going on where on the initial load the value is blank until I actually select the value (or save the page).

EDIT: based on discussion below, it looks like the field is initially set to NULL. However, checking for NULL as part of the rendered expression would also mean the field would show up when the picklist it is dependent on is set to the empty "–None–" value. The question becomes whether there is a way to differentiate the NULL of the initial page load vs the NULL being set manually by a user purely in Visualforce, or if a custom controller would be require to initialize the field (which would for all intents and purposes override the "default" value set in the configuration of the field).

Best Answer

Boolean fields have three states, true, false, and null. It sounds like your picklist might be exhibiting the same issue.

Try prepopulating your object during the construction or action phase of the controller.

ie:

    public Class MyController{
         public object__c myObject__c {get;set;}
         public MyController(){
             myOjbect__c= new object__c(Question_1__c = 'Yes');
        }
    }