我使用 setViewName() 从操作更改视图并且它可以工作,但是在更改视图后,所有显示的数据都消失了,所有字段都为空白。
这是我的操作代码:
public void execute() throws Exception {
// ...
// Here there is data displayed in the view
if (article.getManagedBy() == ManagedBy.BATCH) {
// Batch is defined as @View(name="Batch", members="...") in the entity
getView().setViewName("Batch");
}
else if (article.getManagedBy() == ManagedBy.SERIE) {
// Serie is defined as @View(name="Serie", members="...") in the entity
getView().setViewName("Serie");
}
// Now no data is displayed though the view has changed
}
如何在保留显示数据的同时更改视图?