I am fetching all the field of an object after selecting one object from the dropdown list. With field I am showing checkbox, now I want to show all the field data that I selected using checkbox in VF page.
How to show field value of that particular selected field?
public class ProcessSelected
{
public String obj;
public List<String> objFields {get;set;}
public void processSelected() {
}
public String getobj()
{
return obj;
}
public void setobj(String obj)
{
this.obj = obj;
}
public List<SelectOption> getobjs()
{
List<Schema.SObjectType> gd = Schema.getGlobalDescribe().Values();
List<SelectOption> options = new List<SelectOption>();
for(Schema.SObjectType f : gd)
{
options.add(new SelectOption(f.getDescribe().getName(),f.getDescribe().getName()));
}
return options;
}
public void fetchFields()
{
List<String> fields = new List<String>();
Map<String , Schema.SObjectType> globalDescription = Schema.getGlobalDescribe();
Schema.sObjectType objType = globalDescription.get(obj);
Schema.DescribeSObjectResult r1 = objType.getDescribe();
Map<String , Schema.SObjectField> mapFieldList = r1.fields.getMap();
for(Schema.SObjectField field : mapFieldList.values())
{
Schema.DescribeFieldResult fieldResult = field.getDescribe();
if(fieldResult.isAccessible())
{
fields.add(fieldResult.getName());
}
}
List<String> so = new List<String>();
for(String f : fields)
{
so.add(f);
}
objFields = so;
}
}
apex:outputfield
tag to display. Or better if you can share your code and tell us where are you facing problem.