Child pages
  • JSServer

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin
Hidden
DO NOT EDIT THE CONTENT OF THIS PAGE DIRECTLY, UNLESS YOU KNOW WHAT YOU'RE DOING.
		THE STRUCTURE OF THE CONTENT IS VITAL IN BEING ABLE TO EXTRACT CHANGES FROM THE PAGE AND MERGE THEM BACK INTO SERVOY SOURCE


HTML Table
classservoy sSummary
Colgroup Tag
Column
padding0px
width80px

Column

Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Method Summary
Table Body (tbody)
Table Row (tr)
Table Cell (td)
JSTableObject
Table Cell (td)
#createNewTable(tableName)
Creates in this server a new table with the specified name.
Table Body (tbody)
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)
#dropTable(tableName)
Drops the table with the specified name from this server.
Table Body (tbody)
Table Row (tr)
Table Cell (td)
JSTableObject
Table Cell (td)
#getTable(tableName)
Returns a JSTable instance corresponding to the table with the specified name from this server.
Table Body (tbody)
Table Row (tr)
Table Cell (td)
String[]
Table Cell (td)
#getTableNames()
Returns an array with the names of all tables in this server.
Table Body (tbody)
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)
#isValid()
Get valid state for the server.
Table Body (tbody)
Table Row (tr)
Table Cell (td)
void
Table Cell (td)
#reloadDataModel()
Reloads the datamodel from the database, if changed externally or via rawSQL plugin.
Table Body (tbody)
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)
#synchronizeWithDB(table)
Synchronizes a JSTable instance with the database.

HTML Table
idfunction
classservoy sDetail
Colgroup Tag
Column
padding0px
width100%

Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan1
Method Details
Table Body (tbody)
idcreateNewTable
classnode
Table Row (tr)
idname
Table Cell (td)
createNewTable
Table Row (tr)
idsig
Table Cell (td)
Span
stylefloat: left; margin-right: 5px;
JSTableObject
Span
stylefloat: left; font-weight: bold;
idiets
createNewTable
Span
stylefloat: left;
idiets
(tableName)
Table Row (tr)
iddes
Table Cell (td)
Creates in this server a new table with the specified name.
Table Row (tr)
idprs
Table Cell (td)
Parameters
{String} tableName – The name of the table to create.
Table Row (tr)
idret
Table Cell (td)
Returns
JSTableObject – JSTableObject created table.
Table Row (tr)
idsam
Table Cell (td)
Sample
Div
classsIndent
Code Block
languagejavascript
var server = plugins.maintenance.getServer("example_data");
if (server)
{
	var table = server.createNewTable("new_table");
	if (table) {
		table.createNewColumn("new_table_id", JSColumn.INTEGER, 0, false, true);
		if (server.synchronizeWithDB(table))
			application.output("New table created in the database.");
		else
			application.output("New table not created in database.");
	}
	else application.output("New table not created at all.");
}
Table Row (tr)
classlastDetailRow
Table Cell (td)

Table Body (tbody)
iddropTable
classnode
Table Row (tr)
idname
Table Cell (td)
dropTable
Table Row (tr)
idsig
Table Cell (td)
Span
stylefloat: left; margin-right: 5px;
Boolean
Span
stylefloat: left; font-weight: bold;
idiets
dropTable
Span
stylefloat: left;
idiets
(tableName)
Table Row (tr)
iddes
Table Cell (td)
Drops the table with the specified name from this server.
Table Row (tr)
idprs
Table Cell (td)
Parameters
{String} tableName – The name of the table to drop.
Table Row (tr)
idret
Table Cell (td)
Returns
Boolean – boolean success.
Table Row (tr)
idsam
Table Cell (td)
Sample
Div
classsIndent
Code Block
languagejavascript
var server = plugins.maintenance.getServer("example_data");
if (server) {
	var result = server.dropTable("new_table");
	if (result)
		application.output("Table dropped.");
	else
	application.output("Table not dropped.");
}
Table Row (tr)
classlastDetailRow
Table Cell (td)

Table Body (tbody)
idgetTable
classnode
Table Row (tr)
idname
Table Cell (td)
getTable
Table Row (tr)
idsig
Table Cell (td)
Span
stylefloat: left; margin-right: 5px;
JSTableObject
Span
stylefloat: left; font-weight: bold;
idiets
getTable
Span
stylefloat: left;
idiets
(tableName)
Table Row (tr)
iddes
Table Cell (td)
Returns a JSTable instance corresponding to the table with the specified name from this server.
Table Row (tr)
idprs
Table Cell (td)
Parameters
{String} tableName – The name of the table to retrieve.
Table Row (tr)
idret
Table Cell (td)
Returns
JSTableObject – JSTableObject table.
Table Row (tr)
idsam
Table Cell (td)
Sample
Div
classsIndent
Code Block
languagejavascript
var server = plugins.maintenance.getServer("example_data");
if (server) {
	var table = server.getTable("employees");
	if (table) {
		var colNames = table.getColumnNames()
		application.output("Table has " + colNames.length + " columns.");
		for (var i=0; i<colNames.length; i++)
			application.output("Column " + i + ": " + colNames[i]);
	}
}
Table Row (tr)
classlastDetailRow
Table Cell (td)

