我正在研究检票口,我应该在点击导航栏后呈现 vthe 视图没有任何反应,请帮助我。
<div class="colums data" wicket:id="BooksListViewContainer">
<div wicket:id="booksListView">
<div class="col-left data" wicket:id="bookName"></div>
<div class="col-middle data" wicket:id="author"></div>
<div class="col-middle data" wicket:id="genre"></div>
<div class="col-middle data" wicket:id="language"></div>
<div class="col-middle data" wicket:id="datePublished"></div>
</div>
<div wicket:id="navigator" class="navi">xxx</div>
</div>
和java:
public class HomePage extends WebPage {
transient LibaryServices libaryService ;
Component sortBtns [] ;
public HomePage(final PageParameters parameters) {
super(parameters);
initPage();
}
private void initPage() {
libaryService = new LibaryServices();
add(getBooksListViewContainer());
}
private WebMarkupContainer getBooksListViewContainer(){
String id = "BooksListViewContainer" ;
WebMarkupContainer c = (WebMarkupContainer) get(id);
if (c != null)
return c;
final WebMarkupContainer container = new WebMarkupContainer(id);
container.add(getBooksListView());
container.add(getNavigator());
container.setOutputMarkupId(true);
return container;
}
@SuppressWarnings("unchecked")
private PageableListView<Book> getBooksListView() {
String id = "booksListView";
PageableListView<Book> c = (PageableListView<Book>)get(id);
if (c != null)
return c;
final PageableListView<Book> booksListView = new PageableListView<Book>(id, libaryService.getBooks(), 4) {
@Override
protected void populateItem(ListItem<Book> listBookItem) {
Book book = (Book) listBookItem.getModelObject();
listBookItem.add(new Label("author", book.getAuthor()));
listBookItem.add(new Label("bookName", book.getBookName()));
listBookItem.add(new Label("language", book.getBookLanguage()));
listBookItem.add(new Label("genre", book.getGenre()));
listBookItem.add(new Label("datePublished", book.getDatePublished()));
listBookItem.setVisible(listBookItem.isVisible()&&
book.isShouldBeDisplayedAfterPassFilter());
}
@Override
protected IModel<Book> getListItemModel(
IModel<? extends List<Book>> listViewModel, int index) {
return super.getListItemModel(listViewModel, index);
}
};
booksListView.setOutputMarkupId(true);
booksListView.setMarkupId(id);
return booksListView;
}
public SortingDataUtil getSortingDataUtil(){
return SortingDataUtil.getInstace();
}
private AjaxPagingNavigator getNavigator() {
String id = "navigator";
AjaxPagingNavigator navigator = (AjaxPagingNavigator) get(id);
if (navigator == null) {
navigator = new AjaxPagingNavigator(id, getBooksListView()) {
@Override
protected void onAjaxEvent(AjaxRequestTarget target) {
super.onAjaxEvent(target);
}
};
navigator.setOutputMarkupId(true);
}
return navigator;
}
}
这是我得到的例外
意外的运行时异常
Last cause: Argument 'component' may not be null.
WicketMessage: Method onRequest of interface org.apache.wicket.behavior.IBehaviorListener targeted at org.apache.wicket.ajax.markup.html.navigation.paging.AjaxPagingNavigationLink$1@321af6fe on component [AjaxPagingNavigationLink [Component id = pageLink]] threw an exception
堆栈跟踪
根本原因:
java.lang.IllegalArgumentException: Argument 'component' may not be null.
at org.apache.wicket.util.lang.Args.notNull(Args.java:41)
at org.apache.wicket.ajax.AjaxRequestHandler.add(AjaxRequestHandler.java:226)
at org.apache.wicket.ajax.markup.html.navigation.paging.AjaxPagingNavigator.onAjaxEvent(AjaxPagingNavigator.java:152)
at com.wicketlibary.HomePage$3.onAjaxEvent(HomePage.java:146)
at org.apache.wicket.ajax.markup.html.navigation.paging.AjaxPagingNavigationBehavior.onEvent(AjaxPagingNavigationBehavior.java:82)
at org.apache.wicket.ajax.AjaxEventBehavior.respond(AjaxEventBehavior.java:131)
at org.apache.wicket.ajax.AbstractDefaultAjaxBehavior.onRequest(AbstractDefaultAjaxBehavior.java:603)
编辑:我的版本是
<wicket.version>6.6.0</wicket.version>