Showing posts with label Dynamic Component. Show all posts
Showing posts with label Dynamic Component. Show all posts

Tuesday, July 12, 2011

Setting URL for Dynamic Lookup page using Dynamic Component


<apex:page controller="DynamicLookupClass1">
<apex:form >
<apex:pageBlock >
 <apex:pageBlockSection id="section" title="Send To" >

<apex:selectList size="1"  value="{!lookupType}" >
    <apex:actionSupport event="onchange" rerender="lookupSection" action="{!changeLookupType}" status="lookupStatus"/>  
    <apex:selectOption itemValue="Contact"/>
    <apex:selectOption itemValue="Opportunity"/>  
</apex:selectList>
</apex:pageBlockSection>
<apex:actionstatus id="lookupStatus" onstart="alert('HI')" onstop="alert('End')"/>
<apex:outputpanel id="lookupSection">
      <apex:dynamicComponent id="dynCom" componentValue="{!myFieldSetSection}"/>
</apex:outputpanel>
</apex:pageBlock>
</apex:form>
</apex:page>

public class DynamicLookupClass1 {
     
      public DynamicLookup__c lkp {get; set;}
    public String lookupType { get; set; }     
    public Component.Apex.pageBlockSection getMyFieldSetSection() {       
         Component.Apex.pageBlockSection rTag = new Component.Apex.pageBlockSection();      
         Component.Apex.inputField oppTotal = new Component.Apex.inputField();
         if(lookupType == 'Opportunity')
         oppTotal.expressions.value='{!lkp.Opportunity__c}';
         else if(lookupType == 'Contact')
         oppTotal.expressions.value='{!lkp.Contact__c}';
         else
         oppTotal.expressions.value='{!lkp.Opportunity__c}';        
         rTag.childComponents.add(oppTotal);
         return rTag;
    }
   
    public void changeLookupType(){            
    }   
}