【发布时间】:2017-06-17 17:53:35
【问题描述】:
我是 Apache Isis 的新手,但我被困住了。
我想创建我自己的带有可编辑参数的提交表单,用于搜索一些实体和一个带有下面搜索结果的网格。
首先,我创建了@DomainObject(nature=Nature.VIEW_MODEL) 与搜索结果集合、搜索参数和@Action 搜索。 经过深入研究,我发现了严格的操作实现(例如 ActionParametersFormPanel)。我可以在没有提示的情况下使用@Action 并编辑@DomainObject 属性(我的操作搜索参数)吗? 可以通过layout.xml实现吗?
然后我尝试按照此处所述更改组件:6.2 Replacing page elements,但我很困惑我应该使用哪个 ComponentType 和 IModel,也许是 ComponentType.PARAMETERS 和 ActionModel,或者为我的案例实现我自己的 IModel。
我是否应该实现自己的 Wicket 页面进行搜索并通过 PageClassList 接口注册它,如下所述:6.3 Custom pages 据我了解,我需要替换 PageType 之一的页面类,但我应该更改哪一个?
那么,问题是如何正确实施这些问题?我应该选择哪种方式?
谢谢!
===================== 更新===================
我已经以这种方式实现了 HomePageViewModel:
@DomainObject(
nature = Nature.VIEW_MODEL,
objectType = "homepage.HomePageViewModel"
)
@Setter @Getter
public class HomePageViewModel {
private String id;
private String type;
public TranslatableString title() {
return TranslatableString.tr("My custom search");
}
public List<SimpleObject> getObjects() {
return simpleObjectRepository.listAll();
}
@Action
public HomePageViewModel search(
@ParameterLayout(named = "Id")
String id,
@ParameterLayout(named = "Type")
String type
){
setId(id);
setType(type);
// finding objects by entered parameters is not implemented yet
return this;
}
@javax.inject.Inject
SimpleObjectRepository simpleObjectRepository;
}
我想在没有任何对话框窗口的情况下实现一个带有参数的内置 ViewModel 操作,就像这样:
1) 是否可以基于 ComponentType.PARAMETERS 和 ActionModel 创建类似 ActionParametersFormPanel 的东西,并在我的 ViewModel 中将此组件用作@Action?
2) 或者我应该使用,如你所说,ComponentType.COLLECTION_CONTENTS?据我了解,我的搜索结果网格和我的搜索输入面板将像一个我的存根组件?
谢谢。
【问题讨论】: