You need to sign in to do that
Don't have an account?
michael_hy
The issue when I use the dynamicComponent, Need your help.
Hi, all
I meet one issue, and need someone's help. Thanks.
I write below code and it run well.
But after I change the inputField to dynamicComponent, I find just one dropdown list can be display on the page.
Do anyone can knows how to resolve this.
VF <apex:page showHeader="false" sidebar="false" id="dynamicComponent" controller="DynamicComponent"> <apex:form id="DetailsForm"> <apex:pageBlock mode="edit" id="PageBlock1"> <apex:actionStatus startText="Loading data....." id="productTypeStatus"> <apex:facet name="start"> Loading_data </apex:facet> </apex:actionStatus> <apex:pageBlockSection id="productTypeSec" columns="1" > <apex:selectRadio value="{!MOdetail.Type__c}" label="Type_of_Product" id="type"> <apex:actionSupport event="onclick" action="{!onClickRadio}" reRender="PageBlock1" status="productTypeStatus"></apex:actionSupport> <apex:selectoption itemValue="Life" id="Life" itemLabel="Life" ></apex:selectoption> <apex:selectoption itemValue="Annuity" id="Annuity" itemLabel="Annuity" ></apex:selectoption> </apex:selectRadio> </apex:pageBlockSection> life1:{!EnableLife} + annuity1:{!EnableAnnuity} <apex:pageBlockSection id="coverageBlock" title="Select_Desired_Coverage" columns="1" rendered="{!EnableLife}"> <div class="bottomline"></div> <!--<apex:inputField value="{!MOdetail.Name__c}" id="bp" />--> <apex:dynamicComponent componentValue="{!dynamicDetail}" id="bp" rendered="{!EnableLife}" /> life2:{!EnableLife} + annuity2:{!EnableAnnuity} </apex:pageBlockSection> <apex:pageBlockSection id="annuityOptBlock" title="Select_Annuity_Options" columns="1" rendered="{!EnableAnnuity}"> <div class="bottomline"></div> <!--<apex:inputField value="{!MOdetail.Name__c}" id="bpa"/>--> <apex:dynamicComponent componentValue="{!dynamicDetail}" id="bpa" rendered="{!EnableAnnuity}"/> life3:{!EnableLife} + annuity3:{!EnableAnnuity} </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
Controller: public with Sharing class DynamicComponent{ public Boolean EnableLife{get;set;} public Boolean EnableAnnuity{get;set;} public MyObject__c MOdetail{get;set;} public DynamicComponent(){ MOdetail = new MyObject__c(); EnableLife = false; EnableAnnuity = false; } public void onClickRadio(){ system.debug('huyu: ' + MOdetail.Type__c); if(MOdetail.Type__c == 'Life') { EnableLife = true; EnableAnnuity = false; MOdetail.Name__c = 'Life'; } else if(MOdetail.Type__c == 'Annuity') { EnableLife = false; EnableAnnuity = true; MOdetail.Name__c = 'Annuity'; } system.debug('enable Life and enable annuity : ' + EnableLife + ' : ' + EnableAnnuity ); } public component.apex.pageBlockSectionItem getDynamicDetail() { system.debug('huyu-invoke getDynamicDetail'); component.apex.pageBlockSectionItem optpane = new component.apex.pageBlockSectionItem(); component.apex.outputLabel label=new component.apex.outputLabel(); label.value='Payment Frequency*'; component.apex.selectList selList=new component.apex.selectList(); selList.id='PaymentFrequency'; selList.size=1; selList.childComponents.add(getSelectOption('aaa','value1','key1')); selList.childComponents.add(getSelectOption('bbb','value2','key2')); selList.childComponents.add(getSelectOption('ccc','value3','key3')); //selList.onchange='jsDynamicAllowedValue(this.options[this.selectedIndex].value);'; optpane.childComponents.add(label); optpane.childComponents.add(selList); system.debug(optpane); return optpane; } public component.apex.selectOption getSelectOption(String domainName,String label,String value) { component.apex.selectOption opt=new component.apex.selectOption(); opt.id='OPT_'+domainName+'_'+value; opt.itemLabel=label; opt.itemValue=value; return opt; } }