You need to sign in to do that
Don't have an account?
InputField values lost
I have a page that loads a set of records [based on a query] and includes some inputfields to apply changes to the associated records. The page loads the right records and the fields that I 'get-set' [inputtext] in the controller extension do update. But any values in the inputfields type get lost.
The inputText fields are ButtonClick and RC Setter - these two save - but the rest of the field values are lost. Any suggestions would be great!
Here is my controller extension [extends the case StandardSetController]- which includes two methods for 'SaveClose' and 'SaveNext' and following this is the visualforce page code.
public with sharing class CaseExtension {
//Global Variables
private ApexPages.StandardSetController controller;
Private final string InEditUser=UserInfo.getUserId();
public String onClick { get; set; }
Public String RCSetter { get; set; }
// Standard Controller Constructor
public CaseExtension(ApexPages.StandardSetController Controller) {
this.controller = controller;
}
public ApexPages.StandardSetController caseRecords{
Get{
if(caseRecords==null){
caseRecords = new ApexPages.StandardSetController(Database.getQueryLocator([SELECT Id,ButtonClick__c,CaseNumber,Account.Name,
Cancellation_Date__c,Completion_Date__c,Target_SLA_Current__c,Implementation_Notes__c,
Implementation_Delay__c,Implementation_Delay_Notes__c,Delay_Details__c,Cancellation_Reason__c,New_Case_Comment__c,
OMS_Quote_no__c,Property_Name__c,
Opportunity_c__c,Bundle__c,Product__c,Status_RC__c,InEditUser__c,InEditExpiring__c FROM Case WHERE InEditUser__c =: InEditUser]));
}
return caseRecords;
}
Private set;
}
public List<Case> getcSelected(){
return (List<Case>) caseRecords.getRecords();
}
//getOptions for ButtonClick Method
public List<SelectOption> getOptions(){
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('','--select--'));
options.add(new SelectOption('Next','Next RC'));
options.add(new SelectOption('Previous','Previous RC'));
options.add(new SelectOption('getProperty','Assign Property Contact'));
options.add(new SelectOption('getCorporate','Assign Corporate Contact'));
return options;
}
//Save and Close method
public PageReference SaveClose(){
for(Case e :getcSelected()){
e.ButtonClick__c=onClick;
e.InEditUser__c=Null;
e.RC_Setter__c=RCSetter;
}
Update getcSelected();
PageReference pageRef = new PageReference('/500/o');
pageRef.setRedirect(true);
return pageRef;
}
//Save and Next method
public PageReference SaveNext(){
for(Case g :getcSelected()){
g.ButtonClick__c=onClick;
g.RC_Setter__c=RCSetter;
}
Update getcSelected();
PageReference pageRef = page.InEditUpdateOne;
pageRef.setRedirect(true);
return pageRef;
}
}
VisualForce Page:
<apex:page standardController="Case" extensions="CaseExtension" recordSetVar="implementations"> <apex:sectionHeader title="New Field Values"/> <apex:form > <apex:pageBlock > <apex:pageMessages /> <apex:pageBlockButtons > <apex:commandButton value="Save and Close" action="{!saveClose}" onclick="NoPrompt();"/> <apex:commandButton value="Save and Next" action="{!saveNext}" onclick="NoPrompt();"/> </apex:pageBlockButtons> <apex:tabPanel switchType="client" selectedTab="TabOne" id="theTabPanel"> <apex:tab label="Standard Details" name="StandardDetails" id="tabOne"> <apex:pageBlockSection title="" showHeader="false" collapsible="false"> <apex:selectList Label="ButtonClick" value="{!onClick}" size="1"> <apex:selectOptions Value="{!Options}"/> </apex:selectList> <apex:inputField Label="Case Owner" value="{!Case.OwnerId}" Required="False"/> <apex:pageBlockSectionItem /> <apex:pageBlockSectionItem /> <apex:pageBlockSectionItem /> <apex:pageBlockSectionItem /> <apex:inputField value="{!Case.Target_SLA_Current__c}"/> <apex:inputField value="{!Case.Client_Contacted_Date__c}" Required="False"/> <apex:inputField value="{!Case.ContactId}" Required="False"/> <apex:pageBlockSectionItem /> <apex:inputTextArea value="{!Case.Implementation_Notes__c}" rows="5" cols="75"/> <apex:inputTextArea value="{!Case.Implementation_Delay_Notes__c}" rows="5" cols="75"/> <apex:pageBlockSectionItem /> </apex:pageBlockSection> </apex:tab> <apex:tab label="Administration" name="Administration" id="tabTwo"> <apex:pageBlockSection title="" showHeader="false" collapsible="false"> <apex:inputText Label="RC Setter" value="{!RCSetter}"/> <apex:inputField value="{!Case.Cancellation_Reason__c}"/> <apex:pageBlockSectionItem /> <apex:pageBlockSectionItem /> <apex:inputField value="{!Case.Completion_Date__c}"/> <apex:inputField value="{!Case.Cancellation_Date__c}"/> <apex:pageBlockSectionItem /> </apex:pageBlockSection> </apex:tab> </apex:tabPanel> <apex:pageBlockSection title="Selected Implementations" columns="1"> <apex:pageBlockTable value="{!cSelected}" var="c"> <apex:column headerValue="Case No"> <apex:outputLink value="/{!c.id}">{!c.casenumber}</apex:outputLink> </apex:column> <apex:column value="{!c.OMS_Quote_No__c}"/> <apex:column value="{!c.Account.Name}"/> <apex:column value="{!c.Property_Name__c}"/> <apex:column value="{!c.Opportunity_c__c}"/> <apex:column value="{!c.Bundle__c}"/> <apex:column value="{!c.Product__c}"/> <apex:column value="{!c.Status_RC__c}"/> <apex:column value="{!c.Target_SLA_Current__c}"/> <apex:column value="{!c.Implementation_Delay__c}"/> <apex:column value="{!c.Implementation_Delay_Notes__c}"/> <apex:column value="{!c.InEditExpiring__c}"/> </apex:pageBlockTable> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
Here was final solution..
http://boards.developerforce.com/t5/Apex-Code-Development/Extension-Class-VF-Page-Custom-Save-method-not-working/m-p/663558/thread-id/123198/highlight/false#M124339