skip to main content
OpenEdge Development: AppBuilder
Multiple Layouts : Switching between layouts at run time
 
Switching between layouts at run time
The multiple layout functionality that the AppBuilder provides is meant primarily to establish a layout once: when you run a procedure file. However, you can also switch among layouts at run time, if you write the necessary code to manage it.
Note: For SmartObjects, all of the code for switching among layouts at run time is managed by the ADM setInstanceProperties() function and applyLayout() procedure. For more information, see the “Applying SmartObject layouts at run time” section.
One way to switch among layouts is to have a trigger execute the CASE statement entries for the different layouts.
To have a trigger execute the CASE statement entries for the different layouts:
1. Execute the “Master Layout” CASE entry in the layout cases internal procedure with the following statement where the {&LAYOUT-VARIABLE} preprocessor name is set:
 
RUN {&LAYOUT-VARIABLE}s (INPUT "Master Layout").
This statement changes all of the run‑time properties to match those of the master layout. This step is necessary because all of the other layouts change their settings relative to the master layout. Thus, before you can switch to a new layout, you should switch back to the master layout.
2. Execute the CASE entry for the layout you want. The following statement sets all of the layout’s properties that you specify:
 
RUN {&LAYOUT-VARIABLE}s (INPUT "My Layout").
3. If necessary, write code that correctly enables the widgets in the new layout.
If widgets are enabled differently from one layout to another, you cannot execute the Enable_UI procedure to do your enabling. The Enable_UI procedure enables widgets based on WHEN phrases built using the layouts’ associated run‑time expressions. The explicit purpose of these run‑time expressions is to identify a unique run‑time environment. Since you want to switch layouts only within the same run‑time environment, you must write your own code to handle the enabling.