Apex Class:
public class ObjectNameAsPicklistController {
public List<SelectOption> lstObject {get;set;}
public String selectedObject {get;set;}
public ObjectNameAsPicklistController() {
lstObject = new List<SelectOption>();
for(String obj:schema.getGlobalDescribe().keyset()) {
system.debug('obj:'+obj);
lstObject.add(new selectOption(obj,obj));
}
}
}
Page:ObjectAPINameAsPicklist
<apex:page controller="ObjectNameAsPicklistController">
<apex:form>
<apex:pageBlock>Select Object:<br/>
<apex:selectList value="{!selectedObject}" label="Select Object:" title="Select Object:">
<apex:selectOptions value="{!lstObject}"/>
</apex:selectList>
</apex:pageBlock>
</apex:form>
</apex:page>
Output:
No comments:
Post a Comment