重置整个 Flex 应用程序 - 所有表单字段和其他用户数据(无 URLRequest/Javascript)

发布于 2024-10-14 00:15:08 字数 286 浏览 1 评论 0原文

重置多用户 Flex 应用程序的最佳实践是什么? 重置我的意思是:

  • 重置用户在会话期间在整个应用程序中留下的所有表单字段和其他数据
  • 重置所有数据网格和包含特定数据的其他组件

...当用户注销应用程序时。

我知道使用 navigatorToURL 或使用 Javascript 重新加载 URL 的方法。但我不喜欢这些方法。主要是因为整个应用程序必须重新加载,这会花费时间,并且对于仅重置数据来说有点残酷。

有没有不需要重新加载 URL 的好替代方法?

What are the best practices to reset multi user Flex applications?
With reset i mean:

  • Reset all form fields and other data the user left throughout the application during his session
  • Reset all datagrids and other components containing specific data

...when the user logs out of the application.

I know the approaches of doing an URL reload with navigateToURL, or by using Javascript. But i don't like these approaches. Mainly because the whole application has to be loaded again, which costs its time and is a bit brute for just resetting data.

Are there any nice alternative approaches which don't require a URL reload?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

甜心 2024-10-21 00:15:08

编写一个方法将您的应用程序设置为默认状态;不管那是什么。将其作为注销过程的一部分运行。

如果您正在寻找某种自动方法来做到这一点,我想不出一种方法。编写这种“自动”算法的人如何知道您的默认值是什么?

Write a method for setting your app into the default state; whatever that is. Run that as part of the log out procedure.

If you're looking for some automatic way to do that, I can't think of one. How would the person writing such an 'automatic' algorithm know what your defaults would be?

懒猫 2024-10-21 00:15:08

首先,@www.Flextras.com 是对的......“默认”状态是由您(应用程序开发人员)定义的。如果您不想重新加载应用程序以重新开始,则需要知道清除所有字段意味着什么。他是绝对正确的,他得到了+1。

话虽如此,我还可以添加一些想法供您集思广益。您始终可以编写一个例程,使用 getElementnumElements 等函数递归地导航可视化树。您可以做一些类似的事情,假设所有 TextInputs 和 TextAreas 都将被清除,并在树中找到它们时清除它们。您甚至可以创建一个配置文件,按树中的名称和默认值列出字段。然后,您可以遍历树,按名称查找元素,并将它们设置为配置中定义的默认值。

但是,您仍然需要了解默认状态以及要清除的内容。从 Flex 的角度来看,属性就是属性。 TextInput.text 并不比 BorderContainer.backgroundAlpha 更特别。如果存在将所有内容设置为“默认”的东西,那么您的应用程序将会自行崩溃。因此,请弄清楚应用程序中“默认”或“重置”的含义。以某种方式封装该定义,这样它就不会遍布在您的代码中,并应用您选择的清除算法。

First, @www.Flextras.com is right... "default" state is defined by you, the application developer. If you don't want to reload the app to start over, you need to know what it means to clear out all of the fields. He is absolutely correct and he gets a +1.

That being said, I can add a few more ideas for you to brainstorm. You can always write a routine that navigates the visual tree using functions like getElement and numElements recursively. You can do something like assume that all TextInputs and TextAreas are to be cleared and clear them when you find them in the tree. You could even go as far is create a configuration files that lists the fields by name in the tree and the default values. You could then traverse the tree, finding elements by name, and setting them to defaults defined in your config.

BUT, you are still left being in charge of knowing what the default state looks like and what to clear. From a Flex perspective, a property is a property. TextInput.text is no more special than BorderContainer.backgroundAlpha. If such a thing existed to set everything to "default", then your app would come crumbling down on itself. So, figure out what it means to be "default" or "reset" in your app. Encapsulate that definition somehow, so it isn't peppered throughout your code, and apply your clearing algorithm of choice.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文