javatapestry

How to implement pager change event in Tapestry's grid


How to implement pager change event in Tapestry's grid? I've read the documentation, but couldn't find the answer. So what I'm trying to do is, I want to reset the selectedItem to null everytime the selected page changing, and I noticed that actually setupRender() triggered, but I don't want to use it because it does a quite heavy process. There's no point to do this only for page changes. So is there any way to implement it specifically only for pager changes? Thank you. I'm using Tapestry 5.3.8 btw


Solution

  • If I understand your question correctly, you should implement your own GridPager and, for example, emit the event when a page is changing (you can then handle this event within page class). For example:

    @Events({ PAGE_CHANGE_EVENT, InternalConstants.GRID_INPLACE_UPDATE + " (internal event)" })
    public class CustomeGridPager
    {
    
        ...
        void onAction(int newPage)
        {
           currentPage = newPage;
           this.resources.triggerEvent(PAGE_CHANGE_EVENT, new Object[] { newPage }, null);
        }
    }