You need to sign in to do that
Don't have an account?

Reloading an iframe, when a button is clicked in Lightning Component
Hello Everyone,
I want to know how can we reload an iframe which contains a visualforce page,so that the value in visualforce page could be updated, through a button in lightning component.
P.S.- I don't have any code regarding it.
Thanks
Regards
I want to know how can we reload an iframe which contains a visualforce page,so that the value in visualforce page could be updated, through a button in lightning component.
P.S.- I don't have any code regarding it.
Thanks
Regards
you can reload your vf page by below code from lightning component button press.
But keep in mind as i mentioned before you can not set a value from @auraEnabled method to visualforce get;set; property
iframe commponent
js controller
change url with your org URL https://foxindia-dev-ed--c.ap2.visual.force.com/apex/ShowData
visualforce page
apex class
NOTE -:
how it reload vf page on button click ---:
in this code i use <aura:attribute name="ifmsrc" type="String"/> for store src value for iframe .
when the attribute value change it's automatic rerandred by lightning component. but here is one question !! how to change iframe src because src of iframe is always same (vf page link ) now the trick is
i append ?t='+ n after url and value of n is current time so it's change every time and you get a different src and its set on aura:attribute with a new time and same src . and your vf page load in iframe.
=================================================================================================
now when you click on the buttton every time visualforce page is loading and you got an alert message.
if you find any way for set svr value to cnval let me inform :)
add component to your lightning application for testing my code
if you have any doubt in code you can ask here :)
Thanks
All Answers
you can use vf page in lightning component by iframe
go to below link for your requirement
http://jargon.io/salesforcejeff/iframecomponent
Thanks
mark it solve if it helps you :)
you can only refresh existing vf page inside the iframe by click the button . can you sahre your code
Thanks
Component:
<pre>
<aura:component controller="showData">
<aura:attribute name="inptText" type="String"/>
<ui:inputText aura:id="input" label="Enter A Value:" value=""/>
Client-Side Value:<ui:outputText value="{!v.inptText}"/><br/>
<ui:button press="{!c.myAction}">Press</ui:button><br/><!--Ifraim should be reloaded on the press of this button-->
<iframe id="myFrame" style="border: 1px solid" src="https://[domainName]/apex/ShowData" />
</aura:component>
</pre>
Client-Side Controller:
<pre>
({
myAction : function(component, event, helper) {
var inp = component.find("input");
var val = inp.get("v.value");
//alert(val);
var action = component.get("c.assignValue");
action.setParams({
"svr" : val
});
action.setCallback(this,function(response){
var state = action.getState();
if(state==="SUCCESS"){
component.set("v.inptText",response.getReturnValue());
}
});
$A.enqueueAction(action);
var frame = document.getElementById("myFrame");
frame.src=frame.src;
}
})
</pre>
Server-Side Controller:
<pre>
public with sharing class showData {
public static string val{get{
val=cnval;
return val;
} set;}
private static string cnval;
@AuraEnabled
public static string assignValue(string svr){
cnval=svr;
return svr;
}
}
</pre>
VF page:
<pre>
<apex:page controller="showData" showHeader="false" standardStylesheets="false">
<apex:form>
<apex:outputText value="{!val}"/>
</apex:form>
</apex:page>
</pre>
Thanks
public with sharing class showData {
public static string val{get{ val=cnval;
return val;
} set;}
private static string cnval;
@AuraEnabled
public static string assignValue(string svr){
cnval=svr; // its aura method never set value for private static string cnval;
return svr;
}
}
you can reload your vf page by below code from lightning component button press.
But keep in mind as i mentioned before you can not set a value from @auraEnabled method to visualforce get;set; property
iframe commponent
js controller
change url with your org URL https://foxindia-dev-ed--c.ap2.visual.force.com/apex/ShowData
visualforce page
apex class
NOTE -:
how it reload vf page on button click ---:
in this code i use <aura:attribute name="ifmsrc" type="String"/> for store src value for iframe .
when the attribute value change it's automatic rerandred by lightning component. but here is one question !! how to change iframe src because src of iframe is always same (vf page link ) now the trick is
i append ?t='+ n after url and value of n is current time so it's change every time and you get a different src and its set on aura:attribute with a new time and same src . and your vf page load in iframe.
=================================================================================================
now when you click on the buttton every time visualforce page is loading and you got an alert message.
if you find any way for set svr value to cnval let me inform :)
add component to your lightning application for testing my code
if you have any doubt in code you can ask here :)
Thanks
I have embeeded map in a lightning component. I want to update/reload map when I change the values.
Thanks
Yashita
I have query related to reloading the map component. The approach followed to get the map via iframe and pointing it to VF page.
Code Structure: Note: Event is fired on button click to go onto map component.
I am unable to refresh the map component when user changes value in filter component and click on button. Can anyone help me.
October 10, 2017