简体   繁体   English

GWT 的登录问题

[英]Login problem with GWT History

I have the follow problem.我有以下问题。 This is the situation i've got when user login the application and register History.这是我在用户登录应用程序并注册历史记录时遇到的情况。 The workflow is: 1. There is a checking if user is already login- meaning if user object is in the session if not then login form is loaded and a new token is added (History.newItem("login")) if yes then the user is free to enter the main form in the application and a token is added (History.newItem("main")).工作流程是: 1. 检查用户是否已经登录 - 意思是用户 object 是否在 session 中,如果没有,则加载登录表单并添加新令牌(History.newItem("login")),如果是,则用户可以在应用程序中自由输入主窗体并添加一个令牌(History.newItem("main"))。 After user enter pass and user successfully then a new token is added (History.newItem(main)) and enter the application main form.用户输入 pass 并成功后,添加一个新令牌(History.newItem(main))并进入应用程序主窗体。

And here is the problem, after main form is displayed and user decide to click "Back" in the browser then "login" token is taken from the stack and login form is loaded.这就是问题所在,在显示主表单并且用户决定在浏览器中单击“返回”之后,从堆栈中获取“登录”令牌并加载登录表单。 But let assume user decide to click on "Forward " browser button and then "main" token is taken and main form displayed.但是假设用户决定单击“转发”浏览器按钮,然后采用“主”令牌并显示主表单。 I don't like this scenario and want to do: After "back" button to appear a Dialog box and ask "Leave application?"我不喜欢这种情况,想做:在“返回”按钮后出现一个对话框并询问“离开申请?” with "Yes" and "No" button but i can't identify when i have regular login or "back/forward" login in order to do some action.使用“是”和“否”按钮,但我无法识别何时进行常规登录或“后退/前进”登录以执行某些操作。

Any advice or approaches.. probably my design is wrong..任何建议或方法..可能我的设计是错误的..

Any way to distinguish back or forward action?有什么方法可以区分向后或向前的动作吗?

If you want to avoid all this then don't put "login" in history.如果您想避免所有这些,请不要将“登录”放在历史记录中。

In this case you might want to implement login panel as modal dialog.在这种情况下,您可能希望将登录面板实现为模式对话框。 So when user (or application) requests login, a modal dialog is shown with login entry field.因此,当用户(或应用程序)请求登录时,会显示一个带有登录输入字段的模式对话框。 When done with login, just close the dialog and reload the current page (to reflect the changes affected by login).完成登录后,只需关闭对话框并重新加载当前页面(以反映受登录影响的更改)。

You can use 'History.fireCurrentHistoryState()' to force reloading the current page.您可以使用“History.fireCurrentHistoryState()”强制重新加载当前页面。 This calls your history handlers, but it does not affect the history (no token is added to history stack).这会调用您的历史处理程序,但它不会影响历史(没有令牌添加到历史堆栈)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM