【发布时间】:2015-11-26 11:15:29
【问题描述】:
当从一个页面切换到另一个页面时,我想在表单页面中缓存状态。
所以:我有 3 页的表单,当我从一个表单切换到另一个表单时,我希望数据保留在表单中。
我发现了这个:https://wiki.eclipse.org/Scout/Concepts/Page_Detail_Form
@Override
protected void execPageActivated() throws ProcessingException {
if (getDetailForm() == null) {
PersonDetailForm form = new PersonDetailForm();
form.setPersonNr(getPersonNr());
setDetailForm(form);
form.startView();
}
}
并说 setDetailForm() 缓存数据
As already said, attaching a detail form to a page means the detail form will automatically be
hidden when the page gets deactivated and shown when the page gets activated (see
PageDetailFormChanged on Desktop). So the detail form actually gets cached and does not need to
be started more than once per page. This requires that the form does not get closed.
但这对我不起作用。
我的代码是
@Override
protected void execPageActivated() throws ProcessingException {
// / Create and open form
if (getDetailForm() == null) {
MarginCalculationForm form = new MarginCalculationForm();
form.startModify();
setDetailForm(form);
}
super.execPageActivated();
}
但它停留在最后一页。
例如:
如果我有页面 A、B、C,并且我打开页面 A,它会自行创建并将其设置为 detailForm()。如果我然后打开页面 B 也可以。但是,如果我然后再次单击页面 A,它会检查 detailForm() 是否不为空(并且它不是),因此它会停留在页面 B 上(进入页面 A)
编辑:
我认为 getDetailForm() 正在返回正确的表单,但显然 super.execPageActivated() 不起作用。
【问题讨论】:
-
我无法在我的工作区重现该问题。我在 execPageActivated() 中有一个断点。第一次点击页面,getDetailForm()为null,窗体实例化。我点击其他地方。之后,当我再次进入同一页面时,getDetailForm() 不为空,并且再次显示先前实例化的表单(对应于此页面实例)。 “每次激活该页面时都会刷新表单”是什么意思。
-
我编辑我的问题。以前的行为似乎是由于没有再次启动我的服务器。
-
在客户端控制台日志中是否有堆栈跟踪或类似内容?
-
否,因为没有报错。
-
super.execPageActivated()对应于AbstractPageWithNodes#execPageActivated()还是对应于空的AbstractPage#execPageActivated()。我仍然无法理解您的代码中发生了什么。
标签: forms eclipse-scout