ServoyApi (serverside)
(servoyApi)
Overview
The ServoyApiObject
provides server-side utility methods to facilitate interactions within the Servoy environment, primarily for NG and Titanium client components or services. These utilities are integral to the internal implementation of web objects, enabling seamless data management and dynamic UI interactions.
The API supports functionalities such as creating foundsets and view foundsets using QBSelect
for flexible data retrieval and filtering. It allows direct manipulation of forms on the server, including methods to show or hide forms dynamically, ensuring efficient updates without additional client-side round trips. Session-specific filters can be applied to foundsets, offering dynamic, user-specific data restrictions.
Additional capabilities include performing SQL queries with query builders, generating media URLs from server-side byte arrays, and creating custom JSEvent
instances for event-driven workflows. Developers can also use utility functions like deep copying of complex objects and creating empty datasets, enhancing data and object management within the platform.
Methods Summarized
Add a filter parameter that is permanent per user session to limit a specified foundset of records.
Can be used to deep copy a custom value.
Creates an empty JSDataSet
This will create a JSEvent filled with component information.
Performs a sql query with a query builder object.
This will generate a list of primary keys names for the given data source.
This will generate a url from a byte array so that the client can get the bytes from that url.
Get select query for dataSource
Hide a form directly on the server for instance when a tab will change on the client, so it won't need to do a round trip for hiding the form through the browser's component.
Show a form directly on the server for instance when a tab will change on the client, so it won't need to do a round trip for showing the form through the browser's component.
Show a form directly on the server for instance when a tab will change on the client, so it won't need to do a round trip for showing the form through the browser's component.
Methods Detailed
addFoundSetFilterParam(foundset, query, filterName)
Add a filter parameter that is permanent per user session to limit a specified foundset of records. This is similar as calling foundset.js_addFoundSetFilterParam, but the main difference is that this works also on related foundsets.
Parameters
JSFoundSet foundset The foundset to add the filter param/query to
QBSelect query The query repesenting the filter
String filterName a name given to this foundset filter
Returns: Boolean
copyObject(value)
Can be used to deep copy a custom value.
Parameters
Object value the value to be copied
Returns: Object a copy of the value object, the same as constructing the object in javascript from scratch
Sample
createEmptyDataSet()
Creates an empty JSDataSet
Returns: JSDataSet an empty JSDataSet
createJSEvent()
This will create a JSEvent filled with component information.
Returns: JSEvent the jsevent
Sample
getDataSetByQuery(query, max_returned_rows)
Performs a sql query with a query builder object. Will throw an exception if anything did go wrong when executing the query. Will use any data filter defined on table.
Parameters
QBSelect query QBSelect query.
Number max_returned_rows The maximum number of rows returned by the query.
Returns: JSDataSet The JSDataSet containing the results of the query.
Sample
getDatasourcePKs(datasource)
This will generate a list of primary keys names for the given data source.
Parameters
String datasource the data source
Returns: Array a list of primary key names
Sample
getFoundSet(query)
Parameters
QBSelect query ;
Returns: JSFoundSet
getMediaUrl(bytes)
This will generate a url from a byte array so that the client can get the bytes from that url.
Parameters
Array bytes The value where an url should be created for
Returns: String the url where the bytes can be downloaded from
Sample
getQuerySelect(dataSource)
Get select query for dataSource
Parameters
String dataSource the dataSource
Returns: QBSelect QB select for the dataSource
getViewFoundSet(name, query)
Parameters
Returns: JSFoundSet
hideForm(formName)
Hide a form directly on the server for instance when a tab will change on the client, so it won't need to do a round trip for hiding the form through the browser's component.
Parameters
Object formName the form to hide
Returns: Boolean true if the form was hidden
Sample
showForm(nameOrUUID)
Show a form directly on the server for instance when a tab will change on the client, so it won't need to do a round trip for showing the form through the browser's component.
NOTE: Make sure this isn't called with a form name that can direclty come from the client, because this call allows all forms to be shown!
Parameters
String nameOrUUID the form to show
Returns: Boolean true if the form was marked as visible
Sample
showForm(nameOrUUID, relationName)
Show a form directly on the server for instance when a tab will change on the client, so it won't need to do a round trip for showing the form through the browser's component.
NOTE: Make sure this isn't called with a form name that can direclty come from the client, because this call allows all forms to be shown!
Parameters
Returns: Boolean true if the form was marked as visible
Sample
Last updated