Getting and setting global var's

75 views
Skip to first unread message

Ed H

unread,
Jun 2, 2020, 5:29:49 AM6/2/20
to GraphWalker
Hi,

I have a working example with two examples using global variables. Now I want to change the global variables from my java code. From all other threads in this forum I cannot find a solution how to make this work. Can somebody tell me how to get and set a global variable from code?

Cheers,
Ed

Ed H

unread,
Jun 2, 2020, 6:09:42 AM6/2/20
to GraphWalker
Small addendum: getAttribute and setAttribute doesn't work... 

Kristian Karl

unread,
Jun 8, 2020, 3:45:28 AM6/8/20
to GraphWalker
Hi Ed,

For the global variable to work, you need to prefix it with global.

Let me know if it fixes your problem.

Kristian

Ed H

unread,
Jun 12, 2020, 6:42:54 AM6/12/20
to GraphWalker
Hi Kristian,

This does indeed solve my problem. Thx.

Ed

Magnus Teekivi

unread,
Apr 4, 2021, 2:21:57 PM4/4/21
to GraphWalker
Hello.

I'm prefixing my global variables with "global." and yet I'm unable to access them in other model implementation Java classes.
I get an error like this:
java.lang.NullPointerException: Cannot invoke "org.graalvm.polyglot.Value.asString()" because the return value of "com.example.modelimplementations.SecondViewTest.getAttribute(String)" is null

I added a commit to my graphwalker-problem GitHub repository that demonstrates this problem in code.

Am I doing something wrong?

Thanks in advance,
Magnus.

Kristian Karl

unread,
Apr 7, 2021, 4:09:35 AM4/7/21
to GraphWalker
Thanks for the report!
I have a PR that address the problem: https://github.com/GraphWalker/graphwalker-project/pull/264
Reply all
Reply to author
Forward
0 new messages