apache-flex 通过弹出窗口在Flex中的视图之间导航

sg24os4d  于 2022-11-01  发布在  Apache
关注(0)|答案(1)|浏览(140)

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

<?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]
7cjasjjr

7cjasjjr1#

我没有看到任何你试图改变状态的代码。你只需要在“忘记图标”图像上添加一个事件侦听器吗?

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

相关问题