I am designing a custom input picklist form that will be data-driven.Based on picklist value selected next question should show up with the picklist options.Like wise it might end up having 10-15 Picklist Questions based on the pathway choosen.
So am trying to create selectlist with options dynamically
How to show questions with picklist options created dynamically on visualforce page
Current Application Details:
We currently have visualforce wizard with questions and picklist options and our client didn't liked it i.e clicking on next or previous buttons for 15 times or more depending on the pathway the user selected ...we are trying to propose it with single page application like with on change of picklist value show related question with picklist options
Any help is appreciated .
Here is part of class and page
Class
public Component.Apex.OutputPanel getThePanel2(){
Component.Apex.OutputPanel outPanel1 = new Component.Apex.OutputPanel();
outPanel1 = getcurrentPanel2();
return outPanel1 ;
}
public boolean showDynamic{get;set;}
public Component.Apex.OutputPanel getcurrentPanel2(){
Component.Apex.OutputPanel outPanel1 = new Component.Apex.OutputPanel();
outPanel1.id='currentsect';
Component.Apex.SelectList STQPicklist = new Component.Apex.SelectList();
STQPicklist.StyleClass = 'form-control';
STQPicklist.StyleClass = 'col-md-4';
STQPicklist.Size = 1;
Component.Apex.ActionSupport asu = new Component.Apex.ActionSupport (event='onchange');
asu.expressions.action='{!getNextChild}';
set<string> outputPanelId = new set<string>();
outputPanelId.add('WizardQues3');
asu.rerender=outputPanelId;
Component.Apex.selectOptions STQOptions = new Component.Apex.SelectOptions();
STQOptions.expressions.value = '{!progLineItemPathwayItems}';
STQPicklist.childComponents.add(STQOptions);
STQPicklist.childComponents.add(asu);
Component.Apex.Outputlabel outlab= new Component.Apex.Outputlabel();
outlab.value = 'What do you want to Import';
outlab.StyleClass = 'col-md-4';
outPanel1.childComponents.add(outlab);
outPanel1.childComponents.add(STQPicklist);
return outPanel1;
}
Page
<apex:outputPanel id="WizardQues2">
<apex:outputPanel rendered="{!if(showDynamic = true,true,false)}">
<div class="row" style="margin-bottom:15px;" >
<apex:dynamicComponent componentValue="{!thePanel2}" id="dyncompt"/>
</div>
</apex:outputPanel>
</apex:outputPanel>
<apex:outputPanel id="WizardQues3">
<apex:outputPanel rendered="{!if(showDynamic = true,true,false)}">
<div class="row" style="margin-bottom:15px;" >
<apex:dynamicComponent componentValue="{!thePanel2}" id="dyncompt"/>
</div>
</apex:outputPanel>
</apex:outputPanel>
asu.rerender=outputPanelId;
this will work.. I think issue with you are passing wrong Id in rerender .. I suggest just removeasu.rerender=outputPanelId;
and try..outPanel1.id='currentsect';
in list of string ` set<string> outputPanelId = new set<string>{'currentsect'};` and finally addasu.rerender=outputPanelId;
... this way it will work