You need to sign in to do that
Don't have an account?
Call a function in flex application from APEX code.?
Hi,
I have a flex swf object as a static resource and have embedded in my VF Page...
I am calling a jsp page and retrieving xml data. Now i want to push this data into my flex swf.. how to do it?
I have a function like below in my flex app.
public function BuildTree(str:String):void{
//code....
}
also i have exposed this as a externalinterface call by adding the below code
ExternalInterface.addCallback("BuildTree", BuildTree);
I can call this from a javascript in my VF page and push the xml into it... But since i am getting the xml only during execution of apex code, what should i do? below is my apex code..
public void GetData(){
Http http = new Http();
HttpRequest req = new HttpRequest();
HttpResponse res;
req.setEndpoint('www.mysite.com/sendxmldata.jsp?userId='+userName);
req.setMethod('GET');
req.setTimeOut(30000);
req.setHeader('Cookie',cookieString);
res = http.send(req);
outputText = res.getBody();
}
I will fire this GetData function on click of a button in my VF Page..
This outputText will be a XML, i now want to push this xml into the my flex code by BuildTree function so that my flex app refreshes.... How should i do it?
Thanks and Regards,
Dinesh
Hi,
I have achieved the above by following method. Please let me know if it is very bad... but it solved my requirement.
I called that function BuildTree in my application's creationComplete event...
In My VF Page code, i put the swf embed object inside a apex:outputPanel control and set it as renderer to my apex controlbutton..... Also i set a flashvar paramter bound to the xmlString from the response.
so when my button is clicked, the output panel is re-rendered, and so the application is built again and the buildtree method is called, this time from flashvar i can retrieve the xml.. :)
Thanks,
Dinesh