Cubic Compass Software

- Support Wiki

Edit

Overview

The 'xos' Javascript API provides client access to the i-Dialogue database for use in AJAX web applications.

Edit

Example

<script>
xos.query("SELECT Id, SolutionName FROM Solution WHERE SolutionName CONTAINS 'test' OR SolutionNote CONTAINS 'test'", options, functionName_callback);
</script>

Edit

Supported Methods

Edit

Query methods

  • query(string XOSQL Query, xosOptions, callBackFunction)
  • getObject(objectID, callBackFunction)

Edit

XosOptions

A xosOptions object is constructed and the following options are passed to the query method:

useCache: The query will store the 'from' object collections (not results) in memory for up to one hour. Can provide 10x performance gain over base Query method when using complex queries.

Edit

Examples

<script>
xosOptions = new Object();
xosOptions.useCache = true;
xos.query("SELECT Id, SolutionName FROM Solution WHERE SolutionName CONTAINS 'test' OR SolutionNote CONTAINS 'test'", xosOptions, function_Callback);
</script>

A null value may be passed as the xosOptions argument.
<script>
xos.query("SELECT property FROM object", null, functionName_callback);
</script>

Edit

Search Methods

  • searchPages(string keywords, callback function)
  • searchDocuments(string repositoryName, string keywords, bool searchFullText, bool searchMetaTags, callback function)
  • getAllDocumentMetaTags(string repositoryName)

Edit

Social Methods

  • addRating(string objectID, int rating, callBack)
  • addVote(string objectID, int vote, callBack)
  • addComment(string objectID, string comment, callBack)
  • addTag(string objectID, string tag, callBack)

Edit

Cuboid Execution Methods

  • exec(string cuboidName, string arguments, callback function)

Arguments are a comma separated list and are accessible in cuboids through the string array 'args'.

Client-side Javascript Example
<script>
xos.exec('Resend Password', emailAddress, functionName_callback);
</script>

Call Cuboid Example
emailAddress = args[0]

//Lookup user by email and resend password here

Edit

AJAX Support

It's recommended to use the methods that support callback functions whenever possible. These methods execute the query or search, then immediately return control flow to the client javascript while the query gets processed asynchronously. When the query or search is completed, the callback function is passed a response object that contains error information (if any) and a JSON formatted object array.

For Query methods, the JSON object type is defined by the FROM keyword and the object properties are defined the SELECT keyword. For example, "SELECT Name, Author FROM PressRelease" returns an array of JSON objects of type "PressRelease" with properties for "Name" and "Author".

The searchPages and searchDocuments methods return "Page" and "Document" JSON objects respectively.

Page Properties: oid, url, title, abstract, keywords, viewCount, label
Document Properties: oid, createdDate, lastModifiedDate, url, title, abstract, author, publisher, viewCount, iconUrl

Edit

AJAX / JSON Example

<script>
function doSearch(keywords){
	var query = "SELECT Id, SolutionName FROM Solution WHERE SolutionName CONTAINS '" + keywords + "'";
	xos.query(query, doSearch_Callback);
}

function doSearch_Callback(response){
	if (response.error != null){
		alert(response.error);
		return;
	}
	
	var data;
	eval ("data = " + response.value);
	
	var html = new Sys.StringBuilder();
	html.append("<table>");
	for(var index=0; index < data.TableName.length; index++)
		html.append("<tr><td>" + data.TableName.PropertyName + "</td></tr>");
	
	html.append("</table>");
	
	$("#divElementID").append(html.toString());
}
</script>

Edit

Security

The xos interface enforces access policies for executing AJAX methods on the server. Allowed queries and calls to cuboid controllers are defined in the page source. Admin users and users with Edit permissions on the current page may execute any query.

Use of any xos query requires embedding <xos> XML query prototypes in the Dialogue Script that define allowed query execution patterns.

Edit

Example XOS execution policy syntax

<script>
	/*
	<xos>
		<supportedQueries>
			<query>select from Case where oid</query>
			<getObject>Solution</getObject>
		</supportedQueries>
		<supportedCuboids>
			<cuboid>case.GetCase</cuboid>
		</supportedCuboids>
	</xos>
	*/
</script>

ScrewTurn Wiki version 2.0.35. Some of the icons created by FamFamFam.