10 Replies Latest reply on Sep 25, 2009 8:25 AM by Ramesh Katakam

    Data passing from Flex to Jsp Iframe

    Ramesh Katakam Level 1

      Hi,

       

      I need input on the following issue.

       

      I have webpublichser web application which opens Flex page in inline IFRAME from the jsp page and Flex code does some process.

      From the Flex AS i have to send the data back to Jsp page and once the data is back in Jsp will be closing IFRAME which is nothing but Flex application.Pls give me how to send the data back to Jsp.

       

      I have tried following options

       

       

       

       

       

       

      var

       

       

       

      var request:URLRequest = new URLRequest(urlString);

      navigateToURL(request,

      "_parent"

       

       

       

      //ExternalInterface.call("javascript:window.opener = parent;parent.handleResponse("+wpParam+")");

       

      but could not able to do pls help me in this

       

       

      Thanks

      Ramesh

       

      urlString:String = "javascript:window.opener = parent;parent.handleResponse("+wpParam+");

       

       

        • 1. Re: Data passing from Flex to Jsp Iframe
          jake_flex Level 2

          Have you tried to make a HTTP request to the jsp from you Flex app using HTTPService?

          • 2. Re: Data passing from Flex to Jsp Iframe
            Ramesh Katakam Level 1

            Yes, but my requirement is

             

            Flex application will be opening in jsp page as inline IFRAME and and does process and sends data then the jsp page will get the data which i have sent back to jsp update the fileds with data without refreshing and needs to close the IFRAME.

             

            Pls help me

             

            thanks

            Ramesh

            • 3. Re: Data passing from Flex to Jsp Iframe
              jake_flex Level 2

              Ramesh Katakam wrote:

               

              Yes, but my requirement is

               

              Flex application will be opening in jsp page as inline IFRAME and and does process and sends data then the jsp page will get the data which i have sent back to jsp update the fileds with data without refreshing and needs to close the IFRAME.

               

              Pls help me

               

              thanks

              Ramesh

              I don't understand how does this prevent you from using HTTPService, if after sending the parameters you will close the Flex app.

              • 4. Re: Data passing from Flex to Jsp Iframe
                Ramesh Katakam Level 1

                Yes,

                 

                 

                Could pls find attached screen shot for clear explanation.

                 

                Please let me know if you need any other inputs.

                 

                 

                Thanks

                Ramesh

                • 5. Re: Data passing from Flex to Jsp Iframe
                  Ramesh Katakam Level 1

                  Could you please find the attached doc for clear

                   

                   

                  Pls help me in this

                  • 6. Re: Data passing from Flex to Jsp Iframe
                    Ramesh Katakam Level 1

                    Pls find the attached doc for clear

                    • 7. Re: Data passing from Flex to Jsp Iframe
                      Ramesh Katakam Level 1

                      Pls find the attached doc for clear

                      • 8. Re: Data passing from Flex to Jsp Iframe
                        Ashudeep Sidana

                        I didnt get ur problem completely , but if u want that data on some action from jsp u can have a javascript function which will call ur Actiong script function and will return the result u need.

                         

                        In javascript , u simply have to do

                            var abc = getElementById("(Whatevre is the Id for ur embedded object)").myCallingfunction() - (This function is there in ur actionscript)

                         

                        And in ActionScript u need to addCallBacks in some function and call that function on creation complete:

                         

                         

                        ExternalInterface.

                        addCallback("functionName String",function Name (this would be myCallingfunction));

                         

                        and implement this function in ur AS.

                         

                        Hope it will solve ur problem

                        • 10. Re: Data passing from Flex to Jsp Iframe
                          Ramesh Katakam Level 1

                          no jsp page in webpublisher application it will be another application there from one jsp page they will be calling as

                           

                          function callToServer() {

                            var IFrameDoc;

                           

                            var URL = "http://d-176554:8080/TTTaggingTool/TTTaggingTool.html"   - this is flex application url

                           

                            var responseMessage = document.getElementById('responseMessage');
                            responseMessage.style.display = 'inline';
                            responseMessage.innerHTML = '';

                            try {
                             var tempIFrame=document.createElement('iframe');
                             tempIFrame.setAttribute('id','RSIFrame');
                             tempIFrame.style.border='1px';
                             tempIFrame.style.width='700px';
                             tempIFrame.style.height='350px';
                             tempIFrame.style.marginheight='1px';
                             tempIFrame.style.marginwidth='1px';
                             tempIFrame.style.align="middle";
                             //tempIFrame.style.position = "absolute";
                             tempIFrame.style.display = "block";
                             tempIFrame.scrolling = "no";
                             IFrameObj = document.body.appendChild(tempIFrame);
                             var container = document.getElementById("theFormDiv");
                             IFrameObj = container.appendChild(tempIFrame);
                            
                             if (document.frames) {
                              // this is for IE5 Mac, because it will only allow access to the document object
                              // of the IFrame if we access it through the document.frames array
                              IFrameObj = document.frames['RSIFrame'];
                             }
                            } catch(exception) {
                             // This is for IE5 PC, which does not allow dynamic creation
                             // and manipulation of an iframe object. Instead, we'll fake
                             // it up by creating our own objects.
                             iframeHTML='<iframe id="RSIFrame" style="';
                             iframeHTML+='border:2px;';
                             iframeHTML+='width:20px;';
                             iframeHTML+='height:20px;';
                             iframeHTML+='"><\/iframe>';
                             document.body.innerHTML+=iframeHTML;
                             IFrameObj = new Object();
                             IFrameObj.document = new Object();
                             IFrameObj.document.location = new Object();
                             IFrameObj.document.location.iframe = document.getElementById('RSIFrame');
                             IFrameObj.document.location.replace = function(location) {
                              this.iframe.src = location;
                             }
                            }
                           
                            if (navigator.userAgent.indexOf('Gecko') !=-1 && !IFrameObj.contentDocument) {
                             // we have to give NS6 a fraction of a second
                             // to recognize the new IFrame
                             setTimeout('callToServer("'+theFormName+'")',10);
                             return false;
                            }
                           
                            if (IFrameObj.contentDocument) {
                             // For NS6
                             IFrameDoc = IFrameObj.contentDocument;
                            } else if (IFrameObj.contentWindow) {
                             // For IE5.5 and IE6
                             IFrameDoc = IFrameObj.contentWindow.document;
                            } else if (IFrameObj.document) {
                             // For IE5
                             IFrameDoc = IFrameObj.document;
                            } else {
                             return true;
                            }
                            IFrameDoc.location.replace(URL);
                           
                            //window.open(URL);
                           
                            return false;
                          }

                           

                           

                           

                          and one more java script method in jsp which ha sto take the data and close the flex application which is opened from this jsp with above url as INLINE IFRAME.

                           

                          function handleResponse(rid) {
                            // get a reference to the multiple select list, which we will populate
                            // with the data from the document loaded in the IFRAME

                            alert('Got it :'+rid);
                            var prod_names = document.getElementById("prodnameid_value");
                            var ver_nums = document.getElementById("prodverid_value");
                            var prod_ids = document.getElementById("proid_value");
                            var ver_ids = document.getElementById("verid_value");
                            //prod_names.value = rid;

                          }

                           

                          pls find the attached screen shot for clear