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
ajay ambatiajay ambati 

visualforce page issue on save button with update operation

hi my requirement is placed 4 buttons 3 buttons display list of accounts,contacts,oppurtunitys when iam clicking,I need to update my feilds from visualforcepage by  using CUSTOM CONTROLLER and inline edit support but when iam click save button its need to update but it is not working getting "Nullpointer exception"
please solve this

below is vfpage:
<apex:page controller="all12">

  <apex:form >
  <style>
   .accountstyle
  {
  background-color:yellow;
font-weight:bold;
color:#E56717;
  }
 
  </style>
  <apex:pageBlock >
  <apex:commandButton value="listofaccounts" action="{!sss}" />
  <apex:commandButton value="listofopp" action="{!ddd}"/>
  <apex:commandButton value="listofcontacts" action="{!fff}"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  <apex:commandButton value="saveit" action="{!save}"/>
  <apex:pageBlockTable value="{!lst1}" var="a" rendered="{!show}">
  <apex:column value="{!a.name}"/>
 
  </apex:pageBlockTable>
  <apex:pageBlockTable value="{!opp}" var="o" rendered="{!show1}" >
  <apex:column value="{!o.Name}" styleClass="accountstyle"/>
  <apex:column value="{!o.CloseDate}"/>
  <apex:column value="{!o.StageName }"/>
   </apex:pageBlockTable>
     <apex:pageBlockTable value="{!cnt}" var="x" rendered="{!show2}">
  <apex:column value="{!x.Name}"/>
        <apex:inlineEditSupport />
  </apex:pageBlockTable>
      <apex:inlineEditSupport event="ondblclick"/>
  </apex:pageBlock>
  </apex:form>
</apex:page>

controller: Note this is custom controller not the standard controller please say solution for controller not for the standard controller using

controller:
public class all12 {
   
     public boolean show {get;set;}
    public boolean show1 {get;set;}
      public boolean show2 {get;set;}
    public String lst { get; set; }
    public list<account> lst1 {get;set;}
    public list<Opportunity> opp {get;set;}
    public list<schema.contact> cnt {get;set;}
    public account ac{get;set;}
   // public id ids{get;set;}
   
    public PageReference sss()
     {
      show = true;
    show1 = false;
    show2 = false;
  lst1 = [select id, name from account ];
        return null;
    }
    public PageReference fff()
    {
    show = false;
    show1 = false;
    show2 = true;
   
       cnt=[select name,phone from contact];
        return null;
    }


    public PageReference ddd()
    {
     show = false;
    show1 = true;
    show2 = false;
    opp = [select Name,CloseDate,StageName from opportunity];
        return null;
    }


    
    public PageReference save()
    {
     
      
    ac = [select id,name from account where id=:ac.id];
      lst1.add(ac);
      //lst1.add(ii);
      update lst1;
      //update opp ;
      //update cnt;
      
  return null;
}
}