弹出窗口中弹性视图之间的导航

时间:2013-07-25 11:13:08

标签: flex

enter image description here

我从事Flex应用程序。我有以下问题:事实上,在第一页中会出现一个authentification弹出窗口,只有当用户存在于数据库中时才会关闭。这部分工作正常,但我想在弹出窗口中建立一个帮助用户恢复其帐户的链接。我的问题我不知道如何导航到恢复电子邮件的页面,我使用状态,但它没有工作,请你帮我。这是authentification popup的代码

<?xml version="1.0" encoding="utf-8"?>
<s:TitleWindow xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/mx"
               xmlns:services="services.*"
               x="400" y="400" width="400" height="196" cornerRadius="10"
               creationComplete="doInit();" fontSize="12" title="Authentication" xmlns:local="*">
    <fx:Declarations>
        <s:CallResponder id="authenticateUserResult"/>
        <services:UserServiceImpl id="userServiceImpl"
                                  fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"
                                  showBusyCursor="true">
            <services:channelSet>
                <s:ChannelSet>
                    <s:AMFChannel uri="http://localhost:8080/SmartSupport/messagebroker/amf"/>
                </s:ChannelSet>
            </services:channelSet>
        </services:UserServiceImpl>
        <s:CallResponder id="setMyStringResult"/>
        <services:MySessionHandler id="mySessionHandler"
                                   fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"
                                   showBusyCursor="true">
            <services:channelSet>
                <s:ChannelSet>
                    <s:AMFChannel uri="http://localhost:8080/SmartSupport/messagebroker/amf"/>
                </s:ChannelSet>
            </services:channelSet>
        </services:MySessionHandler>

            <s:CallResponder id="authenticationResp"/>

        <!-- Placer ici les éléments non visuels (services et objets de valeur, par exemple). -->
    </fx:Declarations>


    <fx:Script>
        <![CDATA[
            import com.roamsmart.acl.CurrentUser;

            import mx.controls.Alert;
            import mx.core.Application;
            import mx.core.FlexGlobals;
            import mx.events.CloseEvent;
            import mx.managers.PopUpManager;
            import mx.rpc.events.ResultEvent;

            import valueObjects.UserEntity; 

            [Bindable]
            public var currentU : UserEntity = new UserEntity();

            protected function Login_clickHandler(event:MouseEvent):void
            {
                authenticateUserResult.addEventListener(ResultEvent.RESULT,activateUser);
                authenticateUserResult.token = userServiceImpl.authenticateUser(name_.text, pass.text);             
            } 
            private function doInit():void
            {               
                this.addEventListener(KeyboardEvent.KEY_UP, handleKeyStrokes);

            }

            public function handleKeyStrokes(evt:KeyboardEvent):void
            {
                if(evt.keyCode == Keyboard.ENTER)
                {                   
                    authenticateUserResult.addEventListener(ResultEvent.RESULT,activateUser);
                    authenticateUserResult.token = userServiceImpl.authenticateUser(name_.text, pass.text);     
                }
            }

            private function activateUser(event:Object):void{
                var user:UserEntity = authenticateUserResult.lastResult as UserEntity;
                if(user)
                {
                    if(user.enabled)
                    {
                        CurrentUser.currentUser=user;
                        PopUpManager.removePopUp(this);
                        currentU = user;
                        dispatchEvent(new CloseEvent(CloseEvent.CLOSE, true, false));
                    }
                    else
                    {
                        errorHbox.visible = true;
                        errorLabel.text = "this user account is disabled";
                        name_.text = "";
                        pass.text = "";
                    }

                }
                else
                {
                    errorHbox.visible = true;   
                    name_.text = "";
                    pass.text = "";
                }  

            }

            protected function authenticateUser(arg0:String, arg1:String):void
            {
                authenticateUserResult.token = userServiceImpl.authenticateUser(arg0, arg1);  
            }


        ]]>
    </fx:Script>
    <s:states>
        <s:State name="forgivepasswordState"/>
        <s:State name="index"/>

    </s:states>


    <mx:HBox id="errorHbox" visible="false" width="98%" horizontalAlign="center" paddingLeft="10"
             paddingTop="10" verticalAlign="middle">
        <s:Image width="32" height="32" source="@Embed('assets/warning.png')"/>
        <s:Label id="errorLabel" color="red" fontSize="12" fontWeight="bold"
                 text="Wrong Username/Password combination"/>
    </mx:HBox>  
    <!--<s:Label x="10" y="13" color="#F6800E" fontSize="14"
    text="Your session has been expired, please Log in again"/>-->
    <!--<mx:TextInput id="name_" x="192" y="43" width="157" height="22" text=""/> -->
    <mx:TextInput id="name_" x="189" y="42" width="159" fontSize="15" fontWeight="normal" text=""/>
    <mx:TextInput id="pass" x="191" y="71" width="158" displayAsPassword="true"/>
    <mx:Label x="95" y="44" width="86" height="21" color="#024C9E" fontSize="12" text="User name"/>
    <mx:Label x="96" y="74" width="65" height="21" color="#024C9E" fontSize="12" text="Password"/>
    <s:Button id="linkBtnForgPwd" left="10" bottom="28" width="157" label="I forgot my password"
             color="#000000" cornerRadius="5"
              enabled="true" fontSize="12" icon="assets/lock_key.png"
              skinClass="spark.skins.spark.ButtonSkin" styleName="linkButton"/>
    <s:Button x="191" y="114" width="157" label="Log In" click="Login_clickHandler(event)"
              cornerRadius="5" fontSize="12"/>
    <s:Image x="7" y="115" width="29" height="20" source="assets/forgot_icon.png"/>

</s:TitleWindow>

