【问题标题】:Adobe Air Application How to clear the data?Adobe Air Application 如何清除数据?
【发布时间】:2020-11-16 16:55:21
【问题描述】:

我们正在将 Adob​​e Flex 应用程序迁移到 Adob​​e Air 应用程序,并且许多功能都运行良好。但是我们遇到的主要问题是如何在注销后清除所有数据/记录/会话?

  1. 使用用户名/密码登录 Adob​​e Air 应用程序。
  2. 成功登录后,进入任意菜单项。
  3. 点击注销按钮。
  4. 用户重定向到登录页面。
  5. 用户再次登录时,将显示用户注销所有数据的同一窗口。

那么在 Adob​​e Air 中如何清除会话数据或用户退出时如何清除所有组件?

【问题讨论】:

  • 请添加您的代码以了解我可以如何帮助您。
  • @JoeTaras 感谢您的评论。您想查看代码的哪一部分?在注销按钮中单击我正在调用 sessionManager.logout() 方法,这是适用于 flash 项目的 Flex 代码。在 Adob​​e Air 中,我们是否有任何会话对象,或者我们必须一个一个地删除所有组件
  • 当我执行 logOut 操作时,通常我会销毁所有无用的对象,如果我有 userLogged 变量,请重置它。因此,当我重新加载登录页面时,请清除未与 businnes 对象变量绑定的文本。因此,当我尝试再次登录时,我会在那一刻构建要在后端发送的对象。重要的是我重置了所有经过身份验证的频道
  • 您有任何示例代码,您在 Adob​​e AIR 中的表现如何?

标签: actionscript-3 flash air adobe


【解决方案1】:

如你所愿,我在这里添加一段关于从应用程序注销的代码:

public function logoutApplication(isSessionDown:Boolean=false):void
{
    // This method close other open windows (because in AIR you can open more than one window)
    closeOtherWindows();

    // Here I want to manage a sessionExpired variable in model locator so I can use for further aim
    if (CoreML.getInstance()!=null && CoreML.getInstance().sessionExpired){
        ModelLocator.getInstance().sessionExpired=true;
        CoreML.getInstance().sessionExpired=false;
    }

    // Here I remove all opened popup
    var listPopUp:IChildList = FlexGlobals.topLevelApplication.systemManager.popUpChildren;
    for (var i:int = 0; i < listPopUp.numChildren; i++) {
        var curr:IFlexDisplayObject = listPopUp.getChildAt(i) as IFlexDisplayObject;
        try {
            if (curr != null) {
                PopUpManager.removePopUp(curr);
            }
        }
        catch(ex:ExceptionFrontEndHandler) {
            // If you arrive here, it isn't a popup
        }
    }

    // here I update my component menu (it's business logic is not important)
    if (this.cntComponentMenu != null) {
        var newMenuComp:ComponentMenu = new ComponentMenu();
        newMenuComp.container=this;
        this.cntComponentMenu.removeAllElements();
        this.cntComponentMenu.addElement(newMenuComp);
    }

    // Here I change the state of my main MXML to login and clean the text box (not binded with BO)
    this.currentState='login';
    if (this.cntLogin!=null){
        this.cntLogin.currentState='State1';
        this.cntLogin.validateNow();
        this.cntLogin.userId.text="";
        this.cntLogin.password.text="";
    }
            
    if (!isSessionDown) EnvDispatcher.resetInfoSession(this);
        else mypackage.ModelLocator.getInstance().logout=true;
}

这里是EnvDispatcher.resetInfoSession的result命令代码:

if (this.evt.sender!=null && this.evt.sender is UncertaintyAIR) {
        var pnl:MyApplication = this.evt.sender as MyApplication;
        pnl.currentState='login';
        pnl.validateNow();
        pnl.groupLogin.removeAllElements();
        LoginDispatcher.logout();
        LoginDispatcher.logoutSecure();
        mypackage.ModelLocator.getInstance().logout=true;
        var loginView:LoginView = new LoginView();
        loginView.container=pnl;
        pnl.groupLogin.addElement(loginView);
}

【讨论】:

  • 谢谢 看看它是否可以容纳在我的代码库中。
  • 不客气。我尝试在LinkedIn上写进一步讨论
  • 领英?关于 Adob​​e AIR?
  • @SubodhJoshi:是的,亲爱的
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-05-26
  • 1970-01-01
  • 2010-12-02
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多