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.

2

Change the code in Visualforce page like this.

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

or

<apex:inputField value="{!sobj[sobjfd.fieldname]}"   />
  • 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. – Samuel De Rycke Sep 30 '14 at 12:31
  • Thanks Samuel. But I could not find that {} button. – Charan Vuyyuru Sep 30 '14 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. – Samuel De Rycke Sep 30 '14 at 18:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.