加载日志查看页面时如何设置Form<BgwElasticSearchFields>
的默认值?基本上,在加载页面之前,我需要为Bic
和dtTo
,dtFrom
设置默认值。我尝试了setDefaultModel
,但我不太理解。有什么帮助吗?谢谢!
@Override
protected Form<ElasticSearchFields> getSearchForm() {
Form<ElasticSearchFields> logSearchForm = new Form<ElasticSearchFields>("searchFields",
new CompoundPropertyModel<>(searchFields)) {
logSearchForm.add(new DateTextField("dtTo", new PropertyModel<>(searchFields, "dtTo"), "yyyy-MM-dd").setRequired(true));
logSearchForm.add(new DateTextField("dtFrom", new PropertyModel<>(searchFields, "dtFrom"), "yyyy-MM-dd").setRequired(true));
List<String> bics = Arrays.stream(Bic.values())
.map(Bic::name)
.collect(Collectors.toList());
logSearchForm.add(new DropDownChoice<>(
"bic",
new PropertyModel<>(searchFields, "bic"),
bics).setNullValid(true).setRequired(false));
return logSearchForm;
}
最佳答案
您需要在searchFields
中初始化默认值。成功提交后,Wicket将使用浏览器发送的值覆盖它们。