Application

(application)

Return Types

APPLICATION_TYPES,CLIENTDESIGN,DRAGNDROP,ELEMENT_TYPES,CSSPosition,Renderable,JSDimension,JSPoint,JSDNDEvent,JSEvent,JSRenderEvent,JSUpload,JSWindow,JSLogger,JSLogBuilder,LOGGINGLEVEL,UICONSTANTS,UUID,WEBCONSTANTS,NGCONSTANTS,

Methods Summary

TypeNameSummary

void

Adds a string of client information which gets stored on the server, and can be viewed on the Clients page of Servoy Server Administration Console..

Close all visible windows (except main application window)..

void

Closes the currently open solution and optionally opens another solution, calling a specified global method with the specified arguments..

void

Closes the currently open solution and optionally opens another solution, calling a specified global method with the specified arguments..

void

Closes the currently open solution and optionally opens another solution, calling a specified global method with the specified arguments..

void

Closes the currently open solution and optionally opens another solution, calling a specified global method with the specified arguments..

void

Closes the currently open solution and optionally opens another solution, calling a specified global method with the specified arguments..

Create a new form instance..

Creates a new window that can be used for displaying forms..

Creates a new window that can be used for displaying forms..

void

Runs at method at the given delay in milliseconds..

void

Runs at method at the given delay in milliseconds with the arguments given to the method..

Execute a program and returns output..

Execute a program and returns output..

Execute a program and returns output..

Execute a program and returns output..

void

Execute a program in the background..

void

Execute a program in the background..

void

Execute a program in the background..

void

Execute a program in the background..

void

Stop and exit application..

Get the active user count on the server (can be limited to current solution)..

This gets the currently focused active window; this can be the main application window or a modal dialog..

Get the application type..

Gets the count for all clients displaying the same additional information in the Clients page of Servoy Server Administration Console..

Sets a UI property..

Gets a string from the clipboard, null if not a string or empty..

Get the name of the localhost..

Get the clients' IP address..

Get the names of the used client licenses (as strings in array)..

Get a JSLogger instance which offers an API for logging with arguments..

Get a JSLogger instance which offers an API for logging with arguments..

Returns the name of the operating system of the client..

Get the screen height in pixels..

Get the screen width in pixels..

Returns a date object initialized on server with current date and time..

Gets the HTTP server url..

Get the uuid from this server instance (the same value that is shown on the admin page).

Returns the name of the current solution..

Get the solution release number..

Get the parameters which are provided by startup..

Returns a date object initialized in client with current date and time..

Get a new UUID object (also known as GUID) or convert the parameter (that can be string or byte array) to an UUID object..

Get a new UUID object (also known as GUID) or convert the parameter (that can be string or byte array) to an UUID object..

Get a new UUID object (also known as GUID) or convert the parameter (that can be string or byte array) to an UUID object..

Get a persistent user property..

Get all persistent user property names..

Retrieve a valuelist as array, to get real-values for display-values..

Retrieve a valuelist display-value for a real-value..

Get all values from a custom or database type value list as dataset (with columns displayValue,realValue)..

Get all the valuelist names as array..

Returns the application version..

Get the full version information of this solution and all its modules..

Get the main application window..

Get a window by window name..

Returns true if the solution is running in the developer..

void

Output something on the out stream..

void

Output something on the out stream..

void

Overrides one style with another..

Sets a UI property..

Refresh a global method valuelist by forcing it to call the global method..

Refresh a global method valuelist by forcing it to call the global method..

void

Removes all names given to the client via the admin page..

void

Removes all user properties..

Removes a string of client information which is stored on the server and previously was added using the application..

void

Removes a user property..

void

Sets a string object in the clipboard..

void

Sets a user property for this client: In NGClient this is stored in the locale storage of the browser, so it will be persisted over restarts as long as the user didn't clear the data..

void

Fill a custom type valuelist with values from array(s) or dataset..

void

Fill a custom type valuelist with values from array(s) or dataset..

void

Fill a custom type valuelist with values from array(s) or dataset..

void

Fill a custom type valuelist with values from array(s) or dataset..

void

Fill a custom type valuelist with values from array(s) or dataset..

void

Fill a custom type valuelist with values from array(s) or dataset..

void

