Class: Ajax

Simplicite.Ajax

new Ajax

Simplicité® application.

Parameters:
Name Type Description
approot Application root (either application name or /<context root> or absolute base URL)
gateway Gateway type to use :
  • 1 or "ui": Authenticated UI gateway (default)
  • 2 or "uipublic" : Public UI gateway
  • 3 or "ws" : Legacy webservices gateway (removed in version 4.0+)
  • 4 or "api" : API gateway
login User's login (not required for UI gateways)
password User's password (not required for UI gateways)
async Asynchronous calls by default (true if absent) ?
Source:
  • appsession.js, line 34
Example
// Using authenticated user thru UI gateway
var app = new Simplicite.Ajax("myapp");
// Using public user thru public UI gateway
var app = new Simplicite.Ajax("myapp", "uipublic");
// Using website user thru WS gateway
var app = new Simplicite.Ajax("myapp", "ws", "myuser", "mypassword");
// Using website user thru API gateway
var app = new Simplicite.Ajax("myapp", "api", "myuser", "mypassword");

Classes

BusinessObject
BusinessProcess
Grant
ObjectField

Members

appinfo

Application info data.

  • name: Application name
  • version: Application version
  • platformversion: Platform version
  • encoding: Encoding
  • server: Server vendor
  • TO BE COMPLETED...

Source:
  • appsession.js, line 662

authToken

Server side session authentication token.

Source:
  • appsession.js, line 1785

authTokenExpiryDate

Server side session authentication token expiry date

Source:
  • appsession.js, line 1791

<constant> CONTEXT_ACTION

Action context.

Source:
  • appsession.js, line 358

<constant> CONTEXT_AGENDA

Agenda context.

Source:
  • appsession.js, line 363

<constant> CONTEXT_ASSOCIATE

Association context.

Source:
  • appsession.js, line 348

<constant> CONTEXT_COPY

Copy context.

Source:
  • appsession.js, line 278

<constant> CONTEXT_CREATE

Creation context.

Source:
  • appsession.js, line 273

<constant> CONTEXT_CROSSTAB

Cross table context.

Source:
  • appsession.js, line 298

<constant> CONTEXT_DATAMAPSELECT

Data mapping selection context.

Source:
  • appsession.js, line 318

<constant> CONTEXT_DELETE

Delete context.

Source:
  • appsession.js, line 288

<constant> CONTEXT_EXPORT

Export context.

Source:
  • appsession.js, line 338

<constant> CONTEXT_GRAPH

Chart context.

Source:
  • appsession.js, line 293

<constant> CONTEXT_IMPORT

Import context.

Source:
  • appsession.js, line 343

<constant> CONTEXT_LIST

List context.

Source:
  • appsession.js, line 268

<constant> CONTEXT_NONE

No context.

Source:
  • appsession.js, line 258

<constant> CONTEXT_PANELLIST

Panel list context.

Source:
  • appsession.js, line 353

<constant> CONTEXT_PLACEMAP

Place map context.

Source:
  • appsession.js, line 368

<constant> CONTEXT_POSTVALIDATE

Post validate context.

Source:
  • appsession.js, line 328

<constant> CONTEXT_PREVALIDATE

Pre-validate context.

Source:
  • appsession.js, line 323

<constant> CONTEXT_PRINTTMPL

Publication template context.

Source:
  • appsession.js, line 303

<constant> CONTEXT_REFSELECT

Reference selection context.

Source:
  • appsession.js, line 313

Search context.

Source:
  • appsession.js, line 263

<constant> CONTEXT_STATETRANSITION

State transition context.

Source:
  • appsession.js, line 333

<constant> CONTEXT_UPDATE

Update context.

Source:
  • appsession.js, line 283

<constant> CONTEXT_UPDATEALL

Bulk update context.

Source:
  • appsession.js, line 308

<constant> DEFAULT_ROW_ID

Default row ID value (for creation).

Source:
  • appsession.js, line 252

<constant> ERRLEVEL_ERROR

Error error value

Source:
  • appsession.js, line 643

<constant> ERRLEVEL_FATAL

Fatal error value

Source:
  • appsession.js, line 638

