data dependent setter

8 views
Skip to first unread message

Richard Dijkstra

unread,
Jul 8, 2020, 10:37:22 AM7/8/20
to TopBraid Suite Users
Dear all,

I would like to have a state added to a uri. I use ADS for this as follows:

I have extended the class with:

class extends workitemonto_Workitem {
set_state(){
    if (this.Budget > 0 && this.ResourcePlanningOK == true){
        this.State = '1_OK' ;
        }
    else {
        this.State = 'NOK2' ;
    }
    }
}

And set focusNode.set_state() on the attribute inferences values

The State attribute is not recalculated when I change the data. What is wrong?

Kind regards, Richard

Holger Knublauch

unread,
Jul 8, 2020, 8:02:55 PM7/8/20
to topbrai...@googlegroups.com

Could you clarify what your expectation is?

Did you assume that this.State will update automatically when this.Budge or this.ResourcePlanningOK change? No, this would not work. You still need to call the function explicitly.

Or are you saying that this.State doesn't change even after calling set_state again (after data changes)?

An alternative design would be to use the code below as a sh:values rules at the State property:

    (focusNode.Budget > 0 && focusNode.ResourcePlanningOK == true) ? '1_OK' : 'NOK2'

Then any request of this.State would be dynamically computed from the expression above, including the Forms, JavaScript and GraphQL queries.

Regards,
Holger


Kind regards, Richard
--
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to topbraid-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/5d76d937-ce91-46ea-a953-ac56b31de87bo%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages