I have created a lightning app page with type 'Record Page' and overridden default Opportunities page. I have added a new tab to its content and added a visualforce page as its component. Please see the image below.
The visualforce page contains codes to display documents and download link based on the current stageName of the opportunity. The code is as below.
<apex:page controller="stageDocus">
<apex:panelGrid columns="5" id="theGrid" width="80%" style="margin:30px auto; text-align:center;">
<apex:repeat var="sld" value="{!docs}">
<div style="float:left; width:20%;">
<apex:panelGroup id="theGroup1">
<apex:image width="100%" id="theImage1" value="http://icons.iconarchive.com/icons/alecive/flatwoken/512/Apps-Google-Drive-Slides-icon.png"/>
<apex:outputLink value="/servlet/servlet.FileDownload?file={!sld.Id}" target="_blank" id="theLink1">{!sld.Folder.Name}/{!sld.Name}</apex:outputLink>
</apex:panelGroup>
</div>
</apex:repeat>
</apex:panelGrid>
</apex:page>
The page is working fine when loaded. But if we change the stage, the content is not refreshing. We have to reload the page to see the updated content based on the new stage.
The apex class code I used is a below
public class stageDocus
{
public String currentRecordId {get;set;}
public Opportunity Oppo{get;set;}
public stageDocus() {
currentRecordId = ApexPages.currentPage().getParameters().get('Id');
Oppo = [SELECT Id, Name, StageName, Amount FROM Opportunity WHERE Id = :currentRecordId];
}
public List<Document> getdocs()
{
List<Document> doc = [SELECT Id, Name, FolderId, Folder.Name FROM Document WHERE Folder.Name like :Oppo.StageName];
return doc;
}
}
How can I refresh the visualforce page used as lightning page component whenever the Opportunity StageName is updated. Please help me.