<constant> ERRLEVEL_WARNING

Minor error value

Source:
  • appsession.js, line 648

<constant> FALSE

False value

Source:
  • appsession.js, line 632

grant

Grant data.

  • login: User login
  • firstname: User first name
  • lastname: User last name
  • responsibilities: User active responsibilites array
  • TO BE COMPLETED...

Source:
  • appsession.js, line 675

Menu data.

  • TO BE COMPLETED...

Source:
  • appsession.js, line 696

news

News array. Use news["<code>"] to get a news object), each news object is:

  • TO BE COMPLETED...

Source:
  • appsession.js, line 711

<constant> RENDERING_DEFAULT

Default rendering.

Source:
  • appsession.js, line 578

<constant> RENDERING_HORIZCHECKBOX

Rendering horizontal checkbox(es).

Source:
  • appsession.js, line 588

<constant> RENDERING_HORIZRADIOBUTTON

Rendering horizontal radio button(s).

Source:
  • appsession.js, line 598

<constant> RENDERING_SELECTBOX

Select box rendering (single or multiple select).

Source:
  • appsession.js, line 583

<constant> RENDERING_VERTCHECKBOX

Rendering vertical checkbox(es).

Source:
  • appsession.js, line 593

<constant> RENDERING_VERTRADIOBUTTON

Rendering vertical radio button(s).

Source:
  • appsession.js, line 603

<constant> SEARCH_MONO

Searchable.

Source:
  • appsession.js, line 557

<constant> SEARCH_MULTI_CHECK

Searchable using check boxes.

Source:
  • appsession.js, line 562

<constant> SEARCH_MULTI_LIST

Searchable using list box.

Source:
  • appsession.js, line 567

<constant> SEARCH_NONE

Not searchable.

Source:
  • appsession.js, line 552

<constant> SEARCH_PERIOD

Searchable using period.

Source:
  • appsession.js, line 572

sessionId

Server side session identifier.

Source:
  • appsession.js, line 1779

sysparams

System parameters array. Use sysparams["<name>"] to get a system parameter value.

Source:
  • appsession.js, line 681

texts

Texts. Use texts["<code>"] to get a text value.

Source:
  • appsession.js, line 687

<constant> TRUE

True value

Source:
  • appsession.js, line 627

<constant> TYPE_BIGDECIMAL

Big decimal type.

Source:
  • appsession.js, line 494

<constant> TYPE_BOOLEAN

Boolean type.

Source:
  • appsession.js, line 414

<constant> TYPE_COLOR

Color type.

Source:
  • appsession.js, line 479

<constant> TYPE_DATE

Date type.

Source:
  • appsession.js, line 394

<constant> TYPE_DATETIME

Date and time type.

Source:
  • appsession.js, line 399

<constant> TYPE_DOC

Document type

Source:
  • appsession.js, line 454

<constant> TYPE_EMAIL

Email type.

Source:
  • appsession.js, line 434

<constant> TYPE_ENUM

Single enumerated (list of values) type.

Source:
  • appsession.js, line 409

<constant> TYPE_ENUM_MULTI

Multiple enumerated (list of values) type.

Source:
  • appsession.js, line 444

<constant> TYPE_EXTFILE

External file reference type.

Source:
  • appsession.js, line 459

<constant> TYPE_FLOAT

Float type.

Source:
  • appsession.js, line 384

<constant> TYPE_GEOCOORDS

Geo coordinates type.

Source:
  • appsession.js, line 489

<constant> TYPE_HTML

HTML content type.

Source:
  • appsession.js, line 429

<constant> TYPE_ID

Internal ID (foreign key) type.

Source:
  • appsession.js, line 374

<constant> TYPE_IMAGE

Image type.

Source:
  • appsession.js, line 464

<constant> TYPE_INT

Integer type.

Source:
  • appsession.js, line 379

<constant> TYPE_LONG_STRING

Long string (unlimited) type.

Source:
  • appsession.js, line 439

<constant> TYPE_NOTEPAD

Notepad (incremental long text) type.

Source:
  • appsession.js, line 469

<constant> TYPE_OBJECT

Object type.

Source:
  • appsession.js, line 484

<constant> TYPE_PASSWORD

