Open nyzzik opened 5 months ago
@nyzzik
Can you test the latest 2024.2.2-SNAPSHOT build?
Executing JS commands directly after calling WebAPI.openStageAsPopup()
should work now.
We should probably also redesign the openStageAsPopup() API. Be aware, that when you set the owner of s Stage, it's always shown in the main application. Which could also be a solution to what you are trying to achieve.
On 2024.2.2-SNAPSHOT I am running into the same error
app.getWebAPI().openStageAsPopup(as);
WebAPI.getWebAPI(as.getScene()).executeJSAsync("window.resizeTo(700,300);");
This is the code I am trying to execute, app
being my main JProApplication and as
being the stage I am opening up.
Can you add the initial output of your server - with the JPro build-timestamp? This is to double-check that you are running the correct version. (You might have cached the previous build)
[INFO ] c.jpro.activity - Starting the server
[INFO ] c.j.i.s.JProInitializer$ - *** Starting JPro: https://www.jpro.one/ ***
[INFO ] c.j.i.s.JProInitializer$ - OS: Windows 11
[INFO ] c.j.i.s.JProInitializer$ - JPro: 2024.2.2-SNAPSHOT
[INFO ] c.j.i.s.JProInitializer$ - JPro buildtime: Thu, 27 Jun 2024 11:57:03 -0400
[INFO ] c.j.i.s.JProInitializer$ - Java version: 21.0.2
[INFO ] c.j.i.s.JProInitializer$ - JVM: 21.0.2 Oracle Corporation
[INFO ] c.j.i.s.JProInitializer$ - JavaFX jar: file:/C:/Users/{my user}/.m2/repository/org/openjfx/javafx-graphics/22.0.2-jpro/javafx-graphics-22.0.2-jpro-win.jar
[INFO ] c.j.i.s.JProInitializer$ - Configuring logging from url: 'jar:file:/C:/Users/{my user}/.m2/repository/com/sandec/jpro/jpro-server_2.12/2024.2.2-SNAPSHOT/jpro-server_2.12-2024.2.2-SNAPSHOT.jar!/logback-jpro-default.xml'
[INFO ] c.j.i.s.JProInitializer$ - JavaFX version: 22.0.2-jpro+0
G1 Young Generation
G1 Concurrent GC
G1 Old Generation
[INFO ] c.j.i.s.JProInitializer$ - finished init!
[INFO ] c.j.i.s.JProInitializer$ - [JPro] -> Server started: {start_time: 1719936727164, os_name: Windows 11, jpro_version: 2024.2.2-SNAPSHOT}
[INFO ] a.e.s.Slf4jLogger - Slf4jLogger started
[INFO ] play.api.Play - Application started (Prod) (no global state)
[INFO ] p.c.s.AkkaHttpServer - Enabling HTTP/2 on Akka HTTP server...
[INFO ] p.c.s.AkkaHttpServer - Listening for HTTP on /0.0.0.0:8080
[INFO ] c.jpro - application requested: MyApp params: Map(instanceID -> List(573772191))
[INFO ] c.jpro - Creating Application: MyApp
[INFO ] c.jpro - remoteAddress 127.0.0.1
[INFO ] c.jpro - host localhost:8080
[INFO ] c.jpro - uri /app/ws/MyApp?instanceID=573772191
[INFO] [start] - 2024-07-02T12:12:11.300826 - JPro server is alive!
[INFO ] c.j.i.s.ViewInfo$ - [JPro] -> View created: {app_name: myapp, host_name: localhost:8080, instance_id: 782208353, browser: Unknown, browser_url: http://localhost:8080/, client_ip: 127.0.0.1}
It looks like i am running the correct version
After deleting the version that was in my .m2 repository and redownloading it, it looks like it is working now. It doesnt seem to be working in firefox but that seems to be a firefox thing not a jpro thing. Are there any other ways of resizing the popup or would this be it?
Thanks for the help.
I'm thinking about redesigning how the popup API works. Technically, we can set both the x/y position and the width and height. I guess it's still a surprise what the browser is doing with it. But that's a non-trivial improvement to JPro.
This is basically what the showStageAsPopup API is doing:
val quoted = JSONObject.quote(url) executeScript(s"""window.open($quoted,'_blank','height=500,width=400,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no, status=yes');""")
So you can copy it and adapt it to your needs.
However, I recommend against using "browser" popups; instead, show either the stage with the owner property or somehow show it inside the application.
I am trying to resize a stage popup after calling
WebAPI.openStageAsPopup()
. I found a way to do it using javascript usingwindow.resizeTo()
however this is only working when i set it trigger on button press. If i call it after I popup the window i get this error. I have tried doing it in the JavaFX initialize method as well as setting up a window on load event listener using javascript and receive the same error. Is a way to resize the popup window?