我已经更正了这段代码,但是当用户点击按钮“我忘了我的密码”时出现的面板出现在弹出窗口上,就像在屏幕截图中提到的那样

![<?xml version="1.0" encoding="utf-8"?>
<s:TitleWindow xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/mx"
               xmlns:services="services.*"
               x="400" y="400" width="400" height="196" cornerRadius="10"
               creationComplete="doInit();" fontSize="12" title="Authentication" xmlns:local="*">
    <fx:Declarations>
        <s:CallResponder id="authenticateUserResult"/>
        <services:UserServiceImpl id="userServiceImpl"
                                  fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"
                                  showBusyCursor="true">
            <services:channelSet>
                <s:ChannelSet>
                    <s:AMFChannel uri="http://localhost:8080/SmartSupport/messagebroker/amf"/>
                </s:ChannelSet>
            </services:channelSet>
        </services:UserServiceImpl>
        <s:CallResponder id="setMyStringResult"/>
        <services:MySessionHandler id="mySessionHandler"
                                   fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"
                                   showBusyCursor="true">
            <services:channelSet>
                <s:ChannelSet>
                    <s:AMFChannel uri="http://localhost:8080/SmartSupport/messagebroker/amf"/>
                </s:ChannelSet>
            </services:channelSet>
        </services:MySessionHandler>

            <s:CallResponder id="authenticationResp"/>

        <!-- Placer ici les éléments non visuels (services et objets de valeur, par exemple). -->
    </fx:Declarations>


    <fx:Script>
        <!\[CDATA\[
            import com.roamsmart.acl.CurrentUser;

            import mx.controls.Alert;
            import mx.core.Application;
            import mx.core.FlexGlobals;
            import mx.events.CloseEvent;
            import mx.managers.PopUpManager;
            import mx.rpc.events.ResultEvent;

            import valueObjects.UserEntity; 

            \[Bindable\]
            public var currentU : UserEntity = new UserEntity();

            protected function Login_clickHandler(event:MouseEvent):void
            {
                authenticateUserResult.addEventListener(ResultEvent.RESULT,activateUser);
                authenticateUserResult.token = userServiceImpl.authenticateUser(name_.text, pass.text);             
            } 
            private function doInit():void
            {               
                this.addEventListener(KeyboardEvent.KEY_UP, handleKeyStrokes);

            }

            public function handleKeyStrokes(evt:KeyboardEvent):void
            {
                if(evt.keyCode == Keyboard.ENTER)
                {                   
                    authenticateUserResult.addEventListener(ResultEvent.RESULT,activateUser);
                    authenticateUserResult.token = userServiceImpl.authenticateUser(name_.text, pass.text);     
                }
            }

            private function activateUser(event:Object):void{
                var user:UserEntity = authenticateUserResult.lastResult as UserEntity;
                if(user)
                {
                    if(user.enabled)
                    {
                        CurrentUser.currentUser=user;
                        PopUpManager.removePopUp(this);
                        currentU = user;
                        dispatchEvent(new CloseEvent(CloseEvent.CLOSE, true, false));
                    }
                    else
                    {
                        errorHbox.visible = true;
                        errorLabel.text = "this user account is disabled";
                        name_.text = "";
                        pass.text = "";
                    }

                }
                else
                {
                    errorHbox.visible = true;   
                    name_.text = "";
                    pass.text = "";
                }  

            }

            protected function authenticateUser(arg0:String, arg1:String):void
            {
                authenticateUserResult.token = userServiceImpl.authenticateUser(arg0, arg1);  
            }


        \]\]>
    </fx:Script>
    <s:states>
        <s:State name="forgivepasswordState"/>
        <s:State name="index"/>

    </s:states>


    <mx:HBox id="errorHbox" visible="false" width="98%" horizontalAlign="center" paddingLeft="10"
             paddingTop="10" verticalAlign="middle">
        <s:Image width="32" height="32" source="@Embed('assets/warning.png')"/>
        <s:Label id="errorLabel" color="red" fontSize="12" fontWeight="bold"
                 text="Wrong Username/Password combination"/>
    </mx:HBox>  
    <!--<s:Label x="10" y="13" color="#F6800E" fontSize="14"
    text="Your session has been expired, please Log in again"/>-->
    <!--<mx:TextInput id="name_" x="192" y="43" width="157" height="22" text=""/> -->
    <mx:TextInput id="name_" x="189" y="42" width="159" fontSize="15" fontWeight="normal" text=""/>
    <mx:TextInput id="pass" x="191" y="71" width="158" displayAsPassword="true"/>
    <mx:Label x="95" y="44" width="86" height="21" color="#024C9E" fontSize="12" text="User name"/>
    <mx:Label x="96" y="74" width="65" height="21" color="#024C9E" fontSize="12" text="Password"/>
    <s:Button id="linkBtnForgPwd" left="10" bottom="28" width="157" label="I forgot my password" click="this.currentState='forgivepasswordState'"
             color="#000000" cornerRadius="5"
              enabled="true" fontSize="12" icon="assets/lock_key.png"
              skinClass="spark.skins.spark.ButtonSkin" styleName="linkButton"/>
    <s:Button x="191" y="114" width="157" label="Log In" click="Login_clickHandler(event)"
              cornerRadius="5" fontSize="12"/>
    <s:Image x="7" y="115" width="29" height="20" source="assets/forgot_icon.png"/>
    <local:forgotPassword includeIn="forgivepasswordState"/>

</s:TitleWindow>][1]

1 个答案:

答案 0 :(得分:0)

我没有看到您尝试更改状态的任何代码。您是否只需要在“忘记图标”图像上添加事件监听器?

<s:Image x="7" y="115" width="29" height="20" source="assets/forgot_icon.png" click="{currentstate='forgivepasswordState'}"/>