Password type.

Source:
  • appsession.js, line 419

<constant> TYPE_PHONENUM

Phone number type.

Source:
  • appsession.js, line 474

<constant> TYPE_REGEXP

Regular expression type.

Source:
  • appsession.js, line 449

<constant> TYPE_STRING

String type.

Source:
  • appsession.js, line 389

<constant> TYPE_TIME

Time type.

Source:
  • appsession.js, line 404

<constant> TYPE_URL

URL type.

Source:
  • appsession.js, line 424

<constant> UPD_ALWAYS

Updatable in lists and forms.

Source:
  • appsession.js, line 536

<constant> UPD_FORM_ONLY

Updatable in forms only.

Source:
  • appsession.js, line 541

<constant> UPD_LIST_ONLY

Updatable in lists only.

Source:
  • appsession.js, line 546

<constant> UPD_READ_ONLY

Not updatable.

Source:
  • appsession.js, line 531

<constant> VIEW_TYPE

View item types

Source:
  • appsession.js, line 608

views

View definitions

Source:
  • appsession.js, line 702

<constant> VIS_BOTH

Visible in lists and forms.

Source:
  • appsession.js, line 520

<constant> VIS_FORBIDDEN

Forbidden on UI

Source:
  • appsession.js, line 525

<constant> VIS_FORM

Visible in forms.

Source:
  • appsession.js, line 515

<constant> VIS_HIDDEN

Not visible.

Source:
  • appsession.js, line 500

<constant> VIS_LIST

Visible in lists.

Source:
  • appsession.js, line 510

<constant> VIS_NOT

Not visible (alias to VIS_HIDDEN).

Source:
  • appsession.js, line 505

Methods

base64Decode

Decode a base64 string to string

Parameters:
Name Type Description
s Base64-encoded string
Source:
  • appsession.js, line 2046
Returns:
Decoded string

base64Encode

Encode a string to base64

Parameters:
Name Type Description
s Input string
Source:
  • appsession.js, line 1974
Returns:
Base64-encoded string

base64EncodeArrayBuffer

Encode an array buffer (such as got from a local file read) to to base64

Parameters:
Name Type Description
b Array buffer
Source:
  • appsession.js, line 2032
Returns:
Base64-encoded string

clearCache

Remove objects from cache

Parameters:
Name Type Description
obj Object name or business object
Source:
  • businessobject.js, line 39

contentURL

Returns content URL.

Parameters:
Name Type Description
file Content file name
Source:
  • appsession.js, line 932

dataURL

Returns local data URL (e.g. suitable for src of img tags).

Parameters:
Name Type Description
doc Document
thumb Return document thumbnail?
Source:
  • appsession.js, line 885

dispositionResourceURL

Returns disposition resource URL.

Parameters:
Name Type Description
code Resource code
type Resource type (IMG=image (default), ICO=Icon, CSS=stylesheet, JS=Javascript, HTML=HTML)
Source:
  • appsession.js, line 942

documentURL

Returns document URL.

Parameters:
Name Type Description
object Object name or object { object, field, rowId, docId }
field Field name
rowId Object record row ID
docId Document ID (can be omitted then a lookup is done on record matching rowId)
cdisp Disposition: attachment or inline (defaults to inline)
Source:
  • appsession.js, line 899

follow

Social follow service.

Parameters:
Name Type Description
callback Callback function({followed, followers} | {author})
params parameters:
  • async Asynchronous call (use default if absent) ?
  • error Custom error handler (use default error handler if absent) ?
  • method follow|unfollow|accept|deny|search
  • param related userId or search request
  • object optional User object to use
Source:
  • appsession.js, line 1717

getAppInfo

Loads application info data.

Parameters:
Name Type Description
callback Callback function called when loading is completed (loaded application info data is passed to this function)
params Optional parameters:
  • async Asynchronous call (use default if absent) ?
  • error Custom error handler (use default error handler if absent) ?
Source:
  • appsession.js, line 1112

getBusinessObject

Get a new business object.

Parameters:
Name Type Description
obj Object name or business object
objInstName Optional instance name (default the_ajax_<object name>)
Source:
  • businessobject.js, line 21
