In this blog we will look at external parameters and their usage to enable you to split applications. We will look at the reasons why you want to split first and subsequently look at the way you can make it happen. For the latter we will first look at the basics and then continue to look at the architectural part, how to link to other applications in the same window and finally to be able to go back to the original application.
There are a couple of reasons why you want to split applications into smaller applications that each perform a task.
When you look at performance you will see that the best way to optimize is to show few components and load as few datasources as possible. This is hard to do when you’re application reaches across multiple levels and has numerous click-through possibilities.
Each component that you add increases the possible number of interconnected components. You can address each component from each component with script. When your application contains hundreds of components you have to be careful to keep them under control.
When you work with multiple applications you can have multiple people working on them at the same time. Each application can also be independently called from any other application.
Before we go into the extras, lets revisit the basics. If you want to open a new application you use the method APPLICATION.openNewWindow(Url);
The Url in the parameter Is the address of the application you want to go to. A very basic script of how this would work is this :
var servername = "http://localhost:57821/aad/zen?APPLICATION="; var application = "STORE_SALES"; var parameters = "&store=29938&period=20160401"; var newUrl = servername + application + parameters; APPLICATION.openNewWindow(newUrl);
In this example a new application STORE_SALES is opened and two parameters are passed. Store and period.
In the application STORE_SALES you need to define variables to accept these parameters.
In the start script you can work with these Global Script Variables.
Agree on architectural level on the names of the parameters
If you create multiple applications it is a good idea to agree on the names of the variables and require each application to be able to handle them. When you have this in place the advantage is that you can blindly pass a set of parameters to another application knowing that that other application should understand what you mean.
So in our example. If someone else developed STORE_SALES it doesn’t matter as long there is agreement that Xstore and Xperiod are generally accepted parameters. It basically enables you to call any application and tell the other application what’s going on. Based on that the other application picks up and moves on.
Move to other application in frame
If you want a more seamless experience for your users you may want to have all the applications open in the same window. For that purpose you can use the Open url inplace component that was created by Karol Kalisz. Design Studio SDK: Open Url Inplace Component. With that component you use code like
OPENURLINPLACE_1.removeAllParameters(); OPENURLINPLACE_1.addParameter("P1", "V1"); OPENURLINPLACE_1.addParameter("P2", "V2"); OPENWINDOWPOST_1.triggerExecution(); Instead of the APPLICATION.openNewWindow() method.
Callback to the referring application
Finally if you want to let the applications work together you have to find a way to go back to the previous applications in such a way that it is shown as it was when you left it. For that you can use two parameters Xreferapp and Xreferpar.
Xreferapp holds the application where you came from and the Xreferpar holds all the parameters you need to inform the application where you were when you left that application.
For example if you were in level 2 of the dashboard application and looking at productgroup non-food your parameter value of Xreferpar could hold
When you press a back button the application then opens the url in Xreferapp with the parameters in Xreferpar added. The original application should know how to use these values to recreate the previous state of the application.