You need to sign in to do that
Don't have an account?

Problem with "save" on controller extension for visualforce
Hi All,
I've written this simple controller extension for a VF page and am having trouble with the Save method; the changes I make to a record from the page are not saving after I click "save". Do you see problems with my code?
Thanks,
Collen
I've written this simple controller extension for a VF page and am having trouble with the Save method; the changes I make to a record from the page are not saving after I click "save". Do you see problems with my code?
public class Timesheet { public ApexPages.StandardController stdCntrlr {get; set;} public List<Timesheet_Entry__c> timeentryList {get;set;} public TimeSheet__c timesheet; public Timesheet(ApexPages.StandardController controller) { stdCntrlr = controller; timesheet = (TimeSheet__c)controller.getRecord(); timeentryList = [Select id, Date__c, Time_in_1__c, Time_in_2__c, Time_Out_1__c, Time_Out_2__c, Work_Hours__c, Holiday_Hours__c, Vacation_Hours__c, Personal_Hours__c, Other_Hours__c, Total_Hours__c from Timesheet_Entry__c where TimeSheet__c =: timesheet.ID]; } public PageReference SaveTS(){ upsert timesheet; upsert timeentryList; return (new ApexPages.StandardController(timesheet)).view(); } }Here is a snippet of the Visualforce page:
<apex:page standardController="Timesheet__c" extensions="Timesheet" sidebar="false" showHeader="true" docType="html-5.0"> <apex:form > <apex:pageBlock title="Hours Worked" > <table> <apex:repeat var="TSE" value="{!Timesheet__c.Timesheet_Entries__r}"> <tr> <td > <apex:outputField value="{!TSE.Date__c}"/> </td> <td > <apex:inputField value="{!TSE.Time_Out_1__c}"/> </td> </tr> - - - (other code) - <apex:commandButton value="Save" action="{!saveTS}" /> </apex:pageBlockButtons> </table> </apex:pageBlock> </apex:form> </apex:page>Any help would be appreciated.
Thanks,
Collen
Try changing this line from
To
Hope to have helped!
Regards.
Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.