Example
// app is a Simplicite.Ajax instance
var obj = app.getBusinessObject("MyObject");
// other instance of obj
var tmp = app.getBusinessObject(obj, "tmpObj");

getBusinessProcess

Get a new business process.

Parameters:
Name Type Description
name Business process name
Source:
  • businessprocess.js, line 15
Example
// app is a Simplicite.Ajax instance
var pcs = app.getBusinessProcess("MyProcess");

getExternalObject

Loads external object definition.

Parameters:
Name Type Description
callback Callback function called when loading is completed (loaded external object is passed to this function)
name External object name
params Optional parameters:
  • async Asynchronous call (use default if absent) ?
  • error Custom error handler (use default error handler if absent) ?
Source:
  • appsession.js, line 1571

getExternalObjectURL

External object URL.

Parameters:
Name Type Description
name Object name
params Optional parameters (object or string)
Source:
  • appsession.js, line 1594

getGrant

Loads grant data.

Parameters:
Name Type Description
callback Callback function called when loading is completed (loaded grant data is passed to this function)
params Optional parameters:
  • inlinePicture Inline picture (false if absent or undefined)
  • async Asynchronous call (use default if absent) ?
  • error Custom error handler (use default error handler if absent) ?
  • web true to load menu texts sysparams
Source:
  • appsession.js, line 1167

getIconURL

Icon URL

Parameters:
Name Type Description
name Resource icon name
Source:
  • appsession.js, line 972

getMenu

Loads menu data.

Parameters:
Name Type Description
callback Callback function called when loading is completed (loaded menu data is passed to this function)
params Optional parameters:
  • async Asynchronous call (use default if absent) ?
  • error Custom error handler (use default error handler if absent) ?
Source:
  • appsession.js, line 1263

getNews

Loads news.

Parameters:
Name Type Description
callback Callback function called when loading is completed (loaded news array is passed to this function)
params Optional parameters:
  • inlineImages Inline news images (false if absent or undefined)
  • async Asynchronous call (use default if absent) ?
  • error Custom error handler (use default error handler if absent) ?
Source:
  • appsession.js, line 1533

getResourceURL

Returns Object resource URL.

Parameters:
Name Type Description
code Resource code
type Resource type (IMG=image (default), ICO=Icon, CSS=stylesheet, JS=Javascript, HTML=HTML)
object Object name: ObjectInternal or ObjectExternal (for Disposition use dispositionResourceURL)
objid Object row ID (not the resource row ID)
Source:
  • appsession.js, line 963

getSysInfo

Loads system info data.

Parameters:
Name Type Description
callback Callback function called when loading is completed (loaded system info data is passed to this function)
params Optional parameters:
  • async Asynchronous call (use default if absent) ?
  • error Custom error handler (use default error handler if absent) ?
Source:
  • appsession.js, line 1140

getSysParam

Get system parameter value.

Parameters:
Name Type Description
name System parameter name
params Optional parameters:
  • async Asynchronous call (use default if absent) ?
  • error Custom error handler (use default error handler if absent) ?
Source:
  • appsession.js, line 1392

getSysParams

Loads system parameters.

Parameters:
Name Type Description
callback Callback function called when loading is completed (loaded system parameters array is passed to this function)
params Optional parameters:
  • async Asynchronous call (use default if absent) ?
  • error Custom error handler (use default error handler if absent) ?
Source:
  • appsession.js, line 1362

getText

Get text value.

Parameters:
Name Type Description
code Text code
plural true to get the plural value if known
Source:
  • appsession.js, line 1506

getTexts

Loads texts.

Parameters:
Name Type Description
callback Callback function called when loading is completed (loaded texts array is passed to this function)
params Optional parameters:
  • async Asynchronous call (use default if absent) ?
  • error Custom error handler (use default error handler if absent) ?
Source:
  • appsession.js, line 1454

getUserInfo

Loads basic user data (login, name, email, picture).

Parameters:
Name Type Description
callback Callback function called when loading is completed (loaded user data is passed to this function)
login User login
params Optional parameters:
  • inlinePicture Inline picture (false if absent or undefined)
  • async Asynchronous call (use default if absent) ?
  • error Custom error handler (use default error handler if absent) ?