Table Body (tbody)
idgetTableNames
classnode
Table Row (tr)
idname
Table Cell (td)
getTableNames
Table Row (tr)
idsig
Table Cell (td)
Span
stylefloat: left; margin-right: 5px;
String[]
Span
stylefloat: left; font-weight: bold;
idiets
getTableNames
Span
stylefloat: left;
idiets
()
Table Row (tr)
iddes
Table Cell (td)
Returns an array with the names of all tables in this server.
Table Row (tr)
idret
Table Cell (td)
Returns
String[] – Array of String table names.
Table Row (tr)
idsam
Table Cell (td)
Sample
Div
classsIndent
Code Block
languagejavascript
var server = plugins.maintenance.getServer("example_data");
if (server) {
	var tableNames = server.getTableNames();
	application.output("There are " + tableNames.length + " tables.");
	for (var i=0; i<tableNames.length; i++)
		application.output("Table " + i + ": " + tableNames[i]);
	}
else {
	plugins.dialogs.showInfoDialog("Attention","Server 'example_data' cannot be found.","OK");
}
Table Row (tr)
classlastDetailRow
Table Cell (td)

Table Body (tbody)
idisValid
classnode
Table Row (tr)
idname
Table Cell (td)
isValid
Table Row (tr)
idsig
Table Cell (td)
Span
stylefloat: left; margin-right: 5px;
Boolean
Span
stylefloat: left; font-weight: bold;
idiets
isValid
Span
stylefloat: left;
idiets
()
Table Row (tr)
iddes
Table Cell (td)
Get valid state for the server.
Table Row (tr)
idret
Table Cell (td)
Returns
Boolean – boolean valid state.
Table Row (tr)
idsam
Table Cell (td)
Sample
Div
classsIndent
Code Block
languagejavascript
var server = plugins.maintenance.getServer("example_data");
if (!server.isValid()) {
			application.output("Server not valid!");
}
Table Row (tr)
classlastDetailRow
Table Cell (td)

Table Body (tbody)
idreloadDataModel
classnode
Table Row (tr)
idname
Table Cell (td)
reloadDataModel
Table Row (tr)
idsig
Table Cell (td)
Span
stylefloat: left; margin-right: 5px;
void
Span
stylefloat: left; font-weight: bold;
idiets
reloadDataModel
Span
stylefloat: left;
idiets
()
Table Row (tr)
iddes
Table Cell (td)

Reloads the datamodel from the database, if changed externally or via rawSQL plugin.

This call is not needed after a call to synchronizeWithDB().

Table Row (tr)
idret
Table Cell (td)
Returns
void
Table Row (tr)
idsam
Table Cell (td)
Sample
Div
classsIndent
Code Block
languagejavascript
var server = plugins.maintenance.getServer("example_data");
var result = plugins.rawSQL.executeSQL("example_data", null, 'CREATE TABLE raw_table (raw_table_id INTEGER)');
if (result) {
	application.output("Table created through rawSQL plugin.");
	if (server) {
		server.reloadDataModel();
		// All existing JSTableObject/JSColumn object references are invalid now! Use getTable to get new ones.
		var table = server.getTable("raw_table");
		if (table) {
			var colNames = table.getColumnNames()
			application.output("Table has " + colNames.length + " columns.");
			for (var i=0; i<colNames.length; i++)
				application.output("Column " + i + ": " + colNames[i]);
		}
	}
}
else {
	application.output("Raw table creation failed: " + plugins.rawSQL.getException());
}
Table Row (tr)
classlastDetailRow
Table Cell (td)

Table Body (tbody)
idsynchronizeWithDB
classnode
Table Row (tr)
idname
Table Cell (td)
synchronizeWithDB
Table Row (tr)
idsig
Table Cell (td)
Span
stylefloat: left; margin-right: 5px;
Boolean
Span
stylefloat: left; font-weight: bold;
idiets
synchronizeWithDB
Span
stylefloat: left;
idiets
(table)
Table Row (tr)
iddes
Table Cell (td)
Synchronizes a JSTable instance with the database. If columns were added to or removed from the JSTable instance, all these changes will now be persisted to the database.
Table Row (tr)
idprs
Table Cell (td)
Parameters
{JSTableObject} table – A JSTableObject instance that should be synchronized.
Table Row (tr)
idret
Table Cell (td)
Returns
Boolean – boolean success.
Table Row (tr)
idsam
Table Cell (td)
Sample
Div
classsIndent
Code Block
languagejavascript
var server = plugins.maintenance.getServer("example_data");
if (server)
{
	var table = server.createNewTable("new_table");
	if (table) {
		table.createNewColumn("new_table_id", JSColumn.INTEGER, 0, false, true);
		if (server.synchronizeWithDB(table))
			application.output("New table created in the database.");
		else
			application.output("New table not created in database.");
	}
	else application.output("New table not created at all.");
}
Table Row (tr)
classlastDetailRow
Table Cell (td)