function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Rahul BorgaonkarRahul Borgaonkar 

Force.com sites page refresh Vs Normal page refresh for same visualforce page.

Hi,
I am using a VF page in force.com sites. On the page it has Save and Cancel button. Both buttons are executing controller extension methods saveData and cancelData respectively. Controller extension has constructor too.
Extract from Visualforce page

<apex:page standardController="Special_Event__c" extensions="BSCDelegateCaptureController" id="page"  name="Delegate Capture Form">
    <apex:sectionHeader title="Delegate Capture Form"/>
    <apex:form id="form">
        <apex:pageBlock id="pb">
        <apex:pageMessages id="pm"/>

        <apex:pageBlockButtons id="pbb" location="top">

            <apex:actionStatus id="submitStatus">
                <apex:facet name="stop">
                <apex:outputPanel >
                    <apex:commandButton id="sb" status="submitStatus" value="Submit Details" action="{!saveData}"/> 
                    <apex:commandButton status="submitStatus" value="Cancel" action="{!cancelData}"/>
                </apex:outputPanel>
                </apex:facet>
                <apex:facet name="start">
                <apex:outputPanel >
                    <apex:commandButton value="Submit Details" disabled="true" />
                    <apex:commandButton value="Cancel" disabled="true" />
                </apex:outputPanel>
                </apex:facet>
            </apex:actionStatus>

        </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>
public class BSCDelegateCaptureController
{
    public BSCDelegateCaptureController(ApexPages.StandardController controller)
    {
        system.debug('Inside BSCDelegateCaptureController');
    }

    public PageReference saveData()
    {
        system.debug('Inside saveData');
        PageReference pageRef = new PageReference('/apex/BSCDelegateCapture?id='+BSCEvent.id);
        //PageReference pageRef = new PageReference('/forms/BSCDelegateCapture?id='+BSCEvent.id);
        pageRef.setRedirect(true);
        return pageRef;
    }

    public PageReference cancelData()
    {
        system.debug('Inside cancelData');
        PageReference pageRef = new PageReference('/apex/BSCDelegateCapture?id='+BSCEvent.id);
        //PageReference pageRef = new PageReference('/forms/BSCDelegateCapture?id='+BSCEvent.id);
        pageRef.setRedirect(true);
        return pageRef;
    }
}
When I press Save or Cancel buttonIt should execute saveData or cancelData method
Refresh page and also execute class constructor.While testing in normal salesforce environment it is executing constructor (step2) but it is not executing constructor when page is used in force.com sites.

PageReference pageRef = new PageReference('/apex/BSCDelegateCapture?id='+BSCEvent.id); - Normal url for redirect.
PageReference pageRef = new PageReference('/forms/BSCDelegateCapture?id='+BSCEvent.id); - force.com sites url for redirect.

Kindly let me know what could be the reason. It will help a lot.

Best Regards,

Rahul

 
Best Answer chosen by Rahul Borgaonkar
Rahul BorgaonkarRahul Borgaonkar
Caching Force.com Sites Pages solved this issue
https://help.salesforce.com/HTViewHelpDoc?id=sites_caching.htm&language=en_US