Source:
  • appsession.js, line 1236

getView

Loads view definition.

Parameters:
Name Type Description
callback Callback function called when loading is completed (loaded view is passed to this function)
name View name
params Optional parameters:
  • home optional for home or panel instance (default true to get home object instances)
  • async Asynchronous call (use default if absent) ?
  • error Custom error handler (use default error handler if absent) ?
Source:
  • appsession.js, line 1293

imageURL

Returns image URL.

Parameters:
Name Type Description
object Object name
field Field name
rowId Object record row ID
docId Document ID
thumb Return thumbnail image
Source:
  • appsession.js, line 922

indexsearch

Search from index.

Parameters:
Name Type Description
callback Callback function with result list
request Index search request string
  • simple text with wildcards and operators
  • in:domain:xxx[:all] = to get recent objects in a specific domain 'xxx', 'all' or by default those updated by the user
  • in:docs:obj1[;obj2;obj3...] text = to search the text in joined documents of listed objects
params Optional parameters :
  • inlineDocs Inline documents (false if absent or undefined, can be a boolean or an array of document fields to inline) ?
  • inlineThumbs Inline image documents thumbnails (false if absent or undefined) ?
  • inlineObjs Inline objects fields items (false if absent or undefined, can be a boolean or an array of object fields to inline) ?
  • async Asynchronous call (use default if absent) ?
  • error Custom error handler (use default error handler if absent) ?
  • metadata: gets the search engine metadata { indexed:[{name,label},...], withDocs:[{name,label},...] }
Source:
  • appsession.js, line 1619

isFalse

Returns true if value is 0/false/no/n

Parameters:
Name Type Description
value parameter value
Source:
  • appsession.js, line 1492

isTrue

Returns true if value is 1/true/yes/y

Parameters:
Name Type Description
value parameter value
Source:
  • appsession.js, line 1479

login

Login (same as session()).

Parameters:
Name Type Description
successCallback Callback function called when login is sucessful
failureCallback Callback function called when login fails
authToken Authentication token to (re)use (in case of a persistent token)
params Optional parameters:
  • async Asynchronous call (use default if absent) ?
Source:
  • appsession.js, line 1841

logout

Logout (in case of a persistent token it is deleted)

Parameters:
Name Type Description
successCallback Callback function called when login is sucessful
failureCallback Callback function called when login fails
params Optional parameters:
  • async Asynchronous call (use default if absent) ?
Source:
  • appsession.js, line 1855

messageToJson

Convert a textual backend message to json { code, text, level, field, label, error }

  • code: message code
  • text: optional contextual details
  • level: 'I'nfo, 'W'arning, 'E'rror, 'F'atal
  • field: optional field name of message
  • label: default text to display in user language
  • error: true when level is fatal or error

Parameters:
Name Type Description
msg formatted backend message 'code:text#level#field'
Source:
  • appsession.js, line 844

module

Module services

Parameters:
Name Type Description
callback Callback
params parameters:
  • async Asynchronous call (use default if absent) ?
  • error Custom error handler (use default error handler if absent) ?
  • row_id Module Id
  • del deletion action start|status
  • confirm confirm deletion
Source:
  • appsession.js, line 1751

monitor

Monitoring service

Parameters:
Name Type Description
m monitoring service or plain JSON object to store
params optional parameters { session }
cbk optional callback for response
Source:
  • appsession.js, line 1901

onExpiredSession

Handler when session has expired on server side, by default throws HTTP 401 in console. It can be overridden to return on the logon form in a UI context.

Source:
  • appsession.js, line 81

parseDateTimeValue

Parse a date time value into a Javascript Date

Parameters:
Name Type Description
v Date time value (YYYY-MM-DD hh:mm:ss)
Source:
  • appsession.js, line 1925

parseDateValue

Parse a date value into a Javascript Date

Parameters:
Name Type Description
v Date value (YYYY-MM-DD)
Source:
  • appsession.js, line 1916

resourceURL

Returns resource URL.

Parameters:
Name Type Description
id Resource ID (e.g. taken from business object or external object resources list in metadata)
Source:
  • appsession.js, line 951