Show the form specified by the parameter, that can be a name (is case sensitive!) or a form object..

Shows an URL in a browser..

Shows an URL in a browser..

Shows an URL in a browser..

Shows an URL in a browser..

Shows an URL in a browser..

void

Sleep for specified time (in milliseconds)..

void

Updates the UI (painting)..

void

Updates the UI (painting)..

Methods Details

addClientInfo(info)

Adds a string of client information which gets stored on the server, and can be viewed on the Clients page of Servoy Server Administration Console.

The new piece of client information is added on behalf of the running Servoy client.

This function can be called more than once, if you want to add multiple lines of client information.

NOTE: This function can also be used with the function getClientCountForInfo to count the number of clients with matching addditional client information.

Parameters String info A line of text to be added as additional client information on behalf of the running Servoy client.

Returns void

Sample

application.addClientInfo('SaaS company name');
application.addClientInfo('For any issues call +31-SA-AS');

closeAllWindows()

Close all visible windows (except main application window). Returns true if operation was successful.

Returns Boolean Boolean true if all windows were closed and false otherwise.

Sample

var win = application.createWindow("aWindowName", JSWindow.DIALOG, null);
win.setInitialBounds(10, 10, 300, 300);
win.title = "This is a window";
controller.show(win);

var win2 = application.createWindow("anotherWindowName", JSWindow.DIALOG, null);
win2.setInitialBounds(100, 100, 300, 300);
win2.title = "This is another window";
controller.show(win2);

var qdialog = plugins.dialogs.showQuestionDialog("QuestionDialog","Do you want to close the windows?","Yes","No");
if (qdialog == "Yes") {
	application.closeAllWindows();
	controller.show(null);
}

closeSolution()

Closes the currently open solution and optionally opens another solution, calling a specified global method with the specified arguments. If the user has been logged in, this function keeps the user logged in and in the newly open solution, the login is skipped and the solution goes straight to the first form. If you want to go to a different url, you need to call application.showURL(url) before calling application.closeSolution() (this is only applicable for Web Client). An alternative option is security.logout() which also does a log out for the user (for solutions that require authentication).

Returns void

Sample

//application.showURL('http://www.servoy.com', '_self');  //Web Client only
application.closeSolution();
//close current solution, open solution 'solution_name', call global method 'global_method_name' with argument 'my_argument'.
//if the user has been logged in, he will stay logged in
//application.closeSolution('solution_name','global_method_name','my_argument');
//application.closeSolution('solution_name', {a: 'my_string_argument', p1: 'param1', p2: 'param2'});//close current solution, open solution 'solution_name', call solution's onOpen with argument 'my_argument' and queryParams p1,p2
//Note: specifying a solution will not work in the Developer due to debugger dependencies
//specified solution should be of compatible type with client (normal type or client specific(Smart client only/Web client only) type )

closeSolution(solutionToLoad)

Closes the currently open solution and optionally opens another solution, calling a specified global method with the specified arguments. If the user has been logged in, this function keeps the user logged in and in the newly open solution, the login is skipped and the solution goes straight to the first form. If you want to go to a different url, you need to call application.showURL(url) before calling application.closeSolution() (this is only applicable for Web Client). An alternative option is security.logout() which also does a log out for the user (for solutions that require authentication).

Parameters String solutionToLoad Name of the solution to load

Returns void

Sample

//application.showURL('http://www.servoy.com', '_self');  //Web Client only
application.closeSolution();
//close current solution, open solution 'solution_name', call global method 'global_method_name' with argument 'my_argument'.
//if the user has been logged in, he will stay logged in
//application.closeSolution('solution_name','global_method_name','my_argument');
//application.closeSolution('solution_name', {a: 'my_string_argument', p1: 'param1', p2: 'param2'});//close current solution, open solution 'solution_name', call solution's onOpen with argument 'my_argument' and queryParams p1,p2
//Note: specifying a solution will not work in the Developer due to debugger dependencies
//specified solution should be of compatible type with client (normal type or client specific(Smart client only/Web client only) type )

closeSolution(solutionToLoad, methodArgument)

