Skip to main content

No trigger event on new NULL value, and do / do later nesting

1 reply [Last post]
Joined: 2007-08-14

Q1: Is it correct that a trigger doesn't fire on a NULL newvalue ?

<br />
trigger on TestModel.testTrigger = newVal {<br />
    MessageDialog {<br />
        message: "New value: {newVal}"<br />
        visible: true<br />
    }<br />
}<br />

This trigger fires on all new value objects put into testTrigger but not on NULL values.
Is this correct behavior or did I miss something?

Q2: Is this type of nesting a correct threading approach (SwingWorker style)? It's hardly clear from the docs.

<br />
do {<br />
    // expensive remote call off EDT<br />
    var p = ServiceLocator.getPerson(id);<br />
    do later {<br />
        // inject result from remote code in bound model on EDT<br />
        model.selectedPerson = p;<br />
    }<br />
}<br />

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2003-08-07

I have also noticed strangeness with regard to null values -- for strings, a good workaround is to use "" instead.

JavaFX threading is pretty rough at this point, and not well documented. What you wrote may work, but the most consistent way to get things working is this:

var p;
do {
// expensive remote call off EDT
p = ServiceLocator.getPerson(id);
// inject result from remote code in bound model on EDT
model.selectedPerson = p;

JavaFX waits on completion of the do{} block before proceding to the next line. Putting the do later {} on the outside may also be reasonable if you aren't sure if the code is already in the EDT.