i want to create a code that when i hit save button i want to save the data and redirect it to a another view page with same values. I tired several method, but it does not work. Anybody have any idea? Thanks
<apex:page standardController="Product_Brief__c" sidebar="true" showHeader="true" extensions="gibco" ><br/>
apex:form ><br/>
apex:pageBlock mode="inlineEdit"><br/>
apex:pageBlockSection collapsible="false" title="Section 1: Custom Media Information (Required)"><br/>
apex:outputField value="{!Product_Brief__c.Opportunity__r.Account.Name}" Label="Company Name"/><br/>
apex:outputField value="{!Product_Brief__c.Customer_Number__c}" label="Customer Number"/><br/>
apex:outputField value="{!Product_Brief__c.Billing_Address__c}" /><br/>
apex:outputField value="{!Product_Brief__c.CreatedBy.Name}" Label="Contact Name"/><br/>
apex:outputField value="{!Product_Brief__c.Shipping_Address__c}"/>
</apex:pageBlockSection><br/>
apex:pageblockButtons ><br/>
apex:commandButton action="{!save&view}" value="SAVE"/><br/>
apex:commandButton value="PRINT" onclick="window.print();"/><br/>
apex:commandButton value="Cancel" action="{!Cancel}"/><br/>
/apex:pageblockButtons><br/>
/apex:form>
Extensions
public class gibco {
public Product_Brief__c pb {get;set;}
public User u {get;set;}
private ApexPages.StandardController controller {get;set;}
public boolean bUpdate {get;set;}
public string loggedinUserId = UserInfo.getUserId();
public User u2 = [Select ContactId From User where Id =: '005R0000001Y6h4'];
public String ctId{
get {
// if (ctId==null){
// if (bUpdate){
ctId = u2.ContactId;
// }
return ctId;
// }
}
set;
}
Contact ct = [SELECT AccountId FROM Contact WHERE id=:ctId];
public string getacct(){
Account acct = [SELECT Name FROM Account WHERE id=:ct.AccountId];
return acct.Name;
return null;
}
Opportunity opp = [SELECT Id FROM Opportunity WHERE AccountId=:ct.AccountId LIMIT 1];
public PageReference save&view() {
if(controller.save() != null) {
PageReference congratsPage = Page.page1;
congratsPage.setRedirect(true);
congratsPage.getParameters().put('id',controller.getId());
return congratsPage;
} return null;
}
public PageReference page1(){
return Page.gibcopb;
}
public PageReference page2(){
return Page.gibcopb2;
}
public gibco(ApexPages.StandardController controller) {
}