The Genero Browser Client (GBC) provides a mechanism for applications to be run as child programs that execute in the background, that is the parent program can continue to run without waiting for the child program to finish. To present this feature, we are providing you with this demonstration.
Before you begin
It is recommended you complete the topic regarding Stacked windows prior to completing this demonstration.
Start the standalone dispatcher from the command line using httpdispatch
.
$ httpdispatch
- Launch the Genero Workplace Window to ensure an environment suitable for Genero commands.
Open the demos application in your browser by entering the URL: http://localhost:6394/ua/r/gwc-demo.
Run without waiting demonstration
For this demonstration, you will need to write and compile a Genero application.
This example starts an application with stacked windows. It gives you the option to use a RUN WITHOUT WAITING command to start another instance of the application as a background process.
1. Create the Navigation app source
Copy and save the following Genero source as a file named Navigation.4gl
.
MAIN
DEFINE cw STRING
DEFINE i INT
IF num_args() = 0 THEN LET i=1 ELSE LET i=arg_val(1) END IF
OPEN FORM f FROM "Navigation"
DISPLAY FORM f
DISPLAY "screen" TO fname
OPEN WINDOW w1 WITH FORM "Navigation"
CALL fgl_setTitle("Window w1 - " || i)
DISPLAY "w1" TO fname
OPEN WINDOW w2 WITH FORM "Navigation"
CALL fgl_setTitle("Window w2 - " || i)
DISPLAY "w2" TO fname
OPEN WINDOW w3 WITH FORM "Navigation"
CALL fgl_setTitle("Window w3 - " || i)
DISPLAY "w3" TO fname
WHILE 1
DISPLAY "YES" TO info
MENU "Test"
COMMAND "w1" LET cw="w1" EXIT MENU
COMMAND "w2" LET cw="w2" EXIT MENU
COMMAND "w3" LET cw="w3" EXIT MENU
COMMAND "screen" LET cw="screen" EXIT MENU
COMMAND "RWW" RUN "fglrun Navigation " || i+1 WITHOUT WAITING
COMMAND KEY(INTERRUPT) "Exit" EXIT PROGRAM
END MENU
DISPLAY "NO" TO info
CASE cw
WHEN "w1" CURRENT WINDOW IS w1
WHEN "w2" CURRENT WINDOW IS w2
WHEN "w3" CURRENT WINDOW IS w3
OTHERWISE CURRENT WINDOW IS SCREEN
END CASE
DISPLAY "YES" TO info
END WHILE
END MAIN
NOTE: The "RWW" menu command contains the instruction which allows you to start another instance of the application:
COMMAND "RWW" RUN "fglrun Navigation " || i+1 WITHOUT WAITING
2. Create the Navigation app form
Copy and save the following Genero form definition as a file named Navigation.per
.
# Property of Four Js*
# (c) Copyright Four Js 1995, 2015. All Rights Reserved.
# * Trademark of Four Js Development Tools Europe Ltd
# in the United States and elsewhere
#
# Four Js and its suppliers do not warrant or guarantee that these
# samples are accurate and suitable for your purposes. Their inclusion is
# purely for information purposes only.
LAYOUT
GROUP(text="Test Current Window")
GRID
{
Window name [fw ]
Is current [info ]
}
END
END
ATTRIBUTES
LABEL fw=formonly.fname;
EDIT info=formonly.info;
END
3. Compile the Navigation app
From the command line, compile the source code modules you have created (Navigation.4gl
and Navigation.per
) by typing the following commands:
$ fglcomp Navigation.4gl
$ fglform Navigation.per
Compiled files are created, Navigation.42m
and Navigation.42f
.
4. Create the Navigation app configuration file
Create an application configuration file for your application. Save the configuration file (named Navigation.xcf
) in your $(res.appdata.path)/app
directory.
<?xml version="1.0" encoding="UTF-8" ?>
<APPLICATION Parent="defaultgwc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://www.4js.com/ns/gas/3.00/cfextwa.xsd">
<EXECUTION>
<PATH>*path_to_your_directory*</PATH>
<MODULE>Navigation.42m</MODULE>
</EXECUTION>
<UA_OUTPUT>
<PUBLIC_IMAGEPATH>$(res.public.resources)</PUBLIC_IMAGEPATH>
<GBC>_default</GBC>
</UA_OUTPUT>
</APPLICATION>
5. Run the Navigation app
Request the Navigation application in your browser by entering the URL: http://localhost:6394/ua/r/Navigation
The current window at the top of the stack (w3-1) is displayed.
The current window's menu button options are: w1, w2, w3, screen, RWW, and Exit.
The Window name field displays w3 for the current window.
The Is current field displays "YES" for the current window.
The sidebar panel is updated with the Navigation tree, which has the following links to windows in the stack:
- Navigation
- Screen
- Window w1 - 1
- Window w2 - 1
- Window w3 - 1
6. Run another instance of the Navigation app
To have another instance of the Navigation application running at the same time: In the current window's Test menu panel, click RWW. The sidebar view is updated with another Navigation tree.
From the sidebar view, select the current windows in each running instance of the Navigation application. For example:
- Select Window w3 - 1
- Select Window w3 - 2
You should see that both applications have current windows. The first instance of the Navigation application you started (the parent program) continues to run without waiting for the second instance of Navigation (the child program) to finish.
Select the different windows in the Navigation panel. The result of your selection will depend on the following:
- If the selected window is the current window, the Is current field value is "YES" and the Test menu panel is displayed.
- If the selected window is not current, the Is current field value is "NO" and the Test menu panel is not displayed.