TableView Update

Hi,
I am very confused about rows updates in TableView.
I do not know how to add a row dynamically and have the data ticking in the grid when the property gets changed after the grid has been initialized.
Everything works fine when the rows are set before, but not after.
Is the following sample code to be used to add a row after the grid's initialization?
(Because whenever a new row is added, it does not gets displayed in the TableView)
val datum = new PricingDatum
table.getItems.add(datum)My PricingDatum looks like this:
public final class PricingDatum {
private IntegerProperty nodeId = new IntegerProperty(-1);
public int getNodeId() {return nodeId.get();}
public void setNodeId(final int newVal) {this.nodeId.set(newVal);}
public IntegerProperty nodeIdProperty() {return nodeId;}
private StringProperty instrument = new StringProperty("#");
public String getInstrument() {return instrument.get();}
public void setInstrument(final String newVal) {this.instrument.set(newVal);}
public StringProperty instrumentProperty() {return instrument;}
private DoubleProperty cp = new DoubleProperty(Double.NaN);
public double getCp() {return cp.get();}
public void setCp(final double newVal) {this.cp.set(newVal);}
public DoubleProperty cpProperty() {return cp;}
private DoubleProperty cy = new DoubleProperty(Double.NaN);
public double getCy() {return cy.get();}
public void setCy(final double newVal) {this.cy.set(newVal);}
public DoubleProperty cyProperty() {return cy;}
}Thx v much

