开发者

Why is the PagingNavigator not generating the urls?

开发者 https://www.devze.com 2023-01-30 13:50 出处:网络
I have a problem with PagingNavigator in Wicket and I don\'t understand why am I having it. Here is the thing, I wanted to use a PagingNavigator with a Dataview

I have a problem with PagingNavigator in Wicket and I don't understand why am I having it. Here is the thing, I wanted to use a PagingNavigator with a Dataview

dataView = new DataView("pageableTicketsList", provider){
    protected void populateItem(final Item item) {
       //Somes codes here
    };
navigator = new PagingNavigator("navigator", dataView);
dataView.setItemsPerPage(30);
addOrReplace(dataView);
addOrReplace(navigator);

In the html file, I simply have :

<wicket:enclosure child="navigator">     
 <div class="navigator">
         <span wicket:id="navigator" ></span>
    </div>     
</wicket:enclosure>

When I test in a webBrowser, in fact, I have the pages number shown as :

<< < 1 2 3 4 5 6 7 8 9 10 > >>

BUT any of them are clickable.

I saw in FireBug that the urls are not properly generated like this :

<a href="?wicket:interface=:13:mypage:navigator:navigation:0:pageLink:4:ILinkListener::"><span>1</span>
</a>

Instead, I'm just having

<span>1</span>

I don't get it, what am I doing wrong ?

Here is the code of my provider

public class MyProvider implements IDataProvider {

    private List<Ticket> ticketsList;

    public MyProvider(TicketService ticketService // and some paramaters){
            ticketsList = ticketService.getListBy(//the parameters);
    }

    public Iterator iterator(int first, int count) {
    return ticketsList.subList(first, first + count).iterator();
    }

    public IModel model(final Object object) {
            return new LoadableDetachableModel() {
            @Override
                protected Object load() {
               return (Ticket)object;
            }};
    }

    public int size() {
    return ticketsList.size();
    }

    public void detach() {

    }

    public List<Ticket> getTicketsList() {
    return ticketsList;
    }

    public void setTicketsList(List<ListTicketsExtranetView> ticketsList) {
    this.ticketsList = ticketsList;
  开发者_运维技巧  }
}

The method size() returns the right value and navigator.isEnabled() returns true

Well, after a whole day of digging, I finally found out where my problem came from : I have a WebMarkupContainer that was added to my page, if I remove that WebMarkupContainer, the PagingNavigator works fine. There is no dependencies beetween the 2 of them though, I use the WebMarkupContainer to show a message if a list of Tickets is empty or not. So WHY is the WebMarkupContainer having influence on the PagingNavigator ?


Can you post the code of your class that implements IDataProvider, e.g. SortableDataProvider? If the size() method isn't returning the right value, you might encounter the behaviour you're seeing.


Your code seems right. Did you set anything to disabled with

setEnabled(false);

That has effect on components below that in the hierarchy. If that does not make a difference, try posting some more code.

0

精彩评论

暂无评论...
验证码 换一张
取 消