system.nav.swapTo Failure

I have a project that uses a sidebar type navigation scheme, with a bunch of buttons that swap the main windows based on canned swapTo scripts in the actionPerformed event of each button. These are just the standard scripts that are generated by selecting the various navigation options. In this project, frequently the windows just don’t swap. Sometimes it works, and sometimes it doesn’t. I’ll click on a button to swap screens, nothing happens, so I click a different button to go to a different window first. Then I click on the first button and it will correctly switch to the window I want.

This has happened with this project on multiple gateways. One was version 7.7.4, but this one is 7.7.5. Java version is 8r51, but the version on the other gateway was 7r79 I believe.

Any suggestions?

Look in the Windows menu at the top of the client and see what windows are open. Most likely you have two Main Window type windows open and the client is getting confused about which one to swap. If that is the case you will have to figure out how two Main windows are being opened. I’ve found that a few times I’ve made the mistake of using the wrong function to swap main windows and caused the same issue. Double check all of your window swapping, back button coding.

I’ll take a look at that, but I’m almost positive I’ve only got one main window open. Each of my navigation buttons uses the swapTo function, so I don’t know how I could end up with multiple main windows open.

No luck. Any other suggestions?

Just updated to 7.7.5 Ignition and Java 1.8.0_60-b27 and my system.nav.swapto in my client startup scripts are not working anymore also.

Calling support when they open

Sorry for the 2+ years late response. This appears to be a bug with the system.nav.swapWindow function. Use the system.nav.openWindow function instead and all of your problems will melt into the past!

Don’t worry about it opening up multiple windows b/c it won’t (but it will if you use system.nav.openWindowInstance.

Hope this helps!

Please watch out here. system.nav.swapTo and system.nav.openWindow will cause different navigation strategies.

The swapTo closes your current screen, and opens a new one instead. The openWindow opens it on top. Once you use openWindow for full-screen windows, you can no longer know what the current window is, and if you mix it with the swapTo strategy, it will fail at some point.

So for full-screen windows (no popups), you need to choose the one or the other.

Both strategies have some advantages and disadvantages:

  • swapTo:

  • Makes it possible to get the current window, and f.e. update some gui parameters (like a button appearance on a navigation bar) according to it.

  • Closes the screens, so cleans up the tag subscriptions which frees some resources (certainly hand on an installation with many screens and many clients).

  • Is quite fragile IMO, a bug that fails to close the window (f.e. some timer scrip hanging on the page) will destroy the navigation strategy and may need a full restart of the client).

  • openWindow:

  • Keeps the windows active, so makes switching windows faster, but has a higher resource usage on the clients and server

  • Doesn’t work with the standard “back” and “forward” options. So needs custom implementations to keep track of your current window and the window history

  • Is more robust AFAICS

We’ve used both on different projects, and both work properly when not mixed.

Point taken. I did notice the windows (I have 3 in my current project) actually staying active, but as you mentioned, it is much faster and I don’t have to refresh the window (ie re-query a large Database) when re-opening it albeit taking up more resources.

I’ve only been working with Ignition since 2/18. Thanks for the clarification and I’ll keep your advice in mind!

Does anybody know if they are going to address the bug in the system.nav.swapWindow function??

What bug in the swapWindow function? It's always been the case that having multiple main windows will interfere with swapWindow, which is why it's specifically mentioned in the documentation. If you've had some other issue with swapWindow, I would get in contact with support, but literally every case I've ever seen of swapWindow not working came down to having multiple 'main' windows open.

3 Likes

Earlier in this thread it is mentioned that there is a bug in the system.nav.swapWindow function.

One poster called it a bug, and was corrected. It’s not a bug. Mixing openWindow() and swapWindow() is a bug on the integrator’s part.

3 Likes

Back and forward navigation isn’t as useful as I thought it would be.
When using the system.nav.swapTo method, the back and forward navigation does not retain the param dictionary?

I’m using a window as a container that builds its content dynamically from parameters. Back and forward navigation just shows the window with the latest parameter.

Is there a better way to better track windows with its parameters? Like API that provides the stack of windows the client visited with parameters.