Closes the currently open solution and optionally opens another solution, calling a specified global method with the specified arguments. If the user has been logged in, this function keeps the user logged in and in the newly open solution, the login is skipped and the solution goes straight to the first form. If you want to go to a different url, you need to call application.showURL(url) before calling application.closeSolution() (this is only applicable for Web Client). An alternative option is security.logout() which also does a log out for the user (for solutions that require authentication).

Parameters String solutionToLoad Name of the solution to load Object methodArgument Argument passed to the solution onOpen

Returns void

Sample

//application.showURL('http://www.servoy.com', '_self');  //Web Client only
application.closeSolution();
//close current solution, open solution 'solution_name', call global method 'global_method_name' with argument 'my_argument'.
//if the user has been logged in, he will stay logged in
//application.closeSolution('solution_name','global_method_name','my_argument');
//application.closeSolution('solution_name', {a: 'my_string_argument', p1: 'param1', p2: 'param2'});//close current solution, open solution 'solution_name', call solution's onOpen with argument 'my_argument' and queryParams p1,p2
//Note: specifying a solution will not work in the Developer due to debugger dependencies
//specified solution should be of compatible type with client (normal type or client specific(Smart client only/Web client only) type )

closeSolution(solutionToLoad, methodName)

Closes the currently open solution and optionally opens another solution, calling a specified global method with the specified arguments. If the user has been logged in, this function keeps the user logged in and in the newly open solution, the login is skipped and the solution goes straight to the first form. If you want to go to a different url, you need to call application.showURL(url) before calling application.closeSolution() (this is only applicable for Web Client). An alternative option is security.logout() which also does a log out for the user (for solutions that require authentication).

Parameters String solutionToLoad Name of the solution to load String methodName Name of the global method to call

Returns void

Sample

//application.showURL('http://www.servoy.com', '_self');  //Web Client only
application.closeSolution();
//close current solution, open solution 'solution_name', call global method 'global_method_name' with argument 'my_argument'.
//if the user has been logged in, he will stay logged in
//application.closeSolution('solution_name','global_method_name','my_argument');
//application.closeSolution('solution_name', {a: 'my_string_argument', p1: 'param1', p2: 'param2'});//close current solution, open solution 'solution_name', call solution's onOpen with argument 'my_argument' and queryParams p1,p2
//Note: specifying a solution will not work in the Developer due to debugger dependencies
//specified solution should be of compatible type with client (normal type or client specific(Smart client only/Web client only) type )

closeSolution(solutionToLoad, methodName, methodArgument)

Closes the currently open solution and optionally opens another solution, calling a specified global method with the specified arguments. If the user has been logged in, this function keeps the user logged in and in the newly open solution, the login is skipped and the solution goes straight to the first form. If you want to go to a different url, you need to call application.showURL(url) before calling application.closeSolution() (this is only applicable for Web Client). An alternative option is security.logout() which also does a log out for the user (for solutions that require authentication).

Parameters String solutionToLoad Name of the solution to load String methodName Name of the global method to call Object methodArgument Argument passed to the global method

Returns void

Sample

//application.showURL('http://www.servoy.com', '_self');  //Web Client only
application.closeSolution();
//close current solution, open solution 'solution_name', call global method 'global_method_name' with argument 'my_argument'.
//if the user has been logged in, he will stay logged in
//application.closeSolution('solution_name','global_method_name','my_argument');
//application.closeSolution('solution_name', {a: 'my_string_argument', p1: 'param1', p2: 'param2'});//close current solution, open solution 'solution_name', call solution's onOpen with argument 'my_argument' and queryParams p1,p2
//Note: specifying a solution will not work in the Developer due to debugger dependencies
//specified solution should be of compatible type with client (normal type or client specific(Smart client only/Web client only) type )

createNewFormInstance(designFormName, newInstanceScriptName)

Create a new form instance.

Parameters String designFormName Name of the design form String newInstanceScriptName Name of the new form instance

Returns Boolean Boolean (true) if the instance was created succesfully, (false) otherwise

Sample

var ok = application.createNewFormInstance('orders','orders_view');
if (ok)
{
	var dialog = application.createWindow("myDialog", JSWindow.DIALOG);
 dialog.show('orders_view')
	//forms['orders_view'].controller.show()
	//forms.xyz.elements.myTabPanel.addTab(forms['orders_view'])
	//forms['orders_view'].elements.mylabel.setLocation(10,20)
}

