Someone correct this if its wrong, but I believe that when you send a message from a new thread, the new thread is no longer running in the page scope, it loses the scope of the thread you called it from. So, you may have to play with the scope and maybe listen to session scope or even gateway scope to receive the message.
Bingo!
Use the extra args to system.perspective.openPopup()
to specify the session and page, using the instance of self
captured by jython's closure.
system.perspective
won’t be accessible from that thread. I’ve run into that gotcha many times. It does have access to self
though, so can set a property with an onChange
event that will have access to system.perspective
.
Is this because when using Timer
, it creates a new thread?
How would I implement self
, and what would self
be referring to: session, page, view, component?
That is because the thread invoked by Timer
does have access to self
, but does not have access to system.perspective
, so an Exception prevents it from executing when you place it after such a reference. You can’t send a message or open a popup from that thread. But you can use self
to set a custom property on the component or view. You could then set a change script on that property, which will have access to system.perspective
. The property could be a simple boolean that you set to True in that Timer
thread, then the change script of the property would check the value, and if True, send the message and open the popup, then set the property value back to False.
There is no e
there, so that will also raise an Exception.