Please consider filing bugs in Jira at [http://javafx-jira.kenai.com|http://javafx-jira.kenai.com/]. Without your bugs being filed there is no guarantee we'll know to fix them! File them against 'runtime', for the 'control' component, and they'll turn up in my inbox.
Thanks,
Jonathan

Similar Messages

  • TableView updates not working when ValueFactory returns a new Binding

    Hi,
    When a cell value factory returns a newly created expression or Binding cell values will stop receiving updates at some point. It seems that the cell that requests the observable value from the value factory does not keep a strong reference to the returned value so the cell will only receive updates from the the Observable value as long as it has not been garbage collected. The code below reproduces this issue:
    import javafx.application.Application;
    import javafx.beans.property.DoubleProperty;
    import javafx.beans.property.ReadOnlyStringWrapper;
    import javafx.beans.property.SimpleDoubleProperty;
    import javafx.beans.value.ObservableValue;
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.control.TableColumn;
    import javafx.scene.control.TableColumn.CellDataFeatures;
    import javafx.scene.control.TableView;
    import javafx.scene.layout.HBox;
    import javafx.scene.layout.HBoxBuilder;
    import javafx.scene.layout.StackPane;
    import javafx.scene.layout.VBox;
    import javafx.scene.layout.VBoxBuilder;
    import javafx.stage.Stage;
    import javafx.util.Callback;
    * Reproduce cell update bug. Compile and run the class. Press the update button a
    * couple of times and note how the values in the total column update. Press the
    * GC button a couple of times and then press the update button again. Note how
    * the values in the total column do not update anymore.
    * The Value Factory for the total column does not return a property that is
    * held by the Order object, it returns a Binding that is created on the fly.
    * The cell does not hold a strong reference to this object so it can be gc'd 
    public class CellUpdateTest2 extends Application {
         static class Order {
              String name;
              DoubleProperty price = new SimpleDoubleProperty();
              DoubleProperty qty = new SimpleDoubleProperty();
              Order(String n, double p) {
                   name = n;
                   price.set(p);
                   qty.set(1);
         final Order items[] = {
                   new Order("Item 0", 4.0),
                   new Order("Item 1", 5.0),
                   new Order("Item 2", 6.0),
                   new Order("Item 3", 7.0),
                   new Order("Item 4", 8.0),
                   new Order("Item 5", 9.0),
                   new Order("Item 6", 10.0),
                   new Order("Item 7", 11.0)
         @Override
         public void start(final Stage primaryStage) throws Exception {
              final Button updateButton = new Button("Update Values");
              updateButton.setOnAction(new EventHandler<ActionEvent>() {
                   @Override
                   public void handle(final ActionEvent actionEvent) {
                        for (Order i: items) {
                             i.qty.set(i.qty.get() + 1);
              final Button gcButton = new Button("System.gc()");
              gcButton.setOnAction(new EventHandler<ActionEvent>() {
                   @Override
                   public void handle(final ActionEvent actionEvent) {
                        System.gc();
              final TableView<Order> tv = new TableView<Order>();
              final TableColumn<Order, String> nameCol = new TableColumn<Order, String>("Item");
              final TableColumn<Order, Number> priceCol = new TableColumn<Order, Number>("Price");
              final TableColumn<Order, Number> qtyCol = new TableColumn<Order, Number>("Quantity");
              final TableColumn<Order, Number> totalCol = new TableColumn<Order, Number>("Total");
              nameCol.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Order, String>, ObservableValue<String>>() {
                   @Override
                   public ObservableValue<String> call(final CellDataFeatures<Order, String> d) {
                        return new ReadOnlyStringWrapper(d.getValue().name);
              priceCol.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Order, Number>, ObservableValue<Number>>() {
                   @Override
                   public ObservableValue<Number> call(final CellDataFeatures<Order, Number> cellData) {
                        return cellData.getValue().price;
              qtyCol.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Order, Number>, ObservableValue<Number>>() {
                   @Override
                   public ObservableValue<Number> call(final CellDataFeatures<Order, Number> cellData) {
                        return cellData.getValue().qty;
              totalCol.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Order, Number>, ObservableValue<Number>>() {
                   @Override
                   public ObservableValue<Number> call(final CellDataFeatures<Order, Number> cellData) {
                        return cellData.getValue().price.multiply(cellData.getValue().qty);
              tv.getColumns().addAll(nameCol, priceCol, qtyCol, totalCol);
              tv.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
              tv.getItems().addAll(items);
              final HBox hb = HBoxBuilder.create().children(updateButton, gcButton).build();
              final VBox vb = VBoxBuilder.create().children(tv, hb).build();
              primaryStage.setScene(new Scene(vb));
              primaryStage.setHeight(200.0);
              primaryStage.show();
         public static void main(final String args[]) {
              launch(args);
    } Is this expected behaviour?
    If so - what would the correct way to approach this?
    If not - is there an easy workaround?

    this seems to have worked....
         static class Order {
              String name;
              DoubleProperty price = new SimpleDoubleProperty();
              DoubleProperty qty = new SimpleDoubleProperty();
                    DoubleProperty total = new SimpleDoubleProperty();
              Order(String n, double p) {
                   name = n;
                   price.set(p);
                   qty.set(1);
                    public void updateTotal() {
                        total.set(price.get() * qty.get());
         }with
              qtyCol.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Order, Number>, ObservableValue<Number>>() {
                   @Override
                   public ObservableValue<Number> call(final CellDataFeatures<Order, Number> cellData) {
                                    System.out.println("in qty column");
                                    cellData.getValue().updateTotal();
                        return cellData.getValue().qty;
              });and finally
              totalCol.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Order, Number>, ObservableValue<Number>>() {
                   @Override
                   public ObservableValue<Number> call(final CellDataFeatures<Order, Number> cellData) {
                                    System.out.println("in total column");
                        return cellData.getValue().total;
              });I cannot explain why what you did did not work. I have a mistrust towards binding and I avoid it when ever possible.
    thanks
    jose

  • UITableView realtime loading.

    I was trying to update a UITableView cell after receiving input from the user through a custom UIAlertView with a UITextField. So, after clicking on a cell, a UIAlertView appears for the user to enter in that value. After the user hits OK I wanted the cell to update its data. I tried to do this with [self.tableView setNeedsDisplay], but could not get the TableView to update. I have [self.tableView reloadData] in my viewWillAppear delegate and the only time the TableView updates is when switching views. I finally found that I could replicate the action of switching views by calling [self viewWillAppear:YES] in the UIAlertView's button click delegate. Something is telling me, however, that this is not a very good solution, even if it is a working one. Can someone explain to me if I am doing something wrong.

    If you change the cell's text property directly then you shouldn't need to do anything for it to become visible.
    If you are changing some underlying data structure that's used to set the cell contents when they are created then calling reloadData should do what you want.

  • Using gestures,animations and effects to the app

    I am new to iPad App development, can anybody please tell how can i add effects,gestures and animation to the custom cell in tableview.i would like to use the fading effect to the cells and rearrange the same rows in tableview.

    Updated: 2015-08-04Marked as new idea.

  • Updation of internal table from tableview

    Hi,
    I am using a tableview in which coloumn-3(last_days) is editable.After editing it when user pressess on the button SAVE I should capture the changes and update it in database.
    But here I am facing a problem.Always the field last_days is being filled with '000' irrespective of the value entered.
    The below is the piece of code which I had written:
    DATA: tv TYPE REF TO CL_HTMLB_TABLEVIEW,
    wa like line of  R_GT_VIEW.
    tv ?= CL_HTMLB_MANAGER=>GET_DATA(
    request = runtime->server->request
    name = 'tableView'
    id = 'tvx' ).
    IF tv IS NOT INITIAL.
    DATA: tv_data TYPE REF TO CL_HTMLB_EVENT_TABLEVIEW.
    tv_data = tv->data.
    loop at R_GT_VIEW into wa .
    wa-last_days =  tv_data->get_cell_value( row_index = sy-tabix
                                       column_index = '3' ).
    modify R_GT_VIEW from wa index sy-tabix.
    endloop.
    ENDIF.
    Helpful answers will be rewarded.
    Thanks

    Hi,
    Sorry....coz I replied in a haste...
    Just to let you know....The method get_cell_value will not work if you are rendering a column as InputField.
    Use the below mentioned code and this it should work....
    DATA: tv TYPE REF TO cl_htmlb_tableview.
              wa like line of R_GT_VIEW.
    tv ?= cl_htmlb_manager=>get_data(
                        request = runtime->server->request
                        name = 'tableView'
                        id = 'tvx' ).
    IF tv IS NOT INITIAL.
      DATA: tv_data TYPE REF TO cl_htmlb_event_tableview.
      tv_data = tv->data.
      LOOP AT itab INTO wa .
        data : if_value type ref to cl_htmlb_inputfield.
        data : p_cell_id type string,       
               row_ix type string.
        clear p_cell_id.
        clear row_ix.
        row_ix = sy-tabix.
        condense row_ix.
        concatenate p_cell_id 'TV_' row_ix '_3' into p_cell_id.    "generating cell ID...Make Sure to use ur TableView Id instead of TV
        if_value ?= cl_htmlb_manager=>get_data( request = request
                                                name    = 'inputField'
                                                id      = p_cell_id
           if if_value->value is not initial.
             wa-last_days  = if_value->value.
           endif.
        MODIFY itab FROM wa INDEX sy-tabix.
      ENDLOOP.
    <i>Do reward each useful answer..!</i>
    Thanks,
    Tatvagna.

  • TableView - How to update a running balance column after any other column in the view is re-sorted

    To keep this simple and to illustrate a problem that I am trying to solve let's say we have
    a domain class that contains an income per day.
    This class has two persistent properties - populated from a database table - date and income.
    And there is one transient property - running balance - that shows the accumulated income
    starting from the first record. This property is not persisted and it is used only to show
    the running/accumulated income in a table view.
    This domain object is shown in a table view with three columns:
         - date
         - income
         - running balance
    The first two columns - date and income - are sortable. When the user clicks on the column
    heading these can will be sorted in ascending or descending order. The running balance
    column needs to reflect this change and be correctly updated.
    So the question is : how would you implement the running balance update after the data in
    the table has been updated by the user?
    Take 1)
    =============
    The obvious approach is to use "setOnSort" method to consume the SortEvent event and re-sort the
    data but the sort-event does not contain any useful information that would tell from which column
    the sort event originated.
    Take 2)
    =============
    Found a possible solution:
         - TableView.getSortOrder() returns a list that defines the order in which TableColumn instances are sorted after the user clicked one or more column headings.
         - TableColumn.getSortType() returns the sort type - ascending/descending.
         - This info can be used in the TableView.setOnSort() event handler to re-sort the data and update the balance at the same time.
    Take 3)
    =============
    When the TableView.setOnSort() event handler is called the data is already sorted therefore the only thing that needs to be done is to update the running balance.

    I  think I understand what you're trying to do. If I've missed it, apologies, but I think this will provide you with something you can work from anyway.
    I would listen to the data instead of watching specifically for sorting. This will be much more robust if you add new functionality later (such as adding and removing rows, editing the data that's there, etc).
    Specifically, for the runningBalance column, create a cellValueFactory that provides a DoubleBinding; this binding should listen for changes to the data and compute the value by running through the table's items up to the point of the item for which it's displaying the value. (Hope you can untangle that sentence.)
    Example. The important part is the cellValueFactory for the cumulativeAmountCol. I guess I should mention that you shouldn't try this exact approach with very large tables as the performance might be pretty bad (computations of the order of n x m on changing data, where n is the number of rows in the table and m is the number of visible rows in the table).
    import java.text.DateFormat;
    import java.text.NumberFormat;
    import java.util.ArrayList;
    import java.util.Arrays;
    import java.util.Calendar;
    import java.util.Date;
    import java.util.Iterator;
    import java.util.List;
    import java.util.Random;
    import javafx.application.Application;
    import javafx.beans.Observable;
    import javafx.beans.binding.DoubleBinding;
    import javafx.beans.property.DoubleProperty;
    import javafx.beans.property.ObjectProperty;
    import javafx.beans.property.SimpleDoubleProperty;
    import javafx.beans.property.SimpleObjectProperty;
    import javafx.beans.value.ObservableValue;
    import javafx.collections.FXCollections;
    import javafx.scene.Scene;
    import javafx.scene.control.TableCell;
    import javafx.scene.control.TableColumn;
    import javafx.scene.control.TableColumn.CellDataFeatures;
    import javafx.scene.control.TableView;
    import javafx.scene.control.cell.PropertyValueFactory;
    import javafx.scene.layout.BorderPane;
    import javafx.stage.Stage;
    import javafx.util.Callback;
    public class CumulativeTableColumnExample extends Application {
      private final static int NUM_ITEMS = 20 ;
    @Override
      public void start(Stage primaryStage) {
      final TableView<LineItem> table = new TableView<>();
      // using the extractor here makes sure the table item list fires a list changed event if any amounts change
      // this enables the cumulative amount column to keep up to date when the amount in a different row changes.
      table.setItems(FXCollections.observableList(createRandomData(), new Callback<LineItem, Observable[]>() {
          @Override
          public Observable[] call(LineItem item) {
            return new Observable[] {item.amountProperty()};
      final TableColumn<LineItem, Date> dateCol = new TableColumn<>("Date");
      final TableColumn<LineItem, Number> amountCol = new TableColumn<>("Amount");
      final TableColumn<LineItem, Number> cumulativeAmountCol = new TableColumn<>("Cumulative Amount");
      table.getColumns().addAll(Arrays.asList(dateCol, amountCol, cumulativeAmountCol));
      dateCol.setCellValueFactory(new PropertyValueFactory<LineItem, Date>("date"));
        amountCol.setCellValueFactory(new PropertyValueFactory<LineItem, Number>("amount"));
        cumulativeAmountCol.setCellValueFactory(new PropertyValueFactory<LineItem, Number>("amount"));
        cumulativeAmountCol.setSortable(false); // otherwise bad things might happen
      final DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT);
      dateCol.setCellFactory(new Callback<TableColumn<LineItem, Date>, TableCell<LineItem, Date>>() {
          @Override
          public TableCell<LineItem, Date> call(TableColumn<LineItem, Date> col) {
            return new TableCell<LineItem, Date>() {
              @Override
              public void updateItem(Date date, boolean empty) {
                super.updateItem(date, empty);
                if (empty) {
                  setText(null);
                } else {
                  setText(dateFormat.format(date));
      cumulativeAmountCol.setCellValueFactory(new Callback<CellDataFeatures<LineItem, Number>, ObservableValue<Number>> () {
          @Override
          public ObservableValue<Number> call(CellDataFeatures<LineItem, Number> cellData) {
            final LineItem currentItem = cellData.getValue() ;
            DoubleBinding value = new DoubleBinding() {
                super.bind(table.getItems());
              @Override
              protected double computeValue() {
                double total = 0 ;
                LineItem item = null ;
                for (Iterator<LineItem> iterator = table.getItems().iterator(); iterator.hasNext() && item != currentItem; ) {
                  item = iterator.next() ;
                  total = total + item.getAmount() ;
                return total ;
            return value;
        final NumberFormat currencyFormat = NumberFormat.getCurrencyInstance();
      // generics hell.. can't wait for lambdas...
      final Callback<TableColumn<LineItem, Number>, TableCell<LineItem, Number>> currencyCellFactory = new Callback<TableColumn<LineItem, Number>, TableCell<LineItem, Number>>() {
          @Override
          public TableCell<LineItem, Number> call(TableColumn<LineItem, Number> column) {
            return new TableCell<LineItem, Number>() {
              @Override
              public void updateItem(Number amount, boolean empty) {
                if (empty) {
                  setText(null) ;
                } else {
                  setText(currencyFormat.format(amount));
        amountCol.setCellFactory(currencyCellFactory);
        cumulativeAmountCol.setCellFactory(currencyCellFactory);
        BorderPane root = new BorderPane();
      root.setCenter(table);
      primaryStage.setScene(new Scene(root, 600, 400));
      primaryStage.show();
      public List<LineItem> createRandomData() {
        Random rng = new Random();
        List<LineItem> items = new ArrayList<>();
        for (int i=0; i<NUM_ITEMS; i++) {
          Calendar cal = Calendar.getInstance();
          cal.add(Calendar.DAY_OF_YEAR, rng.nextInt(365)-365);
          double amount = (rng.nextInt(90000)+10000)/100.0 ;
          items.add(new LineItem(cal.getTime(), amount));
        return items ;
      public static void main(String[] args) {
      launch(args);
    public static class LineItem {
        private final ObjectProperty<Date> date ;
        private final DoubleProperty amount ;
        public LineItem(Date date, double amount) {
          this.date = new SimpleObjectProperty<>(this, "date", date);
          this.amount = new SimpleDoubleProperty(this, "amount", amount);
        public final ObjectProperty<Date> dateProperty() {
          return date;
        public final Date getDate() {
          return date.get();
        public final void setDate(Date date) {
          this.date.set(date);
        public final DoubleProperty amountProperty() {
          return amount ;
        public final double getAmount() {
          return amount.get();
        public final void setAmount(double amount) {
          this.amount.set(amount);

  • Error when updating back to ODS using tableview iterator.

    I get this error when I try to execute my bsp page. The page collects a cell value that was edited on the previous page and updates it to the ods.
    The error is "Function not possible in a captured session"
    The termination type was: TH_RES_FREE
    When I debug, every thing looks fine. ITab3 returns values it's supposed to. So I am not sure what's causing it to fail. Any ideas? Thanks.
    Here is my code:
    CLASS cl_htmlb_manager DEFINITION LOAD.
    DATA: event TYPE REF TO cl_htmlb_event.
    event = CL_HTMLB_MANAGER=>get_event( runtime->server->request ).
    if event->id = 'Update' and event->event_type = 'click'.
      DATA: tv TYPE REF TO cl_htmlb_tableview.
    FIELD-SYMBOLS <i> LIKE LINE OF selectedrowindextable.
    tv ?= cl_htmlb_manager=>get_data( request = runtime->server->request
                                     name = 'tableView'
                                     id = 'tv1' ).
    IF tv IS NOT INITIAL.
    DATA: tv_data TYPE REF TO cl_htmlb_event_tableview.
      tv_data = tv->data.
      refresh itab2.
      refresh itab3.
      call method tv_data->GET_ROWS_SELECTED
      receiving selected_rows = itab2.
      endif.
      data : ind type SELECTEDROW,
              row_s type row.
      if itab2 is not initial.
        data: rw LIKE LINE OF itab.
        loop at itab2 into ind.
        READ TABLE itab INDEX ind-index into
        rw.
        if rw is not initial.
        row_s = rw.
        append row_s to itab3.
        clear row_s.
        endif.
        endloop.
            MODIFY /bic/aNCN_O01300 FROM table itab3.
          ENDIF.
          endif.

    hi Uday,
    This is simple....
    Use the function module
    <b>1) For adding leading zero's or spaces...!</b>
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        INPUT   = lw_variable
    IMPORTING
       OUTPUT   = lw_variable.
    <b>2) and for removing leading zero's or spaces.....</b>
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
      EXPORTING
        INPUT   = lw_variable
    IMPORTING
       OUTPUT   = lw_variable.
    Hope this helps.
    <b><i>Do reward each useful answer..!</i></b>
    Thanks,
    Tatvagna.

  • EP 6.0 SP2: Update a HTMLB TableView after onClick Event

    Hello,
    i generate a TableView from a JDBC database selection.
    Outside this TableView there are 3 Buttons.
    Now the problem:
    If one of the buttons will click, the TableView has to be updated with a new database result. Have somebody an idea, how to update the TableView?
    Stephan

    Could you be more precise?
    Default behaviour/coding is that an onClick event effects a request to the server - as your component/dynpage handles this request, you should be able to present anything that you like on this occasion. Maybe you code does not react to the HTMLB event properly?
    Regards,
    Armin

  • Disable tableview to perform TableCell.update selction

    I am working on javafx2.2 tableview
    My table has 100,000 entries (3 columns one int two float), and new rows are inserted every 20 ms,
    I need it to have active sort capability which is achieved using binary search. But am getting very slow GUI.
    Initially I thought it to be because of table.getItems.add(index,element)
    But when I run Jprofiler it is showing major time is consumed in TableCell.updateSelection (javafx.scene.control.TableCell$2.onChanged).
    Can anyone tell me is it useful to have it.... If yes then how....
    And if I want it to be disabled then how to do it.
    Thank you

    No, you cannot perform parallel dml with a trigger present.
    If you are updating the bulk of the rows and can take an outage, you can
    disable the trigger, perform the update, enable the trigger
    OR
    copy to another table, performing the update in the select, rename the tables and add the trigger on the new table
    Hemant K Chitale

  • Save update tableView

    Hello everybody,
    I' m updat a

    Hi,
    Look at the below thread to update the Tableview.
    Re: How to update the tableview
    Raja T

  • Updating tableview back into database table

    I am trying to display a recordset from mysql database table into a tableview in javafx. Maybe let's say get all records where invoice number is 101 i n the master table from the child records in the child table.(This is a typical master detail scenario.) After this I update the tableview add, delete, edit some records AND then I want to save this Tableview or rather update it back, synchronise into the database table.
    I request you to kindly help with sample code or any guidelines that will help me in this objective.

    Here is the tutorial of tableView : http://docs.oracle.com/javafx/2/ui_controls/table-view.htm
    You can use the Java Class that mapped the database for ObservableList. Get all the record in the database and cover it to the java object. Then add them to the ObservableList to show on TableView. After add, update, edit,... Get the item in the ObservableList and update back to your database.
    I can't tell in detail. You should try this tutorial and if there are any more Specific Issue you can post another question here.

  • TableView auto update issue in 2.1 and 2.2

    Hi, guys!
    Initial status: I have a TableView with some items inside. I update an item (an User object), I remove it from table and then I put it again at the same index.
    Working code in 2.0.2:
    // Gets selected item
    User selectedUser = (User) table.getSelectionModel().getSelectedItem();
    // Updates the User object to show the new data in the table
    selectedUser.setFirstName(fNameTF.getText());
    selectedUser.setLastName(lNameTF.getText());
    selectedUser.setRank((String) (rankCB.getSelectionModel().getSelectedItem()));
    selectedUser.setPassword(passTF.getText());
    // Updates table data.
    // First gets the user Object index in the items list,
    // then removes the user object from the table list,
    // then adds the updated user object at the same index it was before.
    int userObjectIndexInItemsList = table.getItems().indexOf(selectedUser);
    table.getItems().remove(table.getItems().indexOf(selectedUser));
    table.getItems().add(userObjectIndexInItemsList, selectedUser);
    Here is my problem: In version 2.1 and 2.2 (b06) this doesn't work anymore. The table doesn't show the modified data. I also tried to getTableItems in tableData (new FXCollections.observableArrayList()), then table.setItems(null), then table.setItems(tableData), but it didn't work.
    So, the problem is that the FXCollections.observableArrayList() (which was used to populate the table at the beginning) doesn't report anymore to the table when a change is made.
    Possible, but unwanted sollutions:
    1 - Total recreation of the table.
    2 - Total recreation of the tableItems (create a new observable list with new objects).
    Any suggestions?
    I don't want to recreate table data every time a change is made, especially because it's based on a database.

    JavaFX has a fundamentally different way of handling these kinds of updates, which may make it tricky to implement this in your current system.
    In short, the way updates work in JavaFX for the ListView, TreeView and TableView is this:
    Each type of View is made out of Cells. The amount of Cells is usually pretty close to the amount of visible rows and each Cell could be thought of to represent one Row.
    Each Cell is basically a small piece of UI, that adapts itself to whatever should be displayed at the given row at that time. The updateItem method is called on these Cells to associate them with an underlying Item from the ObservableList (your model).
    Let's say your "Items" in the Model are Person objects with a name. A cell implementation might render this as follows:
      private static final class PersonTableCell extends TableCell<Person, Person> {
        @Override
        protected void updateItem(final Person person, boolean empty) {
          super.updateItem(mediaNode, empty);
          if(!empty) {
            setText(person.getTitle());
      }The example above will also have the same update problem as your code, that is, if you change the Person object in your model the Cell will not reflect the changed name.
    In JavaFX to let the Cell know about the change, you have to add a listener to the "text" property of your Person object. This assumes that the properties of a Person object are JavaFX style properties. This is accomplished like this (using a binding which uses a listener internally):
      private static final class PersonTableCell extends TableCell<Person, Person> {
        @Override
        protected void updateItem(final Person person, boolean empty) {
          super.updateItem(mediaNode, empty);
          textProperty().unbind();
          if(!empty) {
            textProperty().bind(person.titleProperty());
      }The above will update correctly automatically whenever a Person's title property changes.
    However, this means that you will have to change your Person object to use JavaFX style properties. You donot always have this luxury. However, there are other options. You could for example only support a "changedProperty" in the Person class, and have the Cells listen for to this, something like this:
      private static final class PersonTableCell extends TableCell<Person, Person> {
        private Person oldPerson;
        private InvalidationListener listener;
        @Override
        protected void updateItem(final Person person, boolean empty) {
          super.updateItem(mediaNode, empty);
          if(oldPerson != null) {
            oldPerson.removeListener(listener);
            oldPerson = null;
          if(!empty) {
            listener = new InvalidatonListener() {
              public void invalidated(Observable o) {
                 setText(person.getTitle());
            person.addListener(listener);
            setText(person.getTitle());
      }Now each time you want to trigger a "change", you call a method on the Person object that triggers an Invalidation event. All the cells that are listening to this Person object will be notified and update themselves.
    If you donot want to change the Person class itself, you could also do this with a wrapper. You'll have to experiment a bit.

  • TableView Context Menu Item shows up when run on Java 8 until update 5 but not on later ones

    The code below runs as its name says on Java 8 update 5 but not on later ones:
    public class TableViewShowingOnlyAnAppendContextMenuItemIfRowIsEmptyElseDeleteIsIncluded extends Application {
        private final TableView<Name> table = new TableView<>();
        private final ObservableList<Name> data = FXCollections.observableArrayList(new Name("Jacob"),
                new Name("Isabella"), new Name("Ethan"), new Name("Emma"), new Name("Michael"));
        public static void main(String[] args) {
            launch(args);
        @Override
        public void start(Stage stage) {
            TableColumn<Name, String> column = new TableColumn<>("Name");
            column.setCellValueFactory(new PropertyValueFactory<>("name"));
            table.getColumns().add(column);
            table.setItems(data);
            ContextMenu contextMenu = new ContextMenu();
            contextMenu.getItems().add(new MenuItem("append"));
            table.setContextMenu(contextMenu);
            table.setRowFactory(tableView -> {
                TableRow<Name> row = new TableRow<>();
                row.contextMenuProperty().bind(
                        Bindings.when(Bindings.isNotNull(row.itemProperty()))
                                .then(showOnlyAppendContextMenuItemIfRowIsEmptyElseIncludeDelete())
                                .otherwise((ContextMenu) null));
                return row;
            Scene scene = new Scene(table);
            stage.setScene(scene);
            stage.show();
        private ContextMenu showOnlyAppendContextMenuItemIfRowIsEmptyElseIncludeDelete() {
            ContextMenu rowMenu = new ContextMenu();
            ContextMenu tableMenu = table.getContextMenu();
            if (tableMenu != null)
                rowMenu.getItems().addAll(tableMenu.getItems());
            rowMenu.getItems().add(new MenuItem("delete"));
            return rowMenu;
        public static class Name {
            private final SimpleStringProperty name;
            private Name(String name) {
                this.name = new SimpleStringProperty(name);
            public String getName() {
                return name.get();
            public void setName(String name) {
                this.name.set(name);
    Can help me find the error in the code? Or if there is none, is this a regression that should be submitted? As of now, all the PCs in use have 8u5.
    Thanks in advance.

    Correctly answered by James_D:
    http://stackoverflow.com/questions/28195552/javafx-tableview-context-menu-item-shows-up-when-run-on-java-8-until-update-5-bu
    pasted below:
    The fix is to create new menu items that are copies of the ones in the table's context menu:
    private ContextMenu showOnlyAppendContextMenuItemIfRowIsEmptyElseIncludeDelete() {
    ContextMenu rowMenu = new ContextMenu();
    ContextMenu tableMenu = table.getContextMenu();
    if (tableMenu != null) {
    for (MenuItem item : tableMenu.getItems()) {
    MenuItem rowItem = new MenuItem(item.getText());
    rowItem.setGraphic(item.getGraphic());
    rowItem.setOnAction(item.getOnAction());
    rowMenu.getItems().add(rowItem);
    rowMenu.getItems().add(new MenuItem("delete"));
    return rowMenu;

  • Tableview : Modify/Update/Append

    Hello All,
           I have a tableview with entries from a Database table.
    I have 3 columns in this table view.
    Out of all the 3 columns ,I made only one column editable ( 2nd column ).
    1, Now if i change the value in the 2nd column the internal table of the table view must get modified with the changed value .
    After that I'll modify the corresponding database table
    I want this to be acheived without selecting any line of the tableview after the changes.
    can it be done ?
    2, What is the procedure if I want to append one more entry to the table view .and also the appended line must also be appended to the internal table .
    Regards,
    Deepu.K

    Hello Raja,
             I tried as per ur code.
    But our gv_row is type i.
    So it's not concatenating as it needs type char or N or D or T.
    So I wrote the code like this :-
    data: gv_row type string,
            gv_len type i,
            cell_id type string.
    loop at gt_usr_par into wa_usr_par.
    clear gv_row.
    gv_row = sy-tabix.
    gV_len = strlen( gv_row ).
    gv_len = gv_len - 1.
    concatenate 'usr_parameters_tab' '_' gv_row(gV_len) '_' '2' into cell_id .
    value = request->get_form_field( name = cell_id ).
    if wa_usr_par-parva <> value.
    clear wa_usr_par-parva.
    wa_usr_par-PARVA = value.
    modify gt_usr_par from wa_usr_par.
    endif.
    endloop.
    Now it's working fine.
    Thanks Raja for ur valuable reply.
    Points are awarded . (: (;
    Regards,
    Deepu.K.

  • Tableview getting refreshed when changing data in the rows

    Hi Gurus,
    Iu2019m doing a BSP with MVC. The requirement is as below.
    In the main page there is a button u2018Create Orderu2019, to create a sales order, once I click this button, another screen (pop up) comes up and within that I have a Tableview display with the below fields with the data of 20 records.
    Material no
    Quantity
    Delivery Date
    Here user is allowed to choose the quantity and delivery date by selecting each row.(with MULTISELECT option in BSP)
    The issue is after I select first row and change the quantity and date, and if I click on second row, the Tableview gets refreshed to enable the second row to be editable and the changes what I did on the first row are also refreshed.
    So i want the Tableview not to be refreshed when selecting the multiple rows. So that I can keep the changes I make to the quantity and date fields Can you please suggest any method.
    Cheers,
    Srini.

    Hi Srinivas,
    You need to capture the value entered by user in Quantity and date field and update the internal table with these values for the current selected row.
    For ex.
    The tableView code is like:
                          <htmlb:tableView id                  = "material"
                                     headerText          = "<%= otr(Z_SUS/HEADER_TEXT_MATERIALS) %>"
                                     headerVisible       = "true"
                                     design              = "alternating"
                                     onRowSelection      = "MyEventRowSelection"
                                     selectionMode       = "MULTILINEEDIT"
                                     width               = "880"
                                     filter              = "SERVER"
                                     emptyTableText      = "<%= otr(Z_SUS/EMPTYTABLE_MATERIALS) %>"
                                     iterator            = "<%= iterator %>"
                                     table               = "<%= gt_materials %>" />
    In eventhandler OnInputProcessing :
    DATA: lt_fields type tihttpnvp ,
               ls_fields like line of lt_fields.
    call method request->get_form_fields
                changing
                  fields = lt_fields
    Now the internal table lt_fields contains all the editable cell values , just update the internal table of your tableview with these values.
    You can try these threads
    [Thread-I.|Re: Retrieve changes made in tableView]
    [Thread-II|https://forums.sdn.sap.com/click.jspa?searchID=24460585&messageID=5516977]
    Search the forum for more information on this.
    Regards,
    Anubhav

Maybe you are looking for

  • Displaying/Printing Sub-group Details for Each Parent Group

    My question is based on the example code provided under the "Creating an RTF Template" chapter of the Oracle Business Intelligence Publisher Report Designer's Guide, Release 10.1.3.4, Part Number E12187-01. I modified that example as follows: <?xml v

  • Cd  burn laser power error

    i have a brand new macbok pro and ive had it for two weeks and this is the fisrt time ive tried burning a disc and an error message pops up that says: "Unable to burn disc.The device failed to calibrate the laser power for this media." I cant figure

  • Author metadata separated by semi-colons truncated in file properties and "Get Info"

    I'm using Acrobat Professional 9.0 (CS3) for Mac to edit the metadata for a collection of PDFs to be made available on the web. When I enter the data, I am inputting a list of authors separated by commas, like this: Smith J, Watson C, Brown J. If I c

  • Allow unix account user to execute sqlplus in 10g

    we have created a user with default groups and we required allow him to execute sqlplus command but it is giving errors. ( on same system we have db and oracle account). we do not want him to login into sysdba but as normal user so that he could ente

  • Help Required on Comparison of Holt Winters with other Forecasting techn

    Hello, I have implemented Holt Winters Algorithm to forecaste various matrics like RTT, Throughput over the network. I want to compare my results with some other forecasting algorithm that work for such time series data. Can some body provide me with