简体   繁体   English

在 vaadin 中保留应用程序

[英]Preserving application in vaadin

I was wondering how to preserve an application when the user leave the application completly by going to another site (for example when the user logs into the application and then goes to nytimes.com and then comes back to the application some components go missing).我想知道当用户通过转到另一个站点完全离开应用程序时如何保留应用程序(例如,当用户登录应用程序然后转到 nytimes.com 然后返回应用程序时,某些组件丢失了)。 To preserve the application on a refresh you can use the @PreserveOnRefresh annotation, but this does not preserve the application when you leave it.要在刷新时保留应用程序,您可以使用 @PreserveOnRefresh 注释,但这不会在您离开应用程序时保留它。 The header, menu and footer are disappearing.页眉、菜单和页脚正在消失。 These three components are have their own class and are only declared in the main ui.这三个组件都有自己的类,并且只在主 ui 中声明。 Each view (or page) has its own class (which sit between the menu and the footer).每个视图(或页面)都有自己的类(位于菜单和页脚之间)。 Everything works fine until the user leaves the webpage and comes back the header, menu, and footer disapear So my question is how to preserve my vaadin application when the user leaves it and comes back?一切正常,直到用户离开网页并返回页眉、菜单和页脚消失 所以我的问题是如何在用户离开并返回时保留我的 vaadin 应用程序?

What components are missing when you go back to the application?返回应用程序时缺少哪些组件? Vaadin applicaction lives as long as web session. Vaadin 应用程序的生命周期与网络会话一样长。 If I go to nytimes.com and then go back before the web session ends, the Vaadin application will survive (if it has @PreserveOnRefresh ) or will be renewed如果我去 nytimes.com 然后在网络会话结束前返回,Vaadin 应用程序将继续存在(如果它有@PreserveOnRefresh )或将被更新

Well, there could be problem with serialization and deserialization from session.好吧,会话中的序列化和反序列化可能存在问题。 Make sure you have implemented Serialization interface for your own classes.确保您已经为自己的类实现了Serialization接口。

Have you tried to repaint the missing components?您是否尝试过repaint丢失的组件? They should be set to setImmediate(false) during repaintRequest .它们应该在repaintRequest期间设置为setImmediate(false)

Anyway, ordinary Vaadin application works without problem after returning back from other url.无论如何,从其他 url 返回后,普通的 Vaadin 应用程序可以正常工作。 So good luck.所以祝你好运。

To solve this situation you can add a listener to the navigator which will get the uri to the page you are going to and check your permissions.要解决这种情况,您可以向导航器添加一个侦听器,它将获取您要访问的页面的 uri 并检查您的权限。 If you do not have permission it will keep you on the same page and give you a notification saying that you are not allowed to go to this page.如果您没有权限,它会将您保留在同一页面上,并通知您不允许访问此页面。 If they are allowed you will proceed to direct them to that page.如果他们被允许,您将继续引导他们到该页面。

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

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