session

Session init (retrieves server side session identifier and auth token).

Parameters:
Name Type Description
successCallback Callback function called when session init is sucessful
failureCallback Callback function called when session init fails
authToken Auth token to (re)use (in case of persistent tokens)
params Optional parameters:
  • async Asynchronous call (use default if absent) ?
Source:
  • appsession.js, line 1804

setDebugHandler

Change default global debug handler.

Parameters:
Name Type Description
debugHandler Debug handler function
Source:
  • appsession.js, line 824

setDebugHandlerActive

Set default global debug handler active or inactive.

Parameters:
Name Type Description
active Active status
Source:
  • appsession.js, line 816

setErrorHandler

Change default global error handler.

Parameters:
Name Type Description
errorHandler Error handler function
Source:
  • appsession.js, line 761

setErrorHandlerActive

Set default global error handler active or inactive.

Parameters:
Name Type Description
active Active status
Source:
  • appsession.js, line 752

setInfoHandler

Change default global information handler.

Parameters:
Name Type Description
infoHandler Information handler function
Source:
  • appsession.js, line 803

setInfoHandlerActive

Set default global information handler active or inactive.

Parameters:
Name Type Description
active Active status
Source:
  • appsession.js, line 795

setPassword

Set password.

Parameters:
Name Type Description
callback Callback function called when loading is completed
password Password
params Optional parameters:
  • async Asynchronous call (use default if absent) ?
  • error Custom error handler (use default error handler if absent) ?
Source:
  • appsession.js, line 1207

setSysParam

Set a user system parameter.

Parameters:
Name Type Description
callback Callback function called when loading is completed (parameter is passed to this function)
name Parameter name
value Parameter value (if undefined parameter is unset)
save Save parameter in user parameters (if undefined parameter is not saved)
params Optional parameters :
  • async Asynchronous call (use default if absent) ?
  • error Custom error handler (use default error handler if absent) ?
Source:
  • appsession.js, line 1423

setVersionCompatibility

Set default JSON services version compatibility

Parameters:
Name Type Description
version Simplicite(R) JSON services version to be compatible with (e.g. 2.7)
Source:
  • appsession.js, line 719

setWarningHandler

Change default global warning handler.

Parameters:
Name Type Description
warningHandler Warning handler function
Source:
  • appsession.js, line 782

setWarningHandlerActive

Set default global warning handler active or inactive.

Parameters:
Name Type Description
active Active status
Source:
  • appsession.js, line 774

social

Social post service.

Parameters:
Name Type Description
callback Callback function({count, posted, page, list, follow})
post optional post to save or delete { id, userId, message, pub, object, rowId }
params Optional parameters:
  • async Asynchronous call (use default if absent) ?
  • error Custom error handler (use default error handler if absent) ?
  • counters true to get counters without posts
  • object Optional object name
  • rowId Optional row ID
  • page Optional page to search, -1=no search
  • activity true to include activity message
  • level optional level filter
  • audit to list audit message only
  • del true to delete the post (default the service upsert the post)
  • like Optional true to like, false to unlike
  • status Optional status to update
  • follow true to get follow counters
Source:
  • appsession.js, line 1672

T

Alias for getText

Source:
  • appsession.js, line 1520

toDateTimeValue

Parse a Javascript Date into a date time value

Parameters:
Name Type Description
d Javascript date
Source:
  • appsession.js, line 1964

toDateValue

Parse a Javascript Date into a date value

Parameters:
Name Type Description
d Javascript date
Source:
  • appsession.js, line 1940

toTimeValue

Parse a Javascript Date into a time value

Parameters:
Name Type Description
d Javascript date
Source:
  • appsession.js, line 1952

treeview

Treeview services

Parameters:
Name Type Description
callback Callback function called when loading is completed (loaded view is passed to this function)
name Treeview name
params Optional parameters:
  • service: metadata (default), page, getmenu, addmenu, delmenu
  • object: optional object name
  • rowid: optional object rowId
  • child: child object for page service
  • page: page number for page service
  • async Asynchronous call (use default if absent) ?
  • error Custom error handler (use default error handler if absent) ?
Source:
  • appsession.js, line 1336