IllegalStateException: PaginationDataBinder has first result that is not applicable for the page ranges

Hi,

On an empty browse screen, when adding a new record I get the following exception:

java.lang.IllegalStateException: PaginationDataBinder has first result that is not applicable for the page     ranges
    	at io.jmix.ui.widget.JmixPagination.setCurrentPageNumberByFirstResult(JmixPagination.java:213)
    	at io.jmix.ui.component.impl.PaginationImpl.onCollectionChange(PaginationImpl.java:217)
    	at io.jmix.ui.component.pagination.data.AbstractPaginationDataBinder.lambda$attachCollectionChangeListener$0(AbstractPaginationDataBinder.java:48)
    	at io.jmix.ui.model.impl.WeakCollectionChangeListener.accept(WeakCollectionChangeListener.java:42)
    	at io.jmix.ui.model.impl.WeakCollectionChangeListener.accept(WeakCollectionChangeListener.java:25)
    	at io.jmix.core.common.event.EventHub.publish(EventHub.java:170)
    	at io.jmix.ui.model.impl.CollectionContainerImpl.fireCollectionChanged(CollectionContainerImpl.java:241)
    	at io.jmix.ui.model.impl.CollectionContainerImpl.lambda$getMutableItems$0(CollectionContainerImpl.java:89)
    	at io.jmix.ui.model.impl.ObservableList.fireCollectionChanged(ObservableList.java:69)
    	at io.jmix.ui.model.impl.ObservableList.add(ObservableList.java:97)
    	at io.jmix.ui.builder.EditorBuilderProcessor.lambda$buildEditor$0(EditorBuilderProcessor.java:121)
    	at io.jmix.core.common.event.EventHub.publish(EventHub.java:170)
    	at io.jmix.ui.screen.Screen.fireEvent(Screen.java:124)
    	at io.jmix.ui.screen.Screen.close(Screen.java:330)
    	at io.jmix.ui.screen.StandardEditor.lambda$closeWithCommit$11(StandardEditor.java:617)
    	at io.jmix.ui.util.SuccessOperationResult.compose(SuccessOperationResult.java:35)
    	at io.jmix.ui.screen.StandardEditor.closeWithCommit(StandardEditor.java:617)
    	at io.jmix.ui.screen.StandardEditor.commitAndClose(StandardEditor.java:570)
            ...
    	at java.base/java.lang.Thread.run(Thread.java:833)

Deleting the record and creating it again without closing the browse screen, the exception doesn’t happen. However closing the browse screen and recreating the record the exception is thrown.

For info, here is the configuration of my pagination component:

<pagination id="pagination" itemsPerPageVisible="true" align="TOP_RIGHT">
         <loaderProvider loaderId="recordsDl"/>
</pagination>

Somehow there is an issue with the internal state of the Pagination component.

Best, Samy

Hello!

Thank you for reporting a problem, I’ve created an issue: jmix-framework/jmix#685.

Yes, the problem in the internal state of the Pagination. You can workaround this issue. Inject the loader to the screen controller and in the AfterShowEvent set first result 0:

@Autowired
private CollectionLoader<Customer> customersDl;

@Subscribe
public void onAfterShow(AfterShowEvent event) {
    customersDl.setFirstResult(0);
}
1 Like