function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jonathan ConradJonathan Conrad 

Dynamic bindings in controller don't work

I have the following Apex codes that works just fine as a static object, but I need to build a collection of these dynamically in a controller.  When I try to build the exact same thing in the code, I get very weird results.

Here's the Apex code that works fine:
<apex:PageBlockTable value="{!tableRows}" var="row">
                <apex:column value="{!row.question.question__c}"/> 
                <apex:column headerValue="Response">
                    <apex:selectList size="1" id="status" value="{!row.quote.Quantity__c}" multiselect="false" rendered="{!IF(row.question.answerType__c=='Yes/No', 'true','false')}">
                        <apex:selectOption itemLabel="Yes" itemValue="1"/>
                        <apex:selectOption itemLabel="No" itemValue="0"/>
                    </apex:selectList>
                    <apex:inputField type="number" required="false" value="{!row.quote.Quantity__c}" rendered="{!IF(row.question.answerType__c=='Numeric', 'true','false')}"/>
                </apex:column>    
                <apex:column value="{!row.question.tip__c}"/>
            </apex:PageBlockTable>


Here is the controller code that isn't working:

public Component.Apex.PageBlockTable getSurveyTable()
    {
        Component.Apex.PageBlockTable table = new Component.Apex.PageBlockTable(value=tableRows, var='row');
        
        //Question Column
        Component.Apex.Column qColumn = new Component.Apex.Column();
        qColumn.expressions.value = '{!row.question.question__c}';
        table.childComponents.add(qColumn);
        
        //Response Column
        Component.Apex.Column rColumn = new Component.Apex.Column();
        rColumn.headerValue = 'Response';
        //Yes/No Selection List
        Component.Apex.selectList sList = new Component.Apex.selectList(size=1, id='status', value='{!row.quote.Quantity__c}', multiselect=false);
        sList.expressions.rendered = '{!row.question.question__c != "Yes/No"}';
        sList.childComponents.add(new Component.Apex.selectOption(itemLabel='Yes', itemValue='1'));
        sList.childComponents.add(new Component.Apex.selectOption(itemLabel='No', itemValue='0'));
        rColumn.childComponents.add(sList);
        //Numeric Selector
        Component.Apex.inputField numbers = new Component.Apex.inputField(type='number', required=false, value = '{!row.quote.Quantity__c}');
        numbers.expressions.rendered = '{!IF(row.question.question__c=="Numeric", "false","true")}';
        rColumn.childComponents.add(numbers);
        table.childComponents.add(rColumn);
        
        //Tip Column
        
        return table;    
    }

It won't compile, I get the following error:  value for <apex:inputField> is not a dynamic binding! 

Which is referring to the bolded line of code.  What's really frustrating is the exact same value is bound to the selection list, and it doesn't have any problems with that.  Is this a bug?  I see nothing wrong with my code.
Mikhail UshakovMikhail Ushakov
Hi
Did you manage to solve this?