Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass and retrieve values to/from popup window in Flex?

I want to send some text value to my custom popup window when it pops up from main application which is having some text input and also I want to know how to retrieve data(of text input) which entered by a user in popup window. Any help is appreciated.

like image 244
Kishor Kumar Avatar asked Aug 10 '11 05:08

Kishor Kumar


People also ask

How to reverse a string in a popup window?

A popup window opens with the value entered in the Parent page. In this second part, we will reverse the string and pass the reversed string back to the parent page. To do so, follow these steps: Step 1: Add additional functions to the pop.js file which will reverse the string and return the string back to the parent page.

How to return a value from modal pop up window in JavaScript?

If you want to open a normal pop up window then Just comment the line for window.ShowModalDialog and uncomment the line for window.open in the above function. In modal pop up window, we can return a value using returnValue property.

How to make the popup appear in front of the page?

At the most, you can use ‘modal=yes’ to make the popup appear in front. However unlike the showModalDialog () in IE, you cannot restrict the user to access the parent page when the popup is opened in Firefox.

What is the advantage of well-passing the control to the popup?

Well passing the control has an advantage where there is more than one control that is passed to the popup page. While returning back the values from the popup to the parent page; it helps you to decide and determine which control receives which value.


2 Answers

You can access popUp data using setter as example shows. Or make a popUp component as a global in your main application so you can refer component properties globally.

<!-- TitleWindow.mxml -->
<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:fx="http://ns.adobe.com/mxml/2009" 
            xmlns:mx="library://ns.adobe.com/flex/mx" layout="absolute" width="600" title="" height="160">

<fx:Script>
       <![CDATA[            

           public function get UserTypedData():String
           {
                return tiSomeText.text;
           }
    ]]>
</fx:Script>

<fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<mx:TextInput id="tiSomeText" x="76" y="101"/>

<!-- Application.mxml -->
<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
            xmlns:mx="library://ns.adobe.com/flex/mx" layout="absolute" width="100%" >

<fx:Script>
    <![CDATA[                           
                public var popup:YourPopupWindow;

                private function createPopUp():void
                {
                    popup = YourPopupWindow(PopUpManager.createPopUp(this, YourPopupWindow, false));
                }

                private function getPopUpData():String
                {
                    var retVal:String = "";

                    if (popUp != null)
                    {
                        // get data from setter
                        retVal = popUp.UserTypedData();
                        // of from TextInput
                        retVal = popUp.tiSomeText.text;
                    }

                    return retVal;   
                }

    ]]>
</fx:Script>
</mx:Application>
like image 153
Jarno Lahtinen Avatar answered Oct 07 '22 03:10

Jarno Lahtinen


var popup:YourPopupWindow = PopupManager.createPopup(YourPopupWindow, true) as YourPopupWindow;
popup.someData = yourData;
like image 4
J_A_X Avatar answered Oct 07 '22 02:10

J_A_X