Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8596269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:38:09+00:00 2026-06-12T00:38:09+00:00

Thare is a tutorial at javaFX documentation page. This example describes how to make

  • 0

Thare is a tutorial at javaFX documentation page. This example describes how to make tableView, if you have some sertain java class, which can tell you which columns you are going to have. (That is a Person class in this example).

But what if i do not have any specific class, and number of columns can vary from time to time?
In my case i have such data structure:

class TableData{ 
    List<Row> rows; //A list with all my rows i need to have in my table
}

class Row{
    List<Column> columns; //Cells\Columns for every row. 
}

class Column{
    Attribute attr; //Each column - is somethig like a wrapper for the real data i need to show in a cell;
}

class Attribute{ //My precues data
    String name;
    SupportingInfo info;
}

class SupportingInfo{//Some supporting fields...
    String name;
    String value;
    //...etc....
}

So, my case is very similar to this one.
The only differents is that data from the case above is not binded with its representation in javaFX table (so, even if some one will make extra controls to edit this data in a tableView, the actual object with that data will never know about it.), because it(data) goes to the table like some strings, not like some objects;

So, what do i need – is to push data to the table (like that: table.setItems(tableData)), set some set Factories, to give user ability to edit data, and to have this edited data in my tableData object;

Here are some code ive tried to make for this purpose:

//prepare my table
private void createTableHeader(TableView table, List<Attribute> ias) {
    int i = 0;
    for (final Attribute ia : ias) {
        final int j = i;
        i++;
        TableColumn tc = new TableColumn(ia.getName());
        tc.setSortable(true);
        tc.setCellValueFactory(new Callback<CellDataFeatures<List<Attribute>, String>, ObservableValue<String>>() {
            @Override
            public ObservableValue<String> call(CellDataFeatures<List<Attribute>, String> arg0) {
                if(arg0.getValue().get(j).getSupportingInfo() == null){
                    arg0.getValue().get(j).setSupportingInfo(new SupportingInfo());
                }
                return new SimpleObjectProperty(arg0.getValue().get(j),"value");
            }
        });
        table.getColumns().add(tc);
    }
}

//loading some data to my tableView
private void createTableBody(TableView curTable, List<Row> rows) {  
    ObservableList<List<Attribute>> data = FXCollections.observableArrayList();
    for (Row row : rows) {
        data.add(row.getColumns());
    }
    curTable.setItems(data);
}   

//this one is to define some extra controls for editing data in a table by users
private void makeCellFactory(TableColumn curTableCol, final Attribute templateIa, final Document doc) {
    curTableCol.setCellFactory(new Callback<TableColumn, TableCell>() {
        public TableCell call(TableColumn p) {
            final EditingCell cell = new EditingCell(templateIa, doc);
            return cell;
        }
    });
}       

But, as a result, i have just empty rows in my table, with an ability to click some cell and recieve table editing controls. But there is not defult values in by table;
What am i doing wrong in my code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T00:38:11+00:00Added an answer on June 12, 2026 at 12:38 am

    Ok, i’ve found a solution:
    ts.setCellFactory should look like this:

    tc.setCellValueFactory(new Callback<CellDataFeatures<List<Attribute>, SupportingInfo>, ObservableValue<Attribute>>() {
     @Override
     public ObservableValue<Attribute> call(CellDataFeatures<List<Attribute>, SupportingInfo> arg0) {
      return new SimpleObjectProperty(arg0.getValue().get(j),"value",arg0.getValue().get(j));
     }
    });
    

    Also, this code is needed to catch new values and put the incoming data to the table:

    tc.setOnEditCommit(new EventHandler<CellEditEvent<List<Attribute>, Attribute>>() {
        @Override
        public void handle(CellEditEvent<List<Attribute>, Attribute> t) { t.getTableView().getItems().get(t.getTablePosition().getRow()).get(j).setSupportingInfo(t.getNewValue().getSupportingInfo());
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was learning how to make simple form validation using this tutorial: http://www.raistudies.com/spring/spring-mvc/form-validation-spring-mvc-3-hibernate-validator-jsr-303/ The
There are many questions about this PersistenceException, but I have not seen some, where
I am trying to compile the java class on: http://wiki.eclipse.org/Jetty/Tutorial/Jetty_HelloWorld with Jetty web service.
Is there any tutorial to do this in SQL Server 2008? Do you have
I have been following this tutorial on the Springsource website in order to have
I'm learning to code in Java. I have this assessment that I need to
In hirb tutorial there's an example for array: [[1,2], [2,3]] prints as +---+---+ |
I read some tutorial in Google App Engine, in those tutorial there is same
I'm trying to upload a file using JavaFX using the HttpRequest. For this purpose
This one is a long one, bellow is my primary class that holds the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.