|
It can be useful to display messages periodically while running a component.
This is a specially helpful when using loops to ensure that the loops are not endless loop, and/or are
processing properly.
One way to display messages while running a
component is by creating a Custom Script. Within the Custom Script create a
custom display function. Our custom script function will be called 'display'.
It displays a message to the console for a few seconds. (We will write the
script later in this article.) First we need to create two Project Variables. The first project variable called
Display_Messages is used to turn the display message feature on/off. The second
project variable called
Display_Time is used to control the length of time to display the message.
If a service or component is deployed to an application server with the 'Display
Message' option enabled, the message will appear on the server console. Unlike
the ECMAScript alert statement, however, no intervention is required to continue
processing (as the message is displayed then destroyed after a set about of time
as determined by Display_Time).
The 'display' function takes two parameters: The first parameter is a String
that contains the
text to display. The second parameter is an integer containing the amount of time in seconds the user
wants the text to display. Below is the code for the 'display' function, and an
example of its usage. The code can be cut and pasted into an existing 'Custom
Script'. Be sure to mark the function as public be saving it.
//////////////////////////////////////////////////////////////////////////////////////////
// Display Function:
//
//
Displays a message to the console for a few seconds (Java Frame)
//
//
Parameters: asValue : a String
which contains the text to display
//
//
aiTime : an
integer containing the time to display in seconds
//////////////////////////////////////////////////////////////////////////////////////////
function
display (asValue, aiTime)
{
var myTime
if ((aiTime * 150000)>
150000)
{
myTime = aiTime * 150000
}
else
{
myTime = 150000
}
Frame = java.awt.Frame;
dlg = new Frame(asValue);
dlg.setBounds(100, 200, 500, 0);
dlg.show();
// Dummy loop to hold message on
screen for a short time
for(i=0;i<myTime;++i)
{
}
dlg.dispose();
return asValue;
}
Usage:
From within any action model, select 'add new action' / 'function', and
in the dialog simply call the function with its parameters:
Example:
The function call could combine
static data with XPath like this:
CALL display("Processing
contract #:" +
Output.Xpath("details/ctrct_no"),PROJECT.Xpath("USERCONFIG/Display_Time").toNumber())
|