Customize the UI for the GWC / Front End Call Framework |
Front end calls are functions executed locally on the client workstation. You can call a custom JavaScript™ function. The DVM waits for a response from the front end function.
To make a front end function call:
ui.Interface.frontCall( module, function, parameter-list, returning-list )
CALL ui.interface.frontcall("myfcts", "dosmtg", ["First","Second"], [s]);
In this example, the function called is dosmtg which takes two parameters, First and Second. dosmtg function returns a s value. It is a function of a custom module myfcts. Once the call is initiated, the DVM waits for the response from the JavaScript function until the ping timeout occurs.
Front end calls are client dependent. For the standard module, supported functions are feinfo and launchurl. Other front end functions returns an error code or "Not Implemented".
Web client specific front end functions are getvar and setvar of the session module.
The corresponding front end function should be declared at client side. For each snippet set, JavaScript objects are exposed to ease the custom front end functions integration.
To add your own front end function:
Create a new JavaScript file and add a reference to this file in the main template file (default main.xhtml).
<script type="application/x-javascript" src="{resourceuri('myscript.js', 'SetHtml5')}"/>
In $FGLASDIR/tpl/SetHtml5/main.xhtml add a reference to your custom JavaScript file named myscript.js. resourceuri retrieves the URL to myscripts using the PictureId "SetHtml5". This means myscript.js is saved in $FGLASDIR/tpl/SetHtml5. See $FGLASDIR/etc/as.xcf for more details.
Snippet set | JavaScript object |
---|---|
SetHtml5 | Add your front end function to the
gwc.frontCallModuleList object, in your custom javascript file, as shown in frontCallModuleList example. Note: The gwc.frontCallModuleList declaration can be
found at $FGLASDIR/tpl/SetHtml5/csf.js.
|
gwc.frontCallModuleList.myfcts = { dosmtg: function(param1,param2) { alert("param1: " + param1 + "\nparam2: " + param2); return window.prompt("Enter something"); } };
According to the Genero BDL example , there is a front end call to function "dosmtg" of module "myfcts".
Extend the frontCallModuleList object with the module name "myfcts" and add your "dosmtg" function definition.
Information on Front End call are available through the Template Paths - Application hierarchy.
Excerpt from $FGLASDIR/tpl/SetHtml5/main.xhtml:
<div gwc:condition='application/frontcall/pending && !application/state/ended' data-g-function='{frontcall/functionName}' data-g-id='frontcall' data-g-module='{frontcall/moduleName}' data-g-return-count='{frontcall/returnCount}' > <div gwc:repeat='p frontcall/parameters' data-g-value='{p}' /> </div>
This displays information about the front end function being processed.