closeSolution

voidcloseSolution([solutionToLoad], [method], [argument])

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 [solutionToLoad] – Name of the solution to load
[method] – Name of the global method to call
[argument] – Argument passed to the global method

Returnsvoid

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');
//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 )

createWindow

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.
{Number} type – the type of the window. Can be one of JSWindow.DIALOG, JSWindow.MODAL_DIALOG, JSWindow.WINDOW.

// 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
// 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.WINDOW);
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

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.
{Number} type – the type of the window. Can be one of JSWindow.DIALOG, JSWindow.MODAL_DIALOG, JSWindow.WINDOW.
{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.

// "#" is divider between program args, environment vars and startdir
// 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", "#", "#", "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", "#", "#", "/home/myself/");
application.executeProgram("/home/myself/myapp", "arg1", "arg2", "arg3", "#", "MY_ENV_VAR=something", "#", "/home/myself/myapp");
// 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");

// "#" is divider between program args, environment vars and startdir
// 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.executeProgramInBackground("c:\\Users\\myself\\myapp.exe", "arg1", "arg2", "arg3");
// The same as above, but run the application in the user's home directory.
application.executeProgramInBackground("c:\\Users\\myself\\myapp.exe", "arg1", "arg2", "arg3", "#", "#", "c:\\Users\\myself\\");
// The same as above, but also set an environment variable for the called program.
application.executeProgramInBackground("c:\\Users\\myself\\myapp.exe", "arg1", "arg2", "arg3", "#", "MY_ENV_VAR=something", "#", "c:\\Users\\myself\\");
// For non-Windows systems:
application.executeProgramInBackground("/home/myself/myapp", "arg1", "arg2", "arg3");
application.executeProgramInBackground("/home/myself/myapp", "arg1", "arg2", "arg3", "#", "#", "/home/myself/");
application.executeProgramInBackground("/home/myself/myapp", "arg1", "arg2", "arg3", "#", "MY_ENV_VAR=something", "#", "/home/myself/myapp");
// Open a file with the default application associated with it. (on Windows)
application.executeProgramInBackground("rundll32.exe", "url.dll,FileProtocolHandler", "filename");
// Open a file with the default application associated with it. (on Linux)
application.executeProgramInBackground("xdg-open", "filename");
// Open a file with the default application associated with it. (on MacOS)
application.executeProgramInBackground("open", "filename");
// Open a file with a specific application (on MacOS).
application.executeProgramInBackground("open", "-a", "OpenOffice.org.app", "filename.doc");

getValueListItems

Get all values from a custom or database type value list as dataset (with columns displayValue,realValue).
NOTE: this doesn't return a value for a valuelist that depends on a database relation or is a global method valuelist.

isLastPrintPreviewPrinted

ReturnsBoolean – Boolean (true) is the last print preview did print, (false) otherwise

Sample

//attached this method to onShow on the form being shown after printpreview
//set a global called globals.showPrintPreview to 1 in the onPrintPreview method
if (globals.showPrintPreview == 1)
{
globals.showPrintPreview = 0;//clear for next time
if (application.isLastPrintPreviewPrinted())
{
plugins.dialogs.showInfoDialog('Alert', 'There is printed in printpreview', 'OK')
}
}

// log level is used to determine how/if to log in servoy_log.txt; for smart client java out and err streams are used
application.output('my very important msg',LOGGINGLEVEL.ERROR);// log level: error

overrideStyle

voidoverrideStyle(originalStyleName, newStyleName)

Overrides one style (defined in in a form) with another.

Parameters {String} originalStyleName – Name of the style to override
{String} newStyleName – Name of the new style

Returnsvoid

Sample

//This function will only have effect on forms not yet created, so solution onLoad is the best place to override'
//For example overriding the use of default/designed style anywhere in the solution from 'mystyle' to 'mystyle_mac'
application.overrideStyle('mystyle','mystyle_mace')//in this case both styles should have about the same classes

setUIProperty

Parameters {Object} name – Name of the UI property
{Object} value – New value of the UI property

ReturnsBoolean – Boolean (true) if the UI property was set with the new value

Sample

//Only use this function from the solution on open method!
//In smart client, use this to set javax.swing.UIDefaults properties.
application.setUIProperty('ToolTip.hideAccelerator', true)
//To change the comboboxes selection background color, do this:
application.setUIProperty('ComboBox.selectionBackground', new Packages.javax.swing.plaf.ColorUIResource(java.awt.Color.RED))
//In web client, use this to change the template directory.
//To change the default dir of templates/default to templates/green_skin, do this:
application.setUIProperty('templates.dir','green_skin');

setUserProperty

voidsetUserProperty(name, value)

Set a persistent user property.

Parameters {String} name – Name of the user property
{String} value – New value of the user property

showI18NDialog

Opens the i18n dialog so users can change translations. Returns the key selected by the user (not it's translation) or null if cancel is pressed. Optional parameters specify the initial selections in the dialog.

showURL

Parametersurl – URL to show
[webclientTarget] – Target frame or named dialog/window
[webclientTargetOptions/timeout] – Dialog options used when a dialog is specified / a timeout in seconds when the url should be shown
[timeout] – A timeout in seconds when the url should be shown

application.showURL('http://www.example.com');
//webclient specific additional parameters...
//2nd parameter: target frame or named dialog/window, so its possible to control in which (internal) frame or dialog the url is loaded, '_self' is current window,'_blank' is new dialog, '_top' is main window
//3rd parameter: dialog options used when a dialog is specified, example: 'height=200,width=400,status=yes,toolbar=no,menubar=no,location=no'
//3th or 4th parameter: a timeout in seconds when the url should be shown, immediantly/0 is default'