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
dwwrightdwwright 

Related list values not refreshing on sites pages

I'm setting up a "Wizard" using force.com sites. I'm implementing this with visualforce and apex.

 

The page allows a user to submit information which creates an opportunity, and then takes them to a second page that allows them to create objects for quotation which are child objects to opportunity, or attach files to the opportunity.

 

When the user finishes, they are taken to a page that displays their information back to them. I am displaying a related list of the child objects they have created, and a related list of all attachments. I also give them the ability to go back and edit the items they have entered.

 

The problem is that if a user edits an item and then returns to the confirmation page, the related list of objects and attachments does not update. New items they create dont show up, and changes they have made aren't reflected on the related list. If I click the refresh button, then the changes will be reflected, so on the database end of it, the DML is happening, but the changes are not reflected on the sites page. All of my methods setRedirect(true) before returning pageReferences. In addition, this problem does NOT happen if I access the site from within Salesforce. If I log in and view the wizard, the information refreshes with absolutely no problems, it is only when viewing it externally via sites that the issue occurs

 

I'll post my code below. Any help would be greatly appreciated.

public with sharing class TechSpecController { /*Instance Variables*/ private SDV_Tech_Specification__c spec; //SDV_Tech_Spec record referred to by the controller private ID rfqId; //Id of the parent Opportunity record for this RFQ public Attachment att {get; private set;} //Holds value from inputField public List<Attachment> attachments; //holds names of attachments //Constructor public TechSpecController(ApexPages.StandardController controller){ rfqId = ApexPages.currentPage().getParameters().get('rfq'); this.spec = (SDV_Tech_Specification__c)controller.getRecord(); this.spec.Name = 'View'; att = new Attachment(); } //Accessor method for spec variable public SDV_Tech_Specification__c getSpec(){ return spec; } //Accessor method for the attachments list //(used to display attached files) back to user public List<Attachment> getAttachments() { attachments = [select Name from Attachment where ParentId = :rfqId]; return attachments; } //Submits the request to add an attachment public PageReference attach() { try { att.ParentId = rfqId; insert att; PageReference theRef = ApexPages.currentPage(); theRef.setRedirect(true); return theRef; } catch(System.DmlException e) { PageReference theRef = ApexPages.currentPage(); theRef.setRedirect(true); return theRef; } }//end attach method //Inserts the current spec and refreshes the page to enter a new one public PageReference create(){ spec.Opportunity__c = rfqId; insert spec; PageReference theRef = new PageReference('/apex/sdvSpec?rfq=' + rfqId); theRef.setRedirect(true); return theRef; }//end create method //Inserts the current Spec and takes the user to the confirmation page public PageReference createLast(){ spec.Opportunity__c = rfqId; insert spec; //direct to confirmation page return done(); }//end createLast method //Updates the changes and returns the user to public PageReference saveChanges() { update spec; //direct to confirmation page return done(); }//end saveChanges method //Deletes this spec and takes user back to confirmation page public PageReference del() { delete spec; //direct to confirmation page return done(); }//end del method //Takes user back to the confirmation page public PageReference done() { PageReference theRef = new PageReference('/apex/RFQConfirmation?id=' + rfqId); theRef.setRedirect(true); return theRef; }//end done method

 

}//end class

 

 

 

<apex:page standardController="Opportunity" extensions="RFQController" showHeader="false"> <!-- <apex:relatedList list="SDV_Tech_Specifications__r"/>--> <apex:pageBlock id="TechSpecList" title="Requested Specifications"> <apex:pageBlockButtons location="top" > <apex:commandButton value="New" action="{!addNew}" /> </apex:pageBlockButtons> <apex:pageBlockTable var="spec" value="{!Opportunity.SDV_Tech_Specifications__r}" columns="15"> <apex:column > <apex:outputLink value="/apex/sdvSpec?id={!spec.Id}&rfq={!Opportunity.Id}">Edit</apex:outputLink> </apex:column> <apex:column value="{!spec.Qty__c}" /> <apex:column value="{!spec.Rated_Max_kV__c}" /> <apex:column value="{!spec.Rated_Short_kA__c}" /> <apex:column value="{!spec.Rated_Cont_A__c}" /> <apex:column value="{!spec.Lightning_Impulse_BIL__c}" /> <apex:column value="{!spec.Motor_Volt__c}" /> <apex:column value="{!spec.Close_Volt__c}" /> <apex:column value="{!spec.Trip_Volt__c}" /> <apex:column value="{!spec.Heater_Volt__c}" /> <apex:column value="{!spec.Substation__c}" /> </apex:pageBlockTable> </apex:pageBlock> <apex:pageBlock title="Attached Specifications"> <apex:pageBlockButtons location="top" > <apex:commandButton value="Add Attachment" action="{!addNew}" /> </apex:pageBlockButtons> <apex:pageBlockTable columns="1" var="att" value="{!Opportunity.attachments}"> <apex:column value="{!att.Name}" /> </apex:pageBlockTable> </apex:pageBlock> <br/> <center><apex:commandButton style="font-size:16px" value="Finish" action="{!finish}" /></center> </apex:form> </apex:page>

 

 

 


 

 

Best Answer chosen by Admin (Salesforce Developers) 
RyanGuestRyanGuest

It sounds like your pages are being cached.

 

Have a look at the cache and expires tags in the docs:

 

http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_page.htm

 

Force.com Sites pages set the pages to automatically cache unless overridden. 

All Answers

RyanGuestRyanGuest

It sounds like your pages are being cached.

 

Have a look at the cache and expires tags in the docs:

 

http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_page.htm

 

Force.com Sites pages set the pages to automatically cache unless overridden. 

This was selected as the best answer
dwwrightdwwright
That was indeed the problem. Many thanks!