You need to sign in to do that
Don't have an account?
rickyn
Dynamic Visualforce SelectList Component Help!
I am coding dynamic visual force components in my controller and have had success rendering the Inputfield component and SelectList compnent where the Multi-Select Attribute is False however having trouble when the attribute is set to true.
Here is the controller code and page code snippet: Red text shows the error I am receiving.
Thanks in advance for your help
for(Service_Task_STQ_Joiner__c STQ: STQList){ STRRList.add(new Service_Task_Request_Response__c()); // Picklist field code block if(STQ.Service_Task_Request_Questionnaire__r.Type__c == 'Picklist (Multi-Select)'){ Component.Apex.SelectList STQPicklist = new Component.Apex.SelectList(); List<String> STQPicklistValues = STQ.Service_Task_Request_Questionnaire__r.Values__c.Split(':',0); STQPicklist.Multiselect = True; /* ERROR when I load VF page: System.VisualforceException: Invalid value for property multiselect: Attribute multiselect for component <apex:selectList> cannot be changed after the component has been created */ //If STQPicklist.Multiselect = False; renders fine, however I need Multi-Select option STQPicklist.expressions.value = '{!STRRList[0].Response__c}'; STQPicklist.Size = STQPicklistValues.Size(); STQPicklist.id = 'STQPicklist'+i; STQPicklist.Required = STQ.Service_Task_Request_Questionnaire__r.Required__c; STQPicklist.Title = STQ.Service_Task_Request_Questionnaire__r.Help_Text__c; Component.Apex.selectOptions STQOptions = new Component.Apex.SelectOptions(); Component.Apex.OutputLabel STQOutputLabel = new Component.Apex.OutputLabel(); STQOutputLabel.value = STQ.Service_Task_Request_Questionnaire__r.Label__c; STQOutputLabel.for = 'STQPicklist'+i; STRRList[0].Service_Task_Question__c = STQ.Service_Task_Request_Questionnaire__r.Label__c; dynPageBlockSection.childComponents.add(STQOutputLabel); dynPageBlockSection.childComponents.add(STQPicklist); for(String s: STQPicklistValues){ Component.Apex.selectOption STQOption = new Component.Apex.SelectOption(); STQOption.itemValue = s; STQOption.itemLabel = s; STQPicklist.childComponents.add(STQOption); } }
<apex:page showheader="false" controller="CusReqController" action="{!ServiceTaskQuestionnairePageLoad}"> <apex:form > <apex:dynamicComponent componentValue="{!DynamicForm}"/> </apex:form> </apex:page>
Try passing it into the constructor: