I have a list of sObject
which I have created dynamically. This is how the list is populated.
(Contact:{OtherCountry=null, Division_Type__c=null}, Account:{AccountNumber=null})
I don't want to hard code any field. I need fields should be displayed dynamically. My controller code for list
public List<sObject> sobjlst {get; set;}
sobjlst = new List<sObject>();
for(sObject sobj : sObjectFieldMap.keyset()){
SObject newobj = sobj;
system.debug('object Name before loop ' + sobj);
for(SObjectField sobjFd : sObjectFieldMap.get(sobj)){
system.debug('object Name ' + sobj + ' Fields ' + sobjFd);
//SObject newobj = sobj{sobjFd};
newobj.put(sobjFd, '');
system.debug('The fields added to object ' + newobj);
//break;
}
sobjlst.add(newobj);
system.debug('object details ' + sobj);
//break;
}
My VF page :
<apex:pageBlock >
<apex:pageBlockTable value="{!sobjlst}" var="sobj">
</apex:pageBlockTable>
</apex:pageBlock>
when I add <apex:inputFied value="{!sobjlst[sobj]}"/>
between apex:pageBlockTable
getting error :
Error Error: Read access denied for null
Please help me how can I get the solution. Or suggest me the best way to solve this issue.