You need to sign in to do that
Don't have an account?
![Padmanabhan Kamuni Padmanabhan Kamuni](https://dfc-org-production.my.site.com/img/userprofile/default_profile_45_v2.png)
I'm not able to see the picklist by using schema?? Kindly help
Hello,
Please find the code below and guide me.
VF page is below.
Pick list is not displaying. Help..
Please find the code below and guide me.
public class Task17 { public Map<String, schema.SObjectType> allObjects {get;set;} public List<SelectOption> objNames {get; set;} public String objName {get; set;} public String selectedName {get; set;} public Task17(){ list<selectoption> objNames = new List<selectoption>(); allObjects = schema.getGlobalDescribe(); list<string> allNames = new list<string>(allObjects.keySet()); //allNames.sort(); system.debug('line 19'+allNames); for( String key1 : allNames){ objNames.add(new SelectOption(key1,key1)); } system.debug('Line22'+objNames); } }
VF page is below.
<apex:page controller="Task17" > <apex:form> <apex:pageBlock> Please Select the obj <apex:selectList value="{!selectedName}"> <apex:selectOptions value="{!objNames}"/> </apex:selectList> </apex:pageBlock> </apex:form> </apex:page>
Pick list is not displaying. Help..
I have changed some code from you written above. Please use this it is working fine.
public class ObjectNamesController{
public Map<String, schema.SObjectType> allObjects {get;set;}
public List<SelectOption> objNames {set;}
public String selectedName {get; set;}
public ObjectNamesController(){
}
public List<SelectOption> getobjNames(){
list<selectoption> objNames = new List<selectoption>();
allObjects = schema.getGlobalDescribe();
system.debug('allObjects'+allObjects );
list<string> allNames = new list<string>(allObjects.keySet());
system.debug('allNames'+allNames);
for( String key1 : allNames){
objNames.add(new SelectOption(key1,key1));
system.debug('key1 '+key1 );
}
system.debug('Line22'+objNames);
return objNames;
}
}
All Answers
I have changed some code from you written above. Please use this it is working fine.
public class ObjectNamesController{
public Map<String, schema.SObjectType> allObjects {get;set;}
public List<SelectOption> objNames {set;}
public String selectedName {get; set;}
public ObjectNamesController(){
}
public List<SelectOption> getobjNames(){
list<selectoption> objNames = new List<selectoption>();
allObjects = schema.getGlobalDescribe();
system.debug('allObjects'+allObjects );
list<string> allNames = new list<string>(allObjects.keySet());
system.debug('allNames'+allNames);
for( String key1 : allNames){
objNames.add(new SelectOption(key1,key1));
system.debug('key1 '+key1 );
}
system.debug('Line22'+objNames);
return objNames;
}
}