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
Prallavi DuaPrallavi Dua 

Display the class methods based on the Class Selection

Hi,

I have a VF page with picklist containing the all classes in the org. When I select the class its displays a body in another section.
In the same way it should display the ClassMethods on class selection.
Can Someone help me.

<apex:page controller="DynamicApexClasses_Controller">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection columns="2">
                <apex:pageblockSectionItem >
                    <apex:outputLabel value="Select a Class"/>
                </apex:pageblockSectionItem>       
                <apex:pageblockSectionItem >               
                    <apex:selectList size="1" value="{!state}">
                        <apex:selectOptions value="{!states}"/>
                        <apex:actionSupport event="onchange" reRender="a,aa" action="{!action1}"/>
                    </apex:selectList>               
                </apex:pageblockSectionItem>
                
                <apex:outputText value="{!t.Body}" id="a"/><br /><br />
                <apex:outputText value="{!s}" id="aa" escape="false"/>
            </apex:pageBlockSection>
            
        </apex:pageBlock>
    </apex:form>
</apex:page>
==============================================================
public class DynamicApexClasses_Controller {
    public String state {get;set;}
    public String city {get;set;}
    public apexclass t{get;set;}
    public String s{get;set;}
    
    public List<SelectOption> getStates()
    {
        list<apexclass> aa = [select id,name from apexclass];
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('None','--- None ---'));
        for(apexclass a : aa){
            options.add(new SelectOption(a.id,a.name));
        }
        
        return options;
    }
    
    public void action1(){
        
        if(state!=null){
            t = [select id,name,Body from apexclass where id = :state];                
            s ='@isTest \n\n'+ '<br/>'+'Public Class ' + t.name+'Test{<br/>'+
                'Public void Postivetest(){<br/>'+'}<br/>'+'}' ;  
            
            String soql = 'SELECT ContentEntityId, SymbolTable FROM ApexClassMember where ContentEntityId = ' + t.id + '';
            system.debug('soql==' + soql);
        }
    }
}

Thanks in Advance