0

I followed this example to bind some textfield: Example of using Bindings for validation in JavaFX. by james-d

Now, I would like to know if it is possible to do the same with the columns of a table.

That is, when an empty top row is changed, if certain cells of certain columns are filled, then, the entered data has to be saved in a database.

After that, I do not know if it can be useful for troubleshooting, must appear a notification made by ControlFx package that says that the data was saved. The notification must appear is this

SOLVED BUT NOT WITH BINDING

I solved my problem in this way:

  • Added a table.refresh() in commitEdit in the setCellFactory
  • Add a column with save button that check if the other cells is empty or not. If the cells are empty the save button automatically is disabled, otherwise, you can save.
V_Martusciello
  • 47
  • 1
  • 10
  • 1
    You are really asking for quite a lot here, so I'll just vote to close it as too broad. You should try to make the question less open-ended (e.g. the notification request can be treated differently as a completely separate question). So, narrow down the scope and post your [mcve](http://stackoverflow.com/help/mcve), (emphasis on both minimal and complete for the simplified problem at hand). – jewelsea Aug 22 '16 at 23:22
  • Some related (but different questions): [Programmatically change the TableView row appearance](http://stackoverflow.com/questions/20350099/programmatically-change-the-tableview-row-appearance), [Background with 2 colors in JavaFX?](http://stackoverflow.com/questions/16200901/background-with-2-colors-in-javafx). Also note, TableView isn't really a spreadsheet editor control and giving it even the partial functionality of one is a pretty complicated task. You could investigate third party alternatives such as [TiwulFX](http://tiwulfx.panemu.com), to see if they will assist for your solution. – jewelsea Aug 22 '16 at 23:23
  • mmm, I have little time to implement the function, so I think I will opt for a save button for each line. Leaving aside the rescue notification, you know, is possible to implement the boolean binding on the TableView cell? Then if necessary the mod can also close :) – V_Martusciello Aug 22 '16 at 23:45
  • 1
    Try this gist [TableView row highlighting sample using table row apis and css](https://gist.github.com/jewelsea/5470095) as a basis, add a dirty property to your model object (similar to the willPay field in the sample), and, using the [low level binding API](https://docs.oracle.com/javase/8/javafx/properties-binding-tutorial/binding.htm) set the object to dirty when any field changes. Use a change listener on the dirty property to invoke a validation function on the object and persist to a database if a valid change occurs. You can test such an approach without a UI. – jewelsea Aug 22 '16 at 23:58
  • thank you, soon as I have time in these days I will try to develop the function, soon as all works, I will edit the question in order to help someone else who is in my same state :) If you create a response with what you wrote to me I can select it as the correct answer and close the question :) If you have else to help me I'm happy to wait for news of you :) – V_Martusciello Aug 22 '16 at 23:59

0 Answers0