You need to sign in to do that
Don't have an account?
Vinay Ramu
Display List<String> in VisualForce Page
Need help in displaying List<String> in VF Page. Even with below code nothing displaying except h1 html text.
VF Page Code:
<apex:page controller="SObjectsListPageController">
<h1>List Of sObjects</h1>
<apex:repeat value="{!sObjectsList}" var="listStr" id="theRepeat">
<apex:outputText value="{!listStr}" id="theValue"/><br/>
</apex:repeat>
</apex:page>
Controller:
public class SObjectsListPageController {
public List<String> sObjectsList {get; set;}
public List<Schema.SObjectType> sObjTypeList = new List<Schema.SObjectType>();
public void getsObjectsList (){
Map<String, Schema.SObjectType> objMap = Schema.getGlobalDescribe();
sObjTypeList = objMap.values();
String str;
for(Schema.SObjectType scs : sObjTypeList){
str = scs.getDescribe().getName();
sObjectsList.add(str);
}
}
}
Thanks,
Vinay
VF Page Code:
<apex:page controller="SObjectsListPageController">
<h1>List Of sObjects</h1>
<apex:repeat value="{!sObjectsList}" var="listStr" id="theRepeat">
<apex:outputText value="{!listStr}" id="theValue"/><br/>
</apex:repeat>
</apex:page>
Controller:
public class SObjectsListPageController {
public List<String> sObjectsList {get; set;}
public List<Schema.SObjectType> sObjTypeList = new List<Schema.SObjectType>();
public void getsObjectsList (){
Map<String, Schema.SObjectType> objMap = Schema.getGlobalDescribe();
sObjTypeList = objMap.values();
String str;
for(Schema.SObjectType scs : sObjTypeList){
str = scs.getDescribe().getName();
sObjectsList.add(str);
}
}
}
Thanks,
Vinay
Modified VF Page as below:
<apex:page controller="SObjectsListController">
<apex:form >
<apex:pageBlock title="List Of Objects">
<apex:pageblockTable value="{!lstObjects}" var="f">
<apex:column value="{!f}"><apex:facet name="header">Object Names</apex:facet></apex:column>
</apex:pageblockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Thanks,
Vinay
All Answers
Please find Updated Code. It should work fine now.
Apex Controller:
public class SObjectsListPageController {
public List<String> getsObjectsList (){
List<String> finalList=new List<String>();
List<Schema.SObjectType> sObjTypeList = new List<Schema.SObjectType>();
Map<String, Schema.SObjectType> objMap = Schema.getGlobalDescribe();
sObjTypeList = objMap.values();
String str;
for(Schema.SObjectType scs : sObjTypeList){
str = scs.getDescribe().getName();
finalList.add(str);
}
return finalList;
}
}
Regards,
Tamilselvan.
You can use the below code:
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com
Modified VF Page as below:
<apex:page controller="SObjectsListController">
<apex:form >
<apex:pageBlock title="List Of Objects">
<apex:pageblockTable value="{!lstObjects}" var="f">
<apex:column value="{!f}"><apex:facet name="header">Object Names</apex:facet></apex:column>
</apex:pageblockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Thanks,
Vinay
public class SObjectsListController {
public List<String> lstObjects {get; set;}
public SObjectsListController(){
lstObjects = new List<String>();
List<Schema.SObjectType> sObjTypeList;
Map<String, Schema.SObjectType> objMap = Schema.getGlobalDescribe();
sObjTypeList = objMap.values();
String str;
for(Schema.SObjectType scs : sObjTypeList){
str = scs.getDescribe().getName();
lstObjects.add(str);
// System.debug(str);
}
}
}