You need to sign in to do that
Don't have an account?
How do I pass a string value from controller class to apex:iframe in a visualforce page
Hi,
I have created an object say widget and in that object I have created two fields
1.)Name
2.)iframe:Into this iframe I'll paste the code of a widget(for ex:<script type="text/javascript" src="http://cdn.widgetserver.com/syndication/subscriber/InsertWidget.js"></script><script type="text/javascript">if (WIDGETBOX) WIDGETBOX.renderWidget('e0e820ae-5ea6-4688-b15d-b833c87f96e6');</script>
<noscript>Get the <a href="http://www.widgetbox.com/widget/farm-frenzy-games">Farm Frenzy Games</a> widget and many other <a href="http://www.widgetbox.com/">great free widgets</a> at <a href="http://www.widgetbox.com">Widgetbox</a>! Not seeing a widget? (<a href="http://support.widgetbox.com/">More info</a>)</noscript>)
Now my requirement is to get this iframe code into visualforce dynamically by using <apex:iframe> so that I can display my widget as I required.For this my code is as below
<apex:page standardcontroller="Widgetbox__c" extensions="widgetboxdetail" sidebar="false">
<apex:form >
<apex:pageBlock title="Widget Details">
<apex:pageBlockTable value="{!widgetboxDetail}" var="widgets">
<apex:column value="{!widgets.name}" headerValue="Name"/>
<apex:column value="{!widgets.iframe__c}" headerValue="iFrame Value"/>
</apex:pageBlockTable>
<apex:iframe src="{!iframe}" scrolling="true" height="920"/>
</apex:pageBlock>
</apex:form>
</apex:page>
and the class for this is
public class widgetboxdetail
{
public Widgetbox__c widgetList{get;set;}
public string iframe {get;set;}
public widgetboxdetail(ApexPages.StandardController controller)
{
}
public Widgetbox__c getwidgetboxdetail()
{
widgetList = [select id,Name,iframe__c from Widgetbox__c where Name='Aruna'];
system.debug('name-------'+widgetlist.Name);
system.debug('iframe-------'+widgetList.iframe__c);
iframe =widgetList.iframe__c;
return widgetList;
}
}
so whenever Im saving this program I'm getting an error saying that:URL No Longer Exists
can anyone pls help me in this issue......
Thanks in advance
I'm afraid my answer is that you can't do this. What I am suggesting is that you move the ID and any other specifics from the javascript and put those into their own fields. Then you have a component that contains the base javascript and use merge fields to fill out the id etc.
All Answers
Can you provide an example of the contents of an iframe__c field? It sounds to me like you are trying to create the contents of the iframe via the controller - is that the case?
Excatly Bob we are trying to create the contents of the iframe via the controller
iframe__c = <script type="text/javascript" src="http://cdn.widgetserver.com/syndication/subscriber/InsertWidget.js"></script><script type="text/javascript">if (WIDGETBOX) WIDGETBOX.renderWidget('e0e820ae-5ea6-4688-b15d-b833c87f96e6');</script>
<noscript>Get the <a href="http://www.widgetbox.com/widget/farm-frenzy-games">Farm Frenzy Games</a> widget and many other <a href="http://www.widgetbox.com/">great free widgets</a> at <a href="http://www.widgetbox.com">Widgetbox</a>! Not seeing a widget? (<a href="http://support.widgetbox.com/">More info</a>)</noscript>
This is the code of a widget which was copied.Now I can acheive this code by means of apex:outputtext but it creates security reasons.....Is their any other means to get this code
You can't do that I'm afraid - the purpose of an iframe is to embed another document into a page via its URL.
By security reasons, do you mean that using the outputtext component with escape set to false is considered a security risk? I'm not aware of any other way to do this TBH. If you use a rich text area then javascript will be removed.
Do all of these widgets follow a common pattern? E.g. do you always have the same javascript, use widgetbox etc but replace the id, name, url and so on. If so, could you put this into the page as is and replace those sections of text with merge fields?
excatly......by using apex:outputtext we'll be considering it as a security risk.......
and the second thing was widgets don't have a same javascript....We have to change java sript depending on the widget we required and all other fields like name etc etc......
If I can't get it by any other apex label,How can I start with my project :( :(....This is my first requirement in my project
Can you have multiple components, or is the javscript completely different for all widgets?
The only thing I can suggest is that you build up the javascript via custom fields specific to the widget. Its a long winded approach but it will get you there without the security loophole.
We'll be having only a few different components in javascript and in that the main difference is the id.say for example a google map widget have an id of '6ff02b6c-d0e8-4754-85dd-ce1dbf78f8a2' this kind where as a fernz game widget has an id of '46faaad8-ae84-46f9-935e-e2af788b21f8' this kind
Can you explain your answer more brietly.I have created a custom field iframe and i have placed my code into that field.Now how should I call this into visualforce page without apex:outputtext
I'm afraid my answer is that you can't do this. What I am suggesting is that you move the ID and any other specifics from the javascript and put those into their own fields. Then you have a component that contains the base javascript and use merge fields to fill out the id etc.
ohhk......Thanks a ton bob.....cheers....:)