JSCP library reference
Jscp.Updater

Jscp.Updater is the most often used class. Usually you write "new Jscp.Updater()" to create an object instance, call one of its updateXXXX() methods to update UI pages in web app, with option parameter you could get control of some details.

Methods
update(container, pageUrl, dataUrl, options)

Get remote page template and remote data, render them, display rendered result in container.

Members available in options parameter:

  • callContext - Self defined data that would be passed back to preHandleData/onFinish.
  • preHandleData - Should be a function. If provided, would be called after data got and before rendering template. function prototype is handleData(resultData, callContext, replyRawText), return value is used as new render data by Jscp to render template, if return null, Jscp stops rendering.
  • onFinish - Should be a function. If provided, would be called after rendering finished. function prototype is onFinish(resultPageHtml, callContext).
  • debugRawData - If set to true, preHandleData function's third parameter would be set to server's raw reply text for data request. Default is false.
  • cachePages - If set to false, Jscp would not cache returned page template in this request. Default is true.
  • reload/deepReload - If set to yes, Jscp would not use cached page template, directly request remote ones. Default is false.

Other available members are passed to class Ajax.Request() in Prototype library, like "method", "parameters", etc.

updateWithRemotePage(container, pageUrl, renderData, options)

Get remote page template, render it with local data, display rendered result in container.

Options parameter please see description in update() method

updateWithRemoteData(container, pageContent, dataUrl, options)

Get remote data, render local template content with the data, display rendered result in container.

Options parameter please see description in update() method

updateLocal(container, pageContent, renderData)

Render local template content with the data, display rendered result in container.

Jscp.Request

Jscp.Request class is often used too. Usually you write "new Jscp.Request()" to create an object instance, call one of its requestXXXX() methods to render page template with data, or get only data/template contents, with option parameter you could get control of some details.

Methods
request(pageUrl, dataUrl, options)

Get remote page template and remote data, render them, display rendered result in container.

Members available in options parameter:

  • callContext - self defined data that would be passed back to preHandleData/onFinish.
  • preHandleData - Should be a function. If provided, would be called after data got and before rendering template. function prototype is handleData(resultData, callContext, replyRawText), return value is used as new render data by Jscp to render template, if return null, Jscp stops rendering.
  • onFinish - Should be a function. If provided, would be called after rendering finished. function prototype is onFinish(resultPageHtml, callContext).
  • debugRawData - If set to true, preHandleData/onFinish function's third parameter would be set to server's raw reply text for data request. Default is false.
  • cachePages - If set to false, Jscp would not cache returned page template in this request. Default is true.
  • reload/deepReload - If set to yes, Jscp would not use cached page template, directly request remote ones. Default is false.

Other available members are passed to class Ajax.Request() in Prototype library, like "method", "parameters", etc.

requestOnlyData(pageContent, dataUrl, options)

Get remote data, render provided pageContent with data.

Members available in options parameter:

  • getRawData - if you want to get data only, without page content and rendering, set this member to true. (usually in this case you set parameter pageContent to empty string.
  • onFinish - Should be a function. If provided, would be called after rendering finished. If getRawData set to true, onFinish function prototype is onFinish(returnedData, callContext), otherwise prototype is same as in request() method.

Other available members please see description in request() method

requestOnlyPage(pageUrl, renderData, options)

Get remote page template, render it with privided renderData.

Members available in options parameter:

  • getRawPage - if you want to get page only, without data and rendering, set this member to true. (usually in this case you set parameter renderData to null.
  • onFinish - Should be a function. If provided, would be called after rendering finished. If getRawData set to true, onFinish function prototype is onFinish(pageContent, callContext), otherwise prototype is same as in request() method.

Other available members please see description in request() method

Jscp

Jscp module has only one public method renderPage( page, renderData ), usually you don't need to call it explicitly. This method implement the key idea of JSCP.

Set Jscp.debugLog to your log function for receiving log information. Jscp.debugLog default is set to null.

Jscp.StringUtil

Jscp.StringUtil a is tiny helper module internally used by JSCP.

Jscp.UrlUtil

Jscp.UrlUtil is a tiny helper module internally used by JSCP.

Jscp.Impl

Jscp.Impl contains private methods.

Jscp.LoadedPages

Jscp.LoadedPages module manage all cached template pages.

Jscp.Impl.PageLoader

Class Jscp.Impl.PageLoader is used by Jscp.LoadedPages to load remote page template.