0

我正在研究检票口,我应该在点击导航栏后呈现 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>
4

1 回答 1

0

如果您认为这是一个错误,您应该创建一个快速入门并提交。

在你这样做之前,我会改变你获取 PageableListView 引用的方式,而是创建一个类变量,设置它并在创建 AjaxPagingNavigator 时使用它。当从 AjaxPagingNavigator 调用时,您是否使用调试来确保“c”不为空。我使用与您相同的检票口版本在我的环境中工作。我的代码中唯一的区别是我没有通过调用 get(id) 来获取我的变量

于 2013-03-10T18:28:13.077 回答