我正在尝试将 searchService 传递给 Wicket 以供使用。当我在 searchService 没有最终版本的情况下运行它时,我没有遇到任何问题,但我必须将其设为最终版本才能在覆盖的 onSubmit 中使用它。
final SearchService searchService = new SearchService();
Form<?> form = new Form("searchForm") {
public void onSubmit() {
List<File> results = searchService.getSearchResults();
info("Found: " + results.size());
}
};
如果我这样做,我会收到一个错误:
org.apache.wicket.core.util.objects.checker.CheckingObjectOutputStream$ObjectCheckException: The object type is not Serializable!
A problem occurred while checking object with type: test.service.SearchService
Field hierarchy is:
2 [class=test.webui.HomePage, path=2]
private java.lang.Object org.apache.wicket.MarkupContainer.children [class=[Ljava.lang.Object;]
private java.lang.Object org.apache.wicket.MarkupContainer.children[1] [class=org.apache.wicket.markup.html.form.Form, path=2:searchForm]
private final test.service.SearchService test.webui.HomePage$1.val$searchService [class=test.service.SearchService] <----- field that is causing the problem
我是wicket的新手,所以我想知道是否有正确的方法可以做到这一点?