2

Does any one have any idea why I am getting this error when I try to save {!sobj.c}

Error: Read access denied for null

my code

<apex:pageBlockTable value="{!sobjlst}" var="sobj">
    <apex:column >
        <apex:repeat value="{!wcls}" var="sobjfd">
            alert({!sobjfd.fieldname});
            <apex:variable var="c" value="{!sobjfd.fieldname}" />
                alert({!c});
                //sobj is the list of all the objects we are using like this <apex:pageBlockTable value="{!sobjlst}" var="sobj">
            <apex:inputField value="{!sobj.c}"/>
            <!-- <apex:inputField value="{!sobjfd.objectName.get(c)}"/>-->
        </apex:repeat>
    </apex:column>
</apex:pageBlockTable>

list

public List<sObject> sobjlst {get; set;}

My wrapper class :

public class wrapperClass {
    public list<Schema.SObjectField> fieldname {get; set;}
    public SObject objectName {get; set;}
    public wrapperClass(SObject objectName, list<Schema.SObjectField> fieldname) {
        this.fieldname = fieldname;
        this.objectName = objectName;
    }
}

Please do help me how can I display the object with the name of the fields so that it can be inputfield. I need fields in the wrapper to be added as dynamically.

1 Answer 1

2

Change the code in Visualforce page like this.

<apex:inputField value="{!sobj[c]}"   />

or

<apex:inputField value="{!sobj[sobjfd.fieldname]}"   />
3
  • sharan, to post code or VF you can select it and click the {} button in the editor. That'll make sure it's all shown. Commented Sep 30, 2014 at 12:31
  • Thanks Samuel. But I could not find that {} button. Commented Sep 30, 2014 at 17:56
  • apologies, in this new designs it's the button with the binary 1 and 0's. I've gone and editted the post for you. Commented Sep 30, 2014 at 18:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .