Reply
Regular Contributor
Scott0987
Posts: 121
0

Save button not working

I have a visualforce page setup and have inline editing setup on it.  For some reason the Save button does not do anything but refreshes the page.  I have just set it up to use the builtin save button.  At least I think I do.  

Here is the visualforce page:

<apex:page standardController="Census_Import__c" extensions="censusImportPageExtension">
<style type="text/css">
.odd{background-color: #DBDBDB;} 
.even{background-color:#E4E4E4;}
</style>
<apex:form >
<apex:pageBlock title="Accounts To Import">
<apex:inlineEditSupport showOnEdit="inlineEditSave">
<apex:dataTable value="{!accts2imp}" var="a2i" width="100%" rowClasses="odd,even" cellspacing="1px" cellpadding="5px">
<apex:column value="{!a2i.First_Name__c}"><apex:facet name="header">First Name</apex:facet></apex:column> 
<apex:column value="{!a2i.Last_Name__c}"><apex:facet name="header">Last Name</apex:facet></apex:column>
<apex:column value="{!a2i.Phone__c}"><apex:facet name="header">Phone</apex:facet></apex:column>
<apex:column value="{!a2i.Address_1__c}"><apex:facet name="header">"Adress Line 1</apex:facet></apex:column>
<apex:column value="{!a2i.City__c}"><apex:facet name="header">City</apex:facet></apex:column>
<apex:column value="{!a2i.State__c}"><apex:facet name="header">State</apex:facet></apex:column>
<apex:column value="{!a2i.Zip__c}"><apex:facet name="header">Zip Code</apex:facet></apex:column>
<apex:column value="{!a2i.Class__c}"><apex:facet name="header">Class</apex:facet></apex:column>
<apex:column value="{!a2i.DOB__c}"><apex:facet name="header">DOB</apex:facet></apex:column>
<apex:column value="{!a2i.Effective_Date__c}"><apex:facet name="header">Effective Date</apex:facet></apex:column>
<apex:column value="{!a2i.Gender__c}"><apex:facet name="header">Gender</apex:facet></apex:column>
<apex:column value="{!a2i.Hire_Date__c}"><apex:facet name="header">Hiredate</apex:facet></apex:column>
<apex:column ><apex:inputcheckbox value="{!a2i.Import__c}"/><apex:facet name="header">Import?</apex:facet></apex:column>
</apex:dataTable> 
<apex:commandButton action="{!save}" id="inlineEditSave" value="  Save  " />
</apex:inlineEditSupport>
</apex:pageBlock>
</apex:form>
</apex:page>

 Here is the extension:

public with sharing class censusImportPageExtension {

    public censusImportPageExtension(ApexPages.StandardController controller) {
    }

    public list<Account_To_Import__c> acctsToImport {get;set;}
    public list<Account_To_Import__c> getaccts2imp(){
        acctsToImport = [select Import__c, Address_1__c, Address_2__c, Area_Code__c, Census_Import__c, City__c, Class__c, DOB__c, Effective_Date__c, Extension__c, First_Name__c, Gender__c, Hire_Date__c, Job_Title__c, Last_Name__c, Location__c, Middle_Name__c, Phone__c, Relationship__c, Salary__c, SSN__c, State__c, Suffix__c, Zip__c from Account_To_Import__c where Census_Import__c = :ApexPages.currentPage().getParameters().get('id')];
    return acctsToImport;
    }
}

 Thanks for any help. 

Trusted Contributor
Shiv Shankar
Posts: 162
0

Re: Save button not working

write one save function in controller

 

 

      

public pagereference save(){
insert accts2imp;
return (page reference for view page);// this lind will direct you to list mode. above statement is enough to insert record.in that case you remove return type
}

 

 

 

SalesForce Developer

Hit the Kudos button (star) if any post helps you - Mark the answer as solution, It might help others running to into similar problem in future.
Trusted Contributor
asish1989
Posts: 295
0

Re: Save button not working

Hi

   write save method in the controller.it will add more benifites because If you save it by using satndard save function then It will redirect you to  the standard detail page which is not your requirement .So its better to save method in custom controller as you are using Inlineedit. Here is some code you can refer..

   

public PageReference Save() { 
              update accts2imp;
              PageReference newpage = new PageReference('/apex/YourVfpage');
              newpage.setRedirect(true);
              return newpage ;
           }

 Did this post answers your questions if soplease mark it solved

Asish Kumar Behera
Certified Salesforce Developer @
MindfireSolutions
|My Blog