+ Start a Discussion
Collen Mayer 6Collen Mayer 6 

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?
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" >
<apex:repeat var="TSE" value="{!Timesheet__c.Timesheet_Entries__r}">
          <td >
              <apex:outputField value="{!TSE.Date__c}"/>             
          <td >
              <apex:inputField value="{!TSE.Time_Out_1__c}"/>             
- (other code)
               <apex:commandButton value="Save" action="{!saveTS}" />
Any help would be appreciated. 

Best Answer chosen by Collen Mayer 6
Zuinglio Lopes Ribeiro JúniorZuinglio Lopes Ribeiro Júnior
Hello Collen,

Try changing this line from
<apex:repeat var="TSE" value="{!Timesheet__c.Timesheet_Entries__r}">

<apex:repeat var="TSE" value="{!timeentryList}">

Hope to have helped!


Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.