我一直在使用 Swing 应用程序框架,并且对其 session 状态存储非常满意。 我想知道是否可以删除(清理)持久状态。
- 所有对话框表单。 或
- 特定对话框形式。
如果没有,是否有人找到了一种干净的方法来实现此目的(存储的文件不会保存在同一位置,具体取决于操作系统等......)。
谢谢
最佳答案
您可以通过LocalStorage删除相应的文件(忘记了命名的具体细节),这是我使用的代码片段(与bsaf一起使用,但没有改变太多,公平)
/**
* Deletes the session state by deleting the file. Useful during development
* when restoring to old state is not always the desired behaviour.
* Pending: this is incomplete, deletes the mainframe state only.
*/
protected void deleteSessionState() {
ApplicationContext context = getContext();
try {
context.getLocalStorage().deleteFile("mainFrame.session.xml");
} catch (...) {
}
}
关于java - Swing 应用程序框架 session 存储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5729152/