JavaFX TableView pagination - can not create fxml based solution
<p>I am using JavaFX in my project (also Spring, Hibernate e.t.c.).</p>

<p>I am trying to create Pagination for TableView. I found many reasonable solutions, but all off them are controller-based solutions. The best of them in <a href="https://stackoverflow.com/a/15349741/5331196">this solution</a>.</p>

<p>But in my situation - I am using multiple fxml files which were created in SceneBuilder with all huge design options and which contains the TabPane and for one Tab I have one FXML-file and one controller for it. </p>

<p>I have one basic file which imports others, and in my Main class I am loading it:</p>

<p><a href="https://i.stack.imgur.com/XHigL.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XHigL.jpg" alt="enter image description here"></a></p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;

&lt;?import javafx.scene.control.*?&gt;
&lt;?import javafx.scene.layout.AnchorPane?&gt;
&lt;?import javafx.scene.text.Font?&gt;
&lt;AnchorPane xmlns:fx="http://javafx.com/fxml/1" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity"
            minWidth="-Infinity" prefHeight="592.0" prefWidth="920.0" xmlns="http://javafx.com/javafx/8"
            fx:controller="com.varinsia.statistical.controller.GenericController"&gt;
    &lt;children&gt;
        &lt;TabPane layoutX="3.0" layoutY="50.0" prefHeight="542.0" prefWidth="914.0" tabClosingPolicy="UNAVAILABLE"&gt;
            &lt;tabs&gt;
                &lt;Tab text="Statistics"&gt;
                    &lt;content&gt;
                        &lt;fx:include fx:id="statistics" source="/fxml/child/statistics.fxml"/&gt;
                    &lt;/content&gt;
                &lt;/Tab&gt;
                &lt;Tab text="Shedule"&gt;
                    &lt;content&gt;
                        &lt;fx:include fx:id="shedule" source="/fxml/child/shedule.fxml"/&gt;
                    &lt;/content&gt;
                &lt;/Tab&gt;
                &lt;Tab text="Ponab devices"&gt;
                    &lt;content&gt;
                        &lt;fx:include fx:id="ponabDevices" source="/fxml/child/ponabDevices.fxml"/&gt;
                    &lt;/content&gt;
                &lt;/Tab&gt;
                &lt;Tab text="Als devices"&gt;
                    &lt;content&gt;
                        &lt;fx:include fx:id="alsDevices" source="/fxml/child/alsDevices.fxml"/&gt;
                    &lt;/content&gt;
                &lt;/Tab&gt;
                &lt;Tab text="Search"&gt;
                    &lt;content&gt;
                        &lt;fx:include fx:id="search" source="/fxml/child/search.fxml"/&gt;
                    &lt;/content&gt;
                &lt;/Tab&gt;
                &lt;Tab text="Settings"&gt;
                    &lt;content&gt;
                        &lt;fx:include fx:id="settings" source="/fxml/child/settings.fxml"/&gt;
                    &lt;/content&gt;
                &lt;/Tab&gt;
            &lt;/tabs&gt;
        &lt;/TabPane&gt;
        &lt;Label layoutX="127.0" layoutY="9.0" text="..."
               underline="true"&gt;
            &lt;font&gt;
                &lt;Font size="18.0"/&gt;
            &lt;/font&gt;
        &lt;/Label&gt;
    &lt;/children&gt;
&lt;/AnchorPane&gt;
</code></pre>

<p>In my controller class for my statistics.fxml I am creating the TableView and columns:</p>

<pre><code>@FXML
    public TableView&lt;StatisticsRemarkTableDto&gt; statisticsTableView;
    @FXML
    public TableColumn&lt;StatisticsRemarkTableDto, String&gt; objectColumn;
    @FXML
    public TableColumn&lt;StatisticsRemarkTableDto, String&gt; noteColumn;
    @FXML
    public TableColumn&lt;StatisticsRemarkTableDto, String&gt; stageColumn;
    @FXML
    public TableColumn&lt;StatisticsRemarkTableDto, String&gt; dateColumn;
    @FXML
    public TableColumn&lt;StatisticsRemarkTableDto, String&gt; vagonColumn;
    @FXML
    public TableColumn&lt;StatisticsRemarkTableDto, String&gt; repeatColumn;
    @FXML
    public TableColumn&lt;StatisticsRemarkTableDto, Integer&gt; remarkIdColumn;
</code></pre>

<p>And all other things like in <a href="https://stackoverflow.com/a/15349741/5331196">this solution</a>.
Information from the entity is added to my table and everything works fine. But!</p>

<p>Problem starts when i am trying to add Pagination, because I can't understand how I should do this. My Main method looks like this:</p>

<pre><code>public class Main extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("/spring/application-context.xml");
        context.getBeanFactory().registerResolvableDependency(Stage.class, primaryStage);
        primaryStage.setTitle(Constants.MAIN_TITLE);
        primaryStage.setScene(new Scene((Parent) context.getBean(SpringFXMLLoader.class).load(Constants.FXML_PATH), 914, 542));
        primaryStage.show();
    }
}
</code></pre>

<p>In all TableView-pagination examples Pagination were added in the Main class, like in the code from other valid and checked example:</p>

<pre><code>private Node createPage(int pageIndex) {

        int fromIndex = pageIndex * rowsPerPage;
        int toIndex = Math.min(fromIndex + rowsPerPage, data.size());
        table.setItems(FXCollections.observableArrayList(data.subList(fromIndex, toIndex)));

        return new BorderPane(table);
    }

    @Override
    public void start(final Stage stage) throws Exception {

        Pagination pagination = new Pagination((data.size() / rowsPerPage + 1), 0);
        pagination.setPageFactory(this::createPage);

        Scene scene = new Scene(new BorderPane(pagination), 1024, 768);
        stage.setScene(scene);
        stage.setTitle("Table pager");
        stage.show();
    }

    public static void main(String[] args) throws Exception {
        launch(args);
    }
</code></pre>

<p>Is there some way to pass this issue and to add Pagination to my TableView? 
I'll be very glad to any answers on this subject, the problem does not suffer the first day.</p>

<p><strong>RESOLVED!:</strong></p>

<p>Thanks to <a href="https://stackoverflow.com/users/2189127/james-d">James_D</a> and <a href="https://stackoverflow.com/a/36668150/5331196">his solution</a>.
I have tried this variant and it worked fine. My TableView is now with pagination.</p>

<p>I have added to my statistical.fxml:</p>

<pre><code>&lt;Pagination fx:id="statisticsTableViewPagination" layoutX="2.0" layoutY="188.0" prefHeight="275.0"
                prefWidth="912.0"&gt;
        &lt;fx:define&gt;
            &lt;TableView fx:id="statisticsTableView" layoutX="2.0" layoutY="188.0" prefHeight="301.0" prefWidth="912.0"&gt;
                &lt;placeholder&gt;
                    &lt;Label text="No search results found."/&gt;
                &lt;/placeholder&gt;
                &lt;columns&gt;
                    &lt;TableColumn fx:id="objectColumn" prefWidth="131.0" text="Object"/&gt;
                    &lt;TableColumn fx:id="noteColumn" minWidth="0.0" prefWidth="167.0" text="Remark"/&gt;
                    &lt;TableColumn fx:id="stageColumn" prefWidth="282.0" text="Stage"/&gt;
                    &lt;TableColumn fx:id="dateColumn" prefWidth="72.0" text="Date"/&gt;
                    &lt;TableColumn fx:id="vagonColumn" prefWidth="133.0" text="Laboratory"/&gt;
                    &lt;TableColumn fx:id="repeatColumn" prefWidth="125.0" text="Repeats"/&gt;
                    &lt;TableColumn fx:id="remarkIdColumn" minWidth="9.0" prefWidth="15.0" text="Id" visible="false"/&gt;
                &lt;/columns&gt;
            &lt;/TableView&gt;
        &lt;/fx:define&gt;
    &lt;/Pagination&gt;
</code></pre>

<p>And in my controller I have added the same parts as in <a href="https://stackoverflow.com/questions/15349185/javafx-tableview-paginator/15349741#15349741">this example</a>. And everything is working fine. Thanks a lot!</p>