createWindow(windowName, type)

Creates a new window that can be used for displaying forms. Initially the window is not visible. If there is already a window with the given name, it will be closed and destroyed prior to creating the new window. Use the form controller show() and showRecords() methods in order to show a form in this window.

Parameters String windowName the name of the window. Should not be null. Number type the type of the window. Can be one of JSWindow.DIALOG, JSWindow.MODAL_DIALOG, JSWindow.WINDOW. (WINDOW does not work for NGClient)

Returns JSWindow the newly created window.

Sample

// create and show a window, with specified title, initial location and size
// type of the window can be one of JSWindow.DIALOG, JSWindow.MODAL_DIALOG, JSWindow.WINDOW (WINDOW does not work for NGClient)
// If parentWindow is not specified, the current window will be used as parent; parentWindow parameter is only used by dialogs
var win = application.createWindow("windowName", JSWindow.DIALOG);
win.setInitialBounds(10, 10, 300, 300);
win.title = "This is a window";
controller.show(win);
// create and show a non-modal dialog with default initial bounds/title
var nmd = application.createWindow("nonModalDialogName", JSWindow.DIALOG);
controller.showRecords(15, nmd); // 15 is a single-number pk in this case

createWindow(windowName, type, parentWindow)

Creates a new window that can be used for displaying forms. Initially the window is not visible. If there is already a window with the given name, it will be closed and destroyed prior to creating the new window. Use the form controller show() and showRecords() methods in order to show a form in this window.

