Perspective: Open Vision Window

Hi Everyone!

Can anyone answer me one question: Is it possible to open an Vision window from Perspective via Gateway or Session scripts?
The idea is: I connect one Perspective page (via WebBrowser) in Vision, so I need open an Vision window when I click the button (in Perspective page).
I tried to do that (via Project Library script, Gateway Script and Session Script), but I get error, that nav (when I use system.nav.navigate()) is not allowed.

Thanx in Advance!

Perspective scripts run in the gateway, so there’e no system.nav you can use.

Since Perspective and Vision are separate sessions, you would probably need to use system.util.sendMessage() to signal the Vision session to switch windows.

2 Likes

Thanx!!!
It works!!! :heart_eyes:

Hi,

One problem: When I open new window in Vision, so it opening on all clients…
I tried to use “clientSessionId”, but it didn’t help… (I used Session ID variable.)
Maybe You know how to use this Message only on client who opened window…?

In the System tag Folder I didn’t find any session Id also…
and… I looked for the information about clientSessionId, but >here<… I didn’t find anything also…(((

Someone more knowledgeable than me will have to answer that one to be sure, but if it’s on the same machine, then would session.props.host in Perspective be the same as [System]Client/Network/Hostname in Vision?

1 Like

You could also pass a session ID into Perspective (for it to send back out) using a URL parameter; you would just construct the URL property on the web browser component in Vision dynamically using the system/client tag; see https://docs.inductiveautomation.com/display/DOC80/Pages+in+Perspective#PagesinPerspective-PassingParameters(URLParameters) for more details.

1 Like

The link to the page is in Vision’s WebBrowser
I don’t have any clue how to send to the Browser URL link with parameters. :confused:

Put a binding on the starting URL property, something like:
"http://gatewayip:8088/main/system/perspective/project/view?session=" + runScript("system.util.getClientId()")

1 Like

THANX so much! It works! :star_struck:

in 8.1.1 this script doesn’t work…

I also tried disable this script and popoup doesn’t openat all…
when I launch a perspective without Vision (in Browser) it works, but in Vision WebBrowser PopUp doesn’t work…

in log I get this kind of message:

Flood limit tripped, starting 5000ms cooldown.
image

and… after update, I get the white screen

:confused:

You’re running some script on the JxBrowser internals which broke because we bumped the JxBrowser version from 6 to 7. It’s not related to any of the scripting in this thread.

and how to open popups now?

Has this ever worked? A button script in Perspective, even when running in a Vision Web Browser component, is still going to execute in the gateway.

:upside_down_face:

SURE!! It works perfectly!
I decided to downgrate to version 8.0.16 only because of that problem, because we VERY need this function! :see_no_evil: :hear_no_evil: :speak_no_evil:

Paul suggested you’ve got some other script written against implementation details of JXBrowser 6. Can you share that script?

Specifically, whatever is being passed to system.util.invokeLater.

I can for sure)
The main problem was in PopUp’s sizes. When I pushed the button to open it, PopoUp was so small…
I didn’t write it by myself. I can’t remember who gave me this, but here we go:

if event.propertyName == 'componentRunning':
	def addPopupHandler():
		from javax.swing import JFrame, WindowConstants
		from java.awt.event import WindowAdapter
		from java.awt import Dimension, BorderLayout
		from com.teamdev.jxbrowser.chromium.events import DisposeListener
		from com.teamdev.jxbrowser.chromium.swing import BrowserView
		from com.teamdev.jxbrowser.chromium import PopupContainer, PopupHandler
		from functools import partial

		class MyWindowAdapter(WindowAdapter):
			def __init__(self, browser):
				self.browser = browser
				
			def windowClosing(self, e):
				self.browser.dispose()

		def showPopup(browser, initialBounds):
			browserView = BrowserView(browser)
			browserView.setPreferredSize(initialBounds.getSize())
			frame = JFrame("Popup")
			frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE)
			frame.add(browserView, BorderLayout.CENTER)
			frame.pack()
			frame.setLocation(initialBounds.getLocation())
			frame.setVisible(True)
			frame.setMinimumSize(Dimension(1248, 768))
			frame.addWindowListener(MyWindowAdapter(browser))

		class MyPopupContainer(PopupContainer):
			def insertBrowser(self, browser, initialBounds):
				system.util.invokeLater(partial(showPopup, browser, initialBounds))
		browser = event.source.getBrowser()
		class MyPopupHandler(PopupHandler):
			def handlePopup(self, params):
				return MyPopupContainer()

		try:
			browser.setPopupHandler(MyPopupHandler())
		except:
			1

	system.util.invokeLater(addPopupHandler, 5000)

Popups in JXBrowser 7: https://jxbrowser-support.teamdev.com/docs/guides/popups.html#swing

2 Likes

:heart: thanx! I will try it later when we back to 8.1.1 stable version…

Hi,

How to refresh Vision Page?
Problem is… When happens that connection was lost, so the Client ID changes its value.
but…
so… on the WebBrowser StartingURL:

runScript("'http://ip:8088/data/perspective/client/project/vision/'+system.util.getClientId()")

doesn’t change when connection is back…

so… is there a way to refresh a Vision Page?
I need it for running client scripts for open Vision page.

Thanx in Advance…