Enhancement
Major
Detail
Bugfix
Detail
Detail
#25858
Model editor reloads page on script execution
When running a test script (e.g. TestFormatOptions.script.xml) where the model editor is accessed via a goto, the log message appears that the page has been reloaded and the script recorder hangs after running the script.
Cause
The GoTo to DemoTypes.A opens the Diagram tab in the Model Editor and selects DemoTypes.A in the diagram. To be able to display a corresponding diagram, the client-side control tl:DiagramJSGraphControl is created. The control contains a tl:ObjectScope that contains, among other things, the graph itself, and is kept in sync with its server-side counterpart. Two tl:ScopeListeners are registered for the client-side tl:ObjectScope in the Model Editor:
- A listener that renders the diagram using uml.j s and diagram.js, respectively.
- A listener that sends changes of the client-side ObjectScope to the server (after 150ms) in order to update or keep the server-side ObjectScope in sync.
Currently, the listeners are first registered at the client-side ObjectScope. Then the ObjectScope is updated to match the state of the server-side ObjectScope. After that, the listeners are informed, i.e. the graph is rendered and the changes are sent to the server so that it can update its server-side ObjectScope. The latter action is meaningless in the case of diagram creation. When creating the tl:ObjectScope, the listener that keeps the two scopes in sync should not be registered until the client-side scope is initialized.
If the user executes a script that changes the graph and thus the client-side scope and then hides the diagram (e.g. by switching tabs), this usually leads to a reload of the page, since the command for updating the server-side graph or tl:ObjectScope is only executed after the diagram has been hidden, since the corresponding tl:CommandListener is no longer visible or no longer exists.
Test
ExecuteTestFormatOptions.script.xml. The script recorder should not stop. In particular, the page should not be reloaded.