Parameters String windowName the name of the window. Should not be null. Number type the type of the window. Can be one of JSWindow.DIALOG, JSWindow.MODAL_DIALOG, JSWindow.WINDOW (WINDOW doesn't work in NGClient). JSWindow parentWindow the parent JSWindow object. If it is not specified, the current window will be used as parent. This parameter is only used by dialogs.

Returns JSWindow the newly created window.

Sample

// create and show a window, with specified title, initial location and size (WINDOW does not work for NGClient)
var win = application.createWindow("windowName", JSWindow.DIALOG);
win.setInitialBounds(10, 10, 300, 300);
win.title = "This is a window";
controller.show(win);
// create and show a non-modal dialog with default initial bounds/title
var nmd = application.createWindow("nonModalDialogName", JSWindow.DIALOG);
controller.showRecords(15, nmd); // 15 is a single-number pk in this case

executeLater(function, delay)

Runs at method at the given delay in milliseconds.

This is like a simple scheduler to quickly run something after a bit of delay

Parameters Function function The function to call Number delay The millis that has to elapse before the function is called.

Returns void

Sample

executeLater(function, delay, arguments)

Runs at method at the given delay in milliseconds with the arguments given to the method.

This is like a simple scheduler to quickly run something after a bit of delay

Parameters Function function The function to call Number delay The millis that has to elapse before the function is called. Array arguments The arguments that are given to the function when called.

Returns void

Sample

executeProgram(program)

Execute a program and returns output. Specify the cmd as you would do in a console.

Parameters String program (fullpath) of the program to execute

Returns String The output generated by the program execution.

Sample

// For Windows systems:
// Runs a binary located in the user's home directory. The application will run in the current working
// directory, which in general is the one where Servoy was started from.
application.executeProgram("c:\\Users\\myself\\myapp.exe", ["arg1", "arg2", "arg3"]);
// The same as above, but run the application in the user's home directory.
application.executeProgram("c:\\Users\\myself\\myapp.exe", ["arg1", "arg2", "arg3"], null, "c:\\Users\\myself\\");
// The same as above, but also set an environment variable for the called program.
application.executeProgram("c:\\Users\\myself\\myapp.exe", ["arg1", "arg2", "arg3"], ["MY_ENV_VAR=something"], "c:\\Users\\myself\\");
// For non-Windows systems:
application.executeProgram("/home/myself/myapp", ["arg1", "arg2", "arg3"]);
application.executeProgram("/home/myself/myapp", ["arg1", "arg2", "arg3"], null, "/home/myself/");
application.executeProgram("/home/myself/myapp", ["arg1", "arg2", "arg3"], ["MY_ENV_VAR=something"], "/home/myself/");
// Open a file with the default application associated with it. (on Windows)
application.executeProgram("rundll32.exe", ["url.dll,FileProtocolHandler", "filename"]);
// Open a file with the default application associated with it. (on Linux)
application.executeProgram("xdg-open", ["filename"]);
// Open a file with the default application associated with it. (on MacOS)
application.executeProgram("open", ["filename"]);
// Open a file with a specific application (on MacOS).
application.executeProgram("open", ["-a", "OpenOffice.org.app", "filename.doc"]);

executeProgram(program, params)

Execute a program and returns output. Specify the cmd as you would do in a console.

Parameters String program (fullpath) of the program to execute Array params an array of strings as program arguments

Returns String The output generated by the program execution.

Sample

// For Windows systems:
// Runs a binary located in the user's home directory. The application will run in the current working
// directory, which in general is the one where Servoy was started from.
application.executeProgram("c:\\Users\\myself\\myapp.exe", ["arg1", "arg2", "arg3"]);
// The same as above, but run the application in the user's home directory.
application.executeProgram("c:\\Users\\myself\\myapp.exe", ["arg1", "arg2", "arg3"], null, "c:\\Users\\myself\\");
// The same as above, but also set an environment variable for the called program.
application.executeProgram("c:\\Users\\myself\\myapp.exe", ["arg1", "arg2", "arg3"], ["MY_ENV_VAR=something"], "c:\\Users\\myself\\");
// For non-Windows systems:
application.executeProgram("/home/myself/myapp", ["arg1", "arg2", "arg3"]);
application.executeProgram("/home/myself/myapp", ["arg1", "arg2", "arg3"], null, "/home/myself/");
application.executeProgram("/home/myself/myapp", ["arg1", "arg2", "arg3"], ["MY_ENV_VAR=something"], "/home/myself/");
// Open a file with the default application associated with it. (on Windows)
application.executeProgram("rundll32.exe", ["url.dll,FileProtocolHandler", "filename"]);
// Open a file with the default application associated with it. (on Linux)
application.executeProgram("xdg-open", ["filename"]);
// Open a file with the default application associated with it. (on MacOS)
application.executeProgram("open", ["filename"]);
// Open a file with a specific application (on MacOS).
application.executeProgram("open", ["-a", "OpenOffice.org.app", "filename.doc"]);

executeProgram(program, params, environmentVars)

Execute a program and returns output. Specify the cmd as you would do in a console.

Parameters String program (fullpath) of the program to execute Array params an array of strings as program arguments Array environmentVars array of strings, each element of which has environment variable settings in the format name=value, or null if the subprocess should inherit the environment of the current process.

Returns String The output generated by the program execution.

Sample

// For Windows systems:
// Runs a binary located in the user's home directory. The application will run in the current working
// directory, which in general is the one where Servoy was started from.
application.executeProgram("c:\\Users\\myself\\myapp.exe", ["arg1", "arg2", "arg3"]);
// The same as above, but run the application in the user's home directory.
application.executeProgram("c:\\Users\\myself\\myapp.exe", ["arg1", "arg2", "arg3"], null, "c:\\Users\\myself\\");
// The same as above, but also set an environment variable for the called program.
application.executeProgram("c:\\Users\\myself\\myapp.exe", ["arg1", "arg2", "arg3"], ["MY_ENV_VAR=something"], "c:\\Users\\myself\\");
// For non-Windows systems:
application.executeProgram("/home/myself/myapp", ["arg1", "arg2", "arg3"]);
application.executeProgram("/home/myself/myapp", ["arg1", "arg2", "arg3"], null, "/home/myself/");
application.executeProgram("/home/myself/myapp", ["arg1", "arg2", "arg3"], ["MY_ENV_VAR=something"], "/home/myself/");
// Open a file with the default application associated with it. (on Windows)
application.executeProgram("rundll32.exe", ["url.dll,FileProtocolHandler", "filename"]);
// Open a file with the default application associated with it. (on Linux)
application.executeProgram("xdg-open", ["filename"]);
// Open a file with the default application associated with it. (on MacOS)
application.executeProgram("open", ["filename"]);
// Open a file with a specific application (on MacOS).
application.executeProgram("open", ["-a", "OpenOffice.org.app", "filename.doc"]);