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

Similar Messages

  • [Bug?] Defer Panel Update not working when changing scale property

    Hi,
    I found that Defer Panel Update [when True] does not work properly when changing the scale fit property of an intensity graph.
    Try the VI.
    When Defer Panel Update is True, and you change the Numeric controls, the Intensity graph is not updated (as expected).
    But now change the "Z Scale.Scale Fit" button and.... the Intensity graph is updated (only the Z-color, not the axis).
    This looks to be a bug to me!
    Nicolas
    Attachments:
    [Bug] Defer Panel Update not working when changing scale property.vi ‏27 KB

    Hi Nicolas,
    This indeed looks like a bug. I will do more research on it and file a bug report if it's not already filed.  Thank you for posting this information!
    Yi Y.
    Applications Engineer
    National Instruments
    http://www.ni.com/support

  • Delta update not working when i change material master data

    Hi SAP Guru's
    can any body help me in solving my issue.
    My issue is i created a data source with a function module to create delta in change date field LAEDA.
    .Full upload is working fine based on the selection screen but delta update is not working properly .
    it is working as full load run for every first run of the day.
    Please can any body help me in this.
    What i did in ECC.
    I copied the FM 'RSAX_BIW_GET_DATA_SIMPLE to Z function module.
    Done a select on three tables and passed the data into e_t_data
    In Rso2 i attached LAEDA filed after clicking generic delta field.
    after completing the steps in ECC
    Any help will be apperitiated .
    Thanks in advance

    Did you actually change the sold-to party though or just the payer?  The sold-to party's price list type controls the price list type value copied into the order header.  Even if the payer has a different value, it's not copied to the order header.  You can see this behavior in FV45KFKD_VBKD_FUELLEN.  If you switch sold-to's then you should get a pop-up that new pricing was carried out; you should also see your new price list type value in the order header and you can use the 'analysis' function at the item level to verify that the correct price was used.

  • Software Update Not Working - Stuck at "Checking for New Software"

    Hey Everybody,
    I have recently been experiencing problems with my Software Update. After I open it, it gets stuck at the screen and times-out after a while asking me to check my network to see if I'm connected to the Internet. My internet is working fine yet the Software Update is still not working. I have tried removing the Software Update pdlist and trying to change the cache.db yet nothing is working. I have run the verify disk and repair disk utility with no result. Anyone got any other ideas other then a clean install?

    See if the following fixes the problem:
    Fix for Software Update
    See Troubleshooting Automatic Software Update in Mac OS X.
    Delete the following files:
    /Library/Preferences/com.apple.SoftwareUpdate.plist
    /Home/Library/Preferences/com.apple.SoftwareUpdate.plist
    /Home/Library/Preferences/ByHost/com.apple.SoftwareUpdate.xxx.plist
    "xxx" is a number.
    /Home/Library/Caches/com.apple.SoftwareUpdate/ (delete entire folder)
    Message was edited by: Kappy

  • HP-2840 needs new drum (Q3964A) and I am told my printer will not work when I install a new drum

    My HP2840 laser jet All-InOne has been telling me for 6 months that I need a new drum. I was waiting until I saw an issue with my print quality (which I never had a problem) and now my printer will not work unless I replace the drum.
    A friend told me that even after installing a new OEM drum, that my printer will still not work unless I call HP and pay for them to tell me how to make it work.
    Is that true?
    I need help fast cause now my wife is really angry that I "broke" the printer!
    Thanks in advance!

    mmcnel01 wrote:
    Is this an official HP forum?
    If so, is there anyone from HP - maybe a moderator or someone, that will respond to my question?
    This is a user to user forum and is not an official link to HP support.  I would suggest that you contact HP as shown here. 
    Bob Headrick,  HP Expert
    I am not an employee of HP, I am a volunteer posting here on my own time.
    If your problem is solved please click the "Accept as Solution" button ------------V
    If my answer was helpful please click the "Thumbs Up" to say "Thank You"--V

  • Speakers not working when using iTunes on new Dell computer

    I just got a new Dell Latitude e4300 laptop and the speakers will not work with iTunes. I can play audio from any website, but am getting nothing in iTunes. Any idea why this would be? Any fixes for this?
    Jeff

    Hi,
    Please try to diable HDMI sound from Playback devices
      Right click the speaker icon,
      Select Playback devices
      Right click HDMI sound
      Disable it.
    Regards.
    BH
    **Click the KUDOS thumb up on the left to say 'Thanks'**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.

  • IMessage not working when I start a new conversation iOS 6

    Hey guys, the thing now is that since I updated my iPhone 4S to iOS 6 is like the phone does not recognize my iMessage contacts.
    I can use iMessage, but the thing is that I only can send an iMessage if I go to my messages box and open an old iMessage conversation.
    If I want to start a new conversartion the send button never turns blue.
    I even tryied from Siri. Didn't work.
    It is not so bad but still annoying.
    As an additional information, in Ecuador, they just added a new digit in the international code. It shouldn't be a problem because my mobile number is already accepted by iMessage on my iphone settings.
    Hope you can help guys. I would be very grateful.

    UPDATE:
    I just discovered that the problem is that from my Messages software in my iMac mobile numbers are not recognized (even if they were accepted on the iMessage settings on my phone).
    If I send a message to my imessage contact, that contact receives it as a normal SMS but when he answers it is sent as an iMessage and then I can reply as an iMessage.
    But it is not possible to avoid the waste of that SMS.
    Maybe is the new digit thing.

  • Why do hyperlinks not work when Firefox loads a new web page?

    Today, for no apparent reason and for the first time ever in years of using Firefox, I am finding that when a new page loads I cannot select any of the hyperlinks on the page. This is happening on 90% or more of pages I access. If I navigate to a different application (using Alt+Tab for instance) and back to Firefox, the hyperlinks will work. But if I select one of them and a new page loads, I am back to being unable to click on hyperlinks.
    This is manifested by the cursor remaining as an arrow and not changing to a pointy hand when hovering over hyperlinks. It also seems to affect the ability to use the GUI buttons and the minimise/restore/maximise/close buttons in the top left corner of the title bar. Ribbon menu items, curiously, seem to work as normal, except that if I open, say, tools/options, I will have to navigate away from Fireox and back again, before being able to use the Options window that opens. It also prevent me from selecting other tabs. And I'm even having trouble using the Mozilla Support Forum form to post this question.
    I have tried running Firefox in safe mode and reinstalling the software, all to no effect
    == nothing in particular happened

    Do you have that problem when running in the Firefox SafeMode?
    [http://support.mozilla.com/en-US/kb/Safe+Mode]
    ''Don't select anything right now, just use "Continue in SafeMode."''
    If not, see this:
    [http://support.mozilla.com/en-US/kb/troubleshooting+extensions+and+themes]

  • Mail not working when connected to a new network

    Whenever I connect to the network at work I can't send mail. I can receive mail though. I can't use my airport at work. Could this be the problem?
    Thank You
    Tamara

    Unless your employer has a wireless router and wireless network, you can't use Airport when at work.
    Assuming you have a business email account provided by your employer, you can't send mail with your business email account either when connected to your employer's network and internet access at work?

  • Why is my left audio output not working, when I have brand new headphones? (6th Generation Ipod Nano)

    I have recently been having problems with my Ipods audio output... The Left headphone puts out No sound at all... I am positive it is not my headphones... Any solutions or is it a harware problem??
    Hope to hear Back ASAP thanks

    iPod Nano Touch? (I must have missed the announcement of that model of iPod!)
    Regardless of which model of iPod you have (and if it's a Nano, why submit your question to the Touch forum?), some car charging devices charged iPods via the firewire line, which was fine for the first iPods on the market. Some later iPods charged by firewire or USB. New iPods do not have firewire and cannot be charged by firewire. They only charge by USB
    So perhaps your old iPod (again, whichever model it is) charged by fireware.

  • SP2013: OK button not working when editing Settings on List app

    Hi, all!  Currently running Sharepoint 2013 under Server 2008 R2.  My client is Win7 Pro/64-bit running lastest Firefox, Chrome & IE11.  I am currently a Domain Admin for our corp domain.
    Long story short, I've created a test List app.  When I attempt to add a column to the layout of the custom list app, nothing happens when I click the OK button to save the app.  No access spinning, no errors on-screen (also none visible when I view
    the source of the SP page or header), no nothing.  The highlight of the button changes as expected, but nothing else.  The Cancel button will Cancel as expected, but OK does nothing whatsoever.
    My current permissions include member of Domain Admins, Site Owners (Full Control), and Visitors (Read).  A Check Permissions on myself yield the following:
    Full Control   | Given through the "~site~ Owners" group.  
    Read   | Given through the "~site~ Visitors" group.  
    Edit   | Given through the "~site~ Members" group.  
    (Note: "~site~" is replacing the actual SP2013 site name above)
    I'm thinking it has something to do with effective permissions.  I just added myself to the Owners group this morning with no effect.  I've also tried both Compatibility mode on and off in IE, and Firefox and Chrome don't work, either.  Suggestions
    are most welcome as I'm at the point where I'm not sure if IE11 is causing a problem or if it's actually an effective permissions problem that's preventing me from saving any column changes to the List app above.
    Thanks, guys!
    Steve

    Hi Steve,
    From your description, my understanding is that OK button does not work when you create a new column.
    Please check if you get any JS error after you click OK button by pressing F12 to OP developer tool.
    Besides, please try to create a new column with steps below:
    1.      
    Click LIST tab in the Ribbon.
    2.      
    Click Create Column in Mange Views section.
    3.      
    Create your column in the dialog.
    4.      
    Click OK button.
    In addition, please confirm these points below:
    1.      
    Test your issue in another list.
    2.      
    Test your issue with another computer.
    3.      
    Test your issue with another account.
    Best Regards,
    Vincent Han
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • I have i phone 4s i there is problem of wifi my wifi is not working when i go to the wifi there is no working on off when i update it as a 6.1 ios on that time again it was good but after 2 days again the same problem i am too tired

    I have i phone 4s i there is problem of wifi my wifi is not working when i go to the wifi there is no working on off when i update it as a 6.1 ios on that time again it was good but after 2 days again the same problem i am too tired and i also reset network setting but nothing gonna be worked

    Sounds like the device was dropped at some point and damaged as a result.
    Take it to Apple for evaluation and a replacement.

  • I tunes is not working. when i go to update apps nothing happens go to itunes page is blank

    itunes not working. when i go to update apps nothing happens. if i go to itunes store page is blank and does not go to the store

    http://support.apple.com/kb/ts1567

  • HT201413 Device does not work when I connect it to your computer to the iTunes program update requests and then gives me an error No. 21

    Device does not work when I connect it to your computer to the iTunes program update requests and then gives me an error No. 21

    Device does not work when I connect it to my computer to the iTunes program update requests and then gives me an error No. 21

  • Why is my password not working when i want to update apps?

    Please tell me why my Apple ID is not working when i want to update apps?(just the purchased apps are not working).I now have an acount that dosen't have a card entered.

    For examle i have iGO primo and my password is not working (i already reset it).

Maybe you are looking for

  • Stuck in a complicated situation

    I have to come up with a query for report which is dependent on what is selected in the 7 drop boxes. startdate: enter text enddate: enter text Department: Deptname Group:drop down (values like All, Supervisor, Manager, etc) Classification:drop down

  • How i can make in the same action 2 condition (check the exemple down)

    how i can make in the same action 2 condition (check the exemple down) this is an example and I really thank you for helping me(any body plz) http://www.2shared.com/file/DPpdgC_a/Exemple_Edge.html

  • Need help adding music to Imovie.

    I've been working on a slide show in Imovie and importing music I've purchased at Itunes. I find some of the songs need to be shortened to work with the amount of pictures I have. What I did was purchase a song at Itunes, burned this song to a CD, th

  • WLAN ... DWL-G122-C1-3.10/ Ralink RT2500 und OS Lion 10.7.4

    Hey guys, hope that somebody can help me. Device: D-Link DWL-G122 C1 3.10 - Chip: Ralink RT2500 Router: D-Link Wireless N Home DIR-615 OS: Lion 10.7.4 - 64bit Problem: If I install the driver RTUSBD71w-1.3.0.0_UI-3.0.0.0_2010_04_13.dmg , which is act

  • Distinct count differnt from variable count on group

    I have a date field and a number field. I have grouped the date by week and by month. I have created a  DistinctCount summary on number field and placed in each group. I also created a variable formula which gets reset in each group header. I get dif