1
    <apex:page standardController="Product_Brief__c" sidebar="true" showHeader="true" extensions="SUM">
       <apex:form >
         <apex:pageBlock id="myPanel">
            <apex:pageBlockSection title="Section 1: Custom Media Information" collapsible="false" >
                    <apex:outputField value="{!Product_Brief__c.Opportunity__r.Account.Name}" rendered="{!NOT(bEditMode)}" />
                    <apex:inputField value="{!Product_Brief__c.Customer_Number__c}" rendered="{!bEditMode}"/>
                        <apex:outputField value="{!Product_Brief__c.Customer_Number__c}" rendered="{!NOT(bEditMode)}" />
                    <apex:inputField value="{!Product_Brief__c.Billing_Address__c}" rendered="{!bEditMode}"/>
                        <apex:outputField value="{!Product_Brief__c.Billing_Address__c}" rendered="{!NOT(bEditMode)}" />
                    <apex:outputField value="{!Product_Brief__c.CreatedBy.Name}"  Label="Contact Name" rendered="{!NOT(bEditMode)}" />
                    <apex:inputField value="{!Product_Brief__c.Shipping_Address__c}" rendered="{!bEditMode}"/>  
                        <apex:outputField value="{!Product_Brief__c.Shipping_Address__c}" rendered="{!NOT(bEditMode)}" /> 
                </apex:pageBlockSection>

                 <apex:pageBlockSection title="Section 2: Technical Contact (if applicable)" collapsible="false" columns="2"  >
                    <apex:inputField value="{!Product_Brief__c.Technical_Contact__c}" rendered="{!bEditMode}"/>
                        <apex:outputField value="{!Product_Brief__c.Technical_Contact__c}" rendered="{!NOT(bEditMode)}" />
                    <apex:inputField value="{!Product_Brief__c.Title_Technical__c}" rendered="{!bEditMode}"/>
                        <apex:outputField value="{!Product_Brief__c.Title_Technical__c}" rendered="{!NOT(bEditMode)}" />
                    <apex:inputField value="{!Product_Brief__c.Phone_Technical__c}" rendered="{!bEditMode}"/>
                        <apex:outputField value="{!Product_Brief__c.Phone_Technical__c}" rendered="{!NOT(bEditMode)}" />
                    <apex:inputField value="{!Product_Brief__c.Email_Technical__c}" rendered="{!bEditMode}"/>
                        <apex:outputField value="{!Product_Brief__c.Email_Technical__c}" rendered="{!NOT(bEditMode)}" />
                </apex:pageBlockSection>

            <apex:pageBlockButtons >
                <apex:commandButton value="Previous Page" action="{!page2}"/>   
                <apex:commandButton action="{!doToggleEditMode}" value="Edit" reRender="myPanel" rendered="{!NOT(bEditMode)}" />
                <apex:commandButton action="{!doSave}" value="Save" reRender="myPanel" rendered="{!bEditMode}" />
                <apex:commandButton action="{!save}" value="SAVE"/> 
                <apex:commandButton value="PRINT" onclick="window.print();"/>
                <apex:commandButton value="Cancel" action="{!Cancel}"/>
            </apex:pageBlockButtons>

        </apex:pageBlock>
    </apex:form>

Extension

public class SUM {

    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];


/* *************** Edit Sec. ************************     */ 

    public Boolean bEditMode {
    get {
      if(bEditMode == null) {
          bEditmode = false;
          }
          return bEditMode;
      }
      set;
    }

    public PageReference doToggleEditMode() {
         bEditMode = !bEditMode;
            return null;
    }

    public PageReference doSave() {
        try {
        // Do your stuff to save your record
        controller.save();
        doToggleEditMode();
        }
        catch(Exception ex) {
        // Handle error
        }

        return null;
        }
/* ********************************************** */

    public PageReference page1(){
    return Page.sumpage1;
    }

    public PageReference page2(){
    return Page.sumpage2;
    }

    public PageReference page3(){
    return Page.sumpage3;
    }

    public PageReference save() {
    controller.save(); 
    return null;
    }

    public SUM(ApexPages.StandardController controller) {
       this.controller = controller;
    }

}

When I click on the save button it will save, but my page will break. It suppose to redirect to the same page. But it does not. Anybody have any idea? Thanks

11
  • What is the error?
    – navD87
    Commented Jun 24, 2015 at 15:20
  • Error: Error occurred while loading a Visualforce page. Please email us if you need to get in touch. It will not redirect to the same page and gives me above error. Commented Jun 24, 2015 at 15:21
  • 1
    @DananjayaPathirana Your save function doesn't redirect. See return null;? That means you're explicitly asking to not redirect. You could try return controller.save(); instead.
    – sfdcfox
    Commented Jun 24, 2015 at 15:25
  • @Eric It's a Sites error.
    – sfdcfox
    Commented Jun 24, 2015 at 15:27
  • 1
    @DananjayaPathirana Something like if(controller.save() != null) { PageReference ref = Page.myPage; ref.setRedirect(true); return ref; } return null;. Return no page reference if an error occurs, or a redirect otherwise.
    – sfdcfox
    Commented Jun 24, 2015 at 15:31

1 Answer 1

2

This error means that your Sites user doesn't have permission to do whatever they're trying to do, or they got an exception trying to do it (e.g. NullPointerException in a trigger). See an answer like this one on how you can debug these errors. If it's a permissions error, you need to modify the Sites public profile, and if it's an exception, you need to diagnose and fix it, just like any other. There's no way we can help you any more than to generically say that you need to check permissions and exceptions.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .