|
1 | 1 | package com.sankdev; |
2 | 2 |
|
| 3 | +import com.sankdev.portfolio.Item; |
| 4 | +import com.sankdev.portfolio.Portfolio; |
3 | 5 | import java.io.IOException; |
| 6 | +import java.net.URL; |
| 7 | +import java.util.List; |
4 | 8 | import java.util.ResourceBundle; |
5 | 9 | import javafx.fxml.FXML; |
| 10 | +import javafx.scene.control.TableColumn; |
| 11 | +import javafx.scene.control.TableView; |
| 12 | +import javafx.scene.control.cell.PropertyValueFactory; |
6 | 13 |
|
7 | 14 | public class PrimaryController { |
8 | 15 |
|
| 16 | + @FXML |
| 17 | + private TableView<Item> tableView; |
| 18 | + @FXML |
| 19 | + private TableColumn<Item, String> idCol; |
| 20 | + @FXML |
| 21 | + private TableColumn<Item, String> nameCol; |
| 22 | + |
| 23 | + public PrimaryController() { |
| 24 | + System.out.println("===>>> Inside Primary Controller constructor"); |
| 25 | + } |
| 26 | + |
| 27 | + public void initialize() { |
| 28 | + System.out.println("===>>> Inside Primary Controller initialize() method"); |
| 29 | + idCol.setCellValueFactory(new PropertyValueFactory<>("id")); |
| 30 | + nameCol.setCellValueFactory(new PropertyValueFactory<>("name")); |
| 31 | + |
| 32 | + tableView.getItems().setAll(parseUserList()); |
| 33 | + } |
| 34 | + |
| 35 | + private List<Item> parseUserList() { |
| 36 | + // parse and construct User datamodel list by looping your ResultSet rs |
| 37 | + // and return the list |
| 38 | + Portfolio portfolio = new Portfolio(); |
| 39 | + return portfolio.getItems(); |
| 40 | + } |
| 41 | + |
9 | 42 | @FXML |
10 | 43 | private void switchToSecondary() throws IOException { |
11 | 44 | App.setRoot("secondary"); |
|
0 commit comments