Q:

Attempted to insert a null list

I'm having this problem. Every time I try to insert inputFields values to DB via Save button I either have this error 

Attempted to upsert a null list
  Error is in expression '{!Save}' in component  in page neworderpage: Class.NewOrderController.Save: line 23, column 1

OR 
when I instantiate the List object in Save method, it is not inserted into DB.
VF Page (please ignore missing beginning and end):
<apex:form >
    <apex:dataList value="{!Opportunities}" var="o" style="list-style-type: none">
        <apex:pageBlock >
            <apex:pageBlockSection collapsible="false" title="Products (Assets)">
                <apex:inputField value="{!o.Order__r.Asset__r.Product2Id}" />
                <apex:inputField value="{!o.Order__r.Asset__r.Quantity}" /> 
                <apex:outputField value="{!o.Order__r.Asset__r.Price}" />
            </apex:pageBlockSection>
            <apex:pageBlockSection collapsible="false" title="Order details">
                <apex:inputField value="{!o.Order__r.Payment__c}" />  
                <apex:inputField value="{!o.Order__r.Delivery__c}" />
                <apex:inputField value="{!o.Order__r.EffectiveDate}" />
            </apex:pageBlockSection>
            <apex:pageBlockSection collapsible="false" title="Contact Info">
                <apex:inputField value="{!o.Order__r.Contact__r.OwnerId}" />     
                <apex:inputField value="{!o.Order__r.Contact__r.Email}" />
                <apex:inputField value="{!o.Order__r.Contact__r.MobilePhone}" />
                <apex:inputField value="{!o.Order__r.Contact__r.AssistantName}" />
                <apex:inputField value="{!o.Order__r.Contact__r.AssistantPhone}" />
            </apex:pageBlockSection>
            <apex:pageBlockSection collapsible="false" title="Billing Address">
                <apex:inputText value="{!o.Order__r.BillingStreet}" />
                <apex:inputText value="{!o.Order__r.BillingCity}" />
                <apex:inputText value="{!o.Order__r.BillingPostalCode}" />
                <apex:inputText value="{!o.Order__r.BillingCountry}" />
            </apex:pageBlockSection>
            <apex:pageBlockSection collapsible="false" title="Shipping Address">
                <apex:inputText value="{!o.Order__r.ShippingStreet}" />
                <apex:inputText value="{!o.Order__r.ShippingCity}" />
                <apex:inputText value="{!o.Order__r.ShippingPostalCode}" />
                <apex:inputText value="{!o.Order__r.ShippingCountry}" />
            </apex:pageBlockSection>
                <apex:commandButton action="{!Save}" title="Save" value="Save order" />
        </apex:pageBlock>
    </apex:dataList>
</apex:form>

And my controller:
    public class NewOrderController {

    public List<Opportunity> oppList;

    public List<Opportunity> getOpportunities() {
        List<Opportunity> oppList = new List<Opportunity>();

        oppList = [SELECT *some query entries*
                   FROM Opportunity
                   WHERE Order__c != null];
        return oppList;
    }

    public PageReference Save(){

        upsert oppList; 

        return new PageReference('/apex/MyOrders');
    } 
}

What am I missing? Dev console does not throw any error.
Thank you in advance for help. I am kinda new to apex/soql/visualforce. 

A:

You are facing a name shadow problem here.
You have oppList defined as a member variable as well as locally in the method getOpportunities(). So when you are accessing the list on the VF, you are not really populating the member variable. The member variable always remains null and thus you are getting the error in Save().
Just remove the declaration List<Opportunity> oppList = new List<Opportunity>();  from your getOpportunities() and use this instantiation at class level while declaring the variable and that should work.

