Child pages
  • JSServer

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Divcache
Div
iddescription
HTML Table
id
classservoy sSummary
Colgroup Tag
Col
width80px
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Method Summary
Table Row (tr)
Table Cell (td)
JSTableObject
Table Cell (td)createNewTable(tableName)
styleindexdisplay:none

DO NOT EDIT THE CONTENT OF THIS PAGE DIRECTLY (EXCEPT INSIDE THE DIV BELOW WITH ID=DESCRIPTION), UNLESS YOU KNOW WHAT YOU'RE DOING.
THE STRUCTURE OF THE CONTENT IS VITAL IN BEING ABLE TO AUTO UPDATE THE CONTENT THROUGH THE DOC GENERATOR.

true
refresh100d
showRefreshtrue
iddoc
titleRefresh page
showDatetrue
retryEnable
id

servoy sReturnTypes2100%height: 30px;2Supported ClientssWordListSmartClientsWordListWebClientsWordListNGClient

servoy sSummary12%30%58%height: 30px;3Methods SummaryCreates in this server a new table with the specified name. Table Row (tr)

Table Cell (td)
Boolean
Table Cell (td)dropTable(tableName)
Table Cell (td)getTable(tableName)
Drops the table with the specified name from this server. Table Row (tr)
Table Cell (td)
JSTableObject
Returns a JSTable instance corresponding to the table with the specified name from this server. Table Row (tr)
Table Cell (td)
String[]
Table Cell (td)getTableNames()
Returns an array with the names of all tables in this server. Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)isValid()
Get valid state for the server. Table Row (tr) Table Cell (td) Table Cell (td)reloadDataModel()
voidReloads the datamodel from the database, if changed externally or via rawSQL plugin. Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)synchronizeWithDB(table)
Synchronizes a JSTable instance with the database.

HTML Table

functionclass Colgroup Tag Colcolspanservoy sDetail2width100%

Col
Table Head (thead) Table Row (tr)style
Table Row (tr)
idname
Table Cell (td)

createNewTable

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
JSTableObject
Span
stylefont-weight: bold;
createNewTable
Spanheight:30px;
Table Head (th)
colspan2
Method Details
Table Body (tbody)
idcreateNewTable-String
id2Methods DetailscreateNewTablename

createNewTable(tableName)

Table Row (tr)des Table Cell (td) DivclasssIndent
Creates in this server a new table with the specified name.
tr
idprs

Table Cell (td)

Parameters

Divclass

sIndent{String} tableName - The name of the table to create. Table Row (tr)idret

Table Cell (td)class

Returns

DivsIndent JSTableObject - JSTableObject id created table.clients

Table Row (tr)

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Table Cell (td)

Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
iddropTable-String
Table Row (tr)
idname
Table Cell (td)

dropTable

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
dropTable
Span
(tableName)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Drops the table with the specified name from this server.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{String} tableName -

Sample

Div
classsIndent
Code Block
languagejavascript
var server = plugins.maintenance.getServer("example_data");
if (server)
{
	var table = server.createNewTable("new_table");
	if (table) {
		var pk = table.createNewColumn("new_table_id", JSColumn.INTEGER, 0);
		pk.rowIdentifierType = JSColumn.PK_COLUMN;
		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.");
}
sIdentjavascriptlastDetailRowdropTablename

dropTable(tableName)

dessIndent
Drops the table with the specified name from this server.
prs

Parameters

sIndenttableNameThe name of the table to drop.
Table Row (tr)idret

Table Cell (td)

Returns

DivclassBoolean - sIndentid boolean success.clients

Table Row (tr)

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Table Cell (td)

Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idgetTable-String
Table Row (tr)
idname
Table Cell (td)

getTable

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
JSTableObject
Span
stylefont-weight: bold;
getTable
Span
(tableName)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Returns a JSTable instance corresponding to the table with the specified name from this server.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{String} tableName -

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.");
}
sIdentjavascriptlastDetailRowgetTablename

getTable(tableName)

dessIndent
Returns a JSTable instance corresponding to the table with the specified name from this server.
prs

Parameters

sIndenttableNameThe name of the table to retrieve.
Table Row (tr)idret

Table Cell (td)

Returns

DivclassJSTableObject - sIndent Div
classsIndent
String[] - JSTableObject table.clients

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
Table Row (tr)
idname
Table Cell (td)

getTableNames

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
String[]
Span
stylefont-weight: bold;
getTableNames
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Returns an array with the names of all tables in this server.
Table Row (tr)
idret
Table Cell (td)

Returns

id

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
getTableNamesname

getTableNames()

dessIndent
Returns an array with the names of all tables in this server.
ret

Returns

sIndent Array of String table names.
clients

Table Row (tr)

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Table Cell (td)

Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idisValid
Table Row (tr)
idname
Table Cell (td)

isValid

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
isValid
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Get valid state for the server.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
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
Table Row (tr)
idname
Table Cell (td)

reloadDataModel

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
void
Span
stylefont-weight: bold;
reloadDataModel
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent

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

Div
classsIndent
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-JSTableObject
Table Row (tr)
idname
Table Cell (td)

synchronizeWithDB

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
synchronizeWithDB
Span
(table)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
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

Div
classsIndent
{JSTableObject} table -

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");
}
idsIdentjavascriptlastDetailRowisValidname

isValid()

dessIndent
Get valid state for the server.
ret

Returns

sIndent boolean valid state.
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
reloadDataModelname

reloadDataModel()

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

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

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
synchronizeWithDBname

synchronizeWithDB(table)

dessIndent
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.
prs

Parameters

sIndenttableA JSTableObject instance that should be synchronized.
Table Row (tr)ret

Table Cell (td)class

Returns

DivBoolean - sIndentid boolean success.clients

Table Row (tr)

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Table Cell (td) Table Row (tr)

classlastDetailRow
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) {
		var pk = table.createNewColumn("new_table_id", JSColumn.INTEGER, 0);
		pk.rowIdentifierType = JSColumn.PK_COLUMN;
		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.");
}
sIdentjavascriptlastDetailRow