function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SurekaSureka 

Null pointer exception

Hi,

I have the following code in my controller & VF page.


<apex:page controller="testing">
    <apex:form >
          <apex:pageBlockSection title="Dimensions">
          <apex:repeat var="mp" value="{!listMap}">
          <apex:repeat value="{!listMap[mp]}" var="mp1">
              <apex:repeat value="{!mp1.getfields}" var="fldSet">
                  <apex:inputField value="{!acc[fldSet]}"/>    - Null pointer exception here
              </apex:repeat>
              </apex:repeat>
              </apex:repeat>
          </apex:pageBlockSection>
 
        </apex:pageBlock>

    </apex:form> 
</apex:page>


public  class testing
{

    public testing()
    {
    }

    public Account acc { get; set; }
   
    public class WrClass
    {
        public List<Schema.FieldSetMember> getFields{get;set;}
    }
   
    public Map<Integer, WrClass> listMap
    {
        get
        {
            listMap = new Map<Integer, WrClass>();
     WrClass ff  =new WrClass();
            ff.getFields = SObjectType.Account.FieldSets.Bhu_Managed_Pac__asdfasdf.getFields();
            listMap.put(1, ff);
            return listMap;
        }
        set;
    }   
   
}

When I am trying to save the VF page, I am getting the following error:

 

Error: Java.lang.NullPointerException
Error: null

 

This exception occurs only when a map is used. The code is working fine if List<WrClass> is used instead of Map<Integer, WrClass>

 

Any Idea?

 

Thanks
Sureka

aballardaballard

Where in your class do you ever set the property acc?  It appears to be correctly reporting it is null AFAICT.

aballardaballard

Actually, it shouldn't be reporting the error that way even if there is a problem with your code.   You might want to open a support case. 

Salesforce WizardSalesforce Wizard

I've gotten a similar issue.

 

Do you get that error when saving in the Developer Console or editing the class directly in salesforce's class list?

 

In my scenario, I discovered anytime I'm referring to a field list that is nested within something else causes an error:

 

http://boards.developerforce.com/t5/Visualforce-Development/Dynamic-Binding-with-Field-Set-within-List-causes-error-with-no/td-p/454391

 

try not using the input field and just using {!fldSet} and see if the null pointer goes away. That won't get us the desired results but it may confirm we're experiencing similar issues.

Kirill_YunussovKirill_Yunussov

any updates?   I am having this problem also.

Salesforce WizardSalesforce Wizard

Check out this thread: http://boards.developerforce.com/t5/Visualforce-Development/Dynamic-binding-Error-Invalid-field-core-for-SObject-Case/m-p/457843#M52001

 

Basically I'm putting my list of fields within a wrapper class. That's working