|
ICEfaces : JavaScript Client API
JavaScript Client APIICEfaces 2 provides a client-side JavaScript API that allows developers access to various features like form submission, event callbacks, and Ajax Push connection monitoring. NamespaceThe namespace used for the ICEfaces client API is 'ice'. It is defined in the bridge.js file, a link to which is automatically rendered out to each page that uses ICEfaces. Form Submission APIThe functions here allow developers access to the specialized types of form submission (e.g. partial, full, single) provided by ICEfaces. ice.submit(event, element) or ice.s(event, element)This is the full submit function that behaves much like a traditional form submission where all form items are posted to the request. Usage: ice.submit(myEvent, theSubmittingElement); Parameters:
ice.se(event, element) and ice.ser(event, element)These functions submit a single element rather than all the elements of the form. This kind of submission reduces the elements serialization overhead and also increases the communication efficiency with the server. Usage: ice.se sends javax.faces.partial.execute=@this and javax.faces.partial.render=@all along with the serialized element and event. ice.se(myEvent, theSubmittingElement); ice.ser sends javax.faces.partial.execute=@this and javax.faces.partial.render=@this along with the serialized element and event. ice.ser(myEvent, theSubmittingElement); Parameters:
Event Callback APIThe functions here allow developers access to the main events that occur in the ICEfaces client-side bridge. This API complements the existing API that's available in JSF 2 that allows the developer to register callbacks for general event and error handling. The ICEfaces API is designed in much the same way as the JSF API. Callback functions are registered that allow the developer to tap into several types of client events that are specific to ICEfaces. ice.onAfterUpdate(callback)Accepts a reference to a callback function. The callback function will be invoked after the updates are applied to the DOM. Usage: ice.onAfterUpdate(postUpdateHandler); ... var postUpdateHandler = function(updates) { ... }; Parameters:
ice.onBeforeUpdate(callback)Accepts a reference to a callback function. The callback function will be invoked before the updates are applied to the DOM. Usage: ice.onBeforeUpdate(preUpdateHandler); ... var preUpdateHandler = function(updates) { ... }; Parameters:
ice.onServerError(callback)Accepts a reference to a callback function. The callback function will be invoked when a server error is received by the browser from a JSF form submit. Usage: ice.onServerError(serverErrorHandler); ... var serverErrorHandler = function(statusCode, responseText, responseDOM) { ... }; Parameters:
ice.onSessionExpiry(callback)Accepts a reference to a callback function. The callback function will be invoked when the HTTP session has been invalidated or expired. Usage: ice.onSessionExpiry(sessionExpiryHandler); ... var sessionExpiryHandler = function() { ... }; ice.onNetworkError(callback)Accepts a reference to a callback function. The callback function will be invoked when a network error is detected by the browser during a request-response. Usage: ice.onNetworkError(networkErrorHandler); ... var networkErrorHandler = function(statusCode, errorDescription) { ... }; Parameters:
ice.onBeforeSubmit(callback)Accepts a reference to a callback function. The callback function will be invoked just before the form submit request is issued. Usage: ice.onBeforeSubmit(paramHandler); ... var paramHandler = function(source) { ... }; Parameters:
ice.onElementRemove(elementID, callback)Accepts the ID of the element to be monitored for removal and a reference to a callback function. The callback function will be invoked when the element with the specified ID is removed from the document. Usage: ice.onElementRemove(elementID, callback) ... var callback = function() { ... }; Parameters:
ice.onLoad(callback)Accepts a reference to a callback function. The callback function will be invoked when the DOM document finished loading. This registration function allows the registration of multiple callbacks without the danger of callback overwriting (unlike the native windown.onload property).
Usage: ice.onLoad(callback) ... var callback = function() { ... }; Parameters:
ice.onUnload(callback)Accepts a reference to a callback function. The callback function will be invoked when the DOM document is unloaded. This registration function allows the registration of multiple callbacks without the danger of callback overwriting (unlike the native windown.onunload property).
Usage: ice.onUnload(callback) ... var callback = function() { ... }; Parameters:
Focus Retention APIThe functions here allow developers access to ICEfaces' focus retention mechanism. ice.setFocus(id) or ice.sf(id)Accepts an element ID. By calling this function the client will send the ID to the server next time a form submit is invoked. The focus is not moved on the specified element. Usage: ice.setFocus(id); Parameters:
ice.applyFocus(id) or ice.af(id)Accepts an element ID. By calling this function the client will move the focus on the specified element and also call ice.setFocus so that the server will be informed about the focus change. Usage: ice.applyFocus(id); Parameters:
Push Specific APIThe following functions are available and valid only when ICEpush is enabled for the application. ice.onBlockingConnectionUnstable(callback)Accepts a reference to a callback function. The callback function will be invoked when the client bridge's hearbeat detects that the server isn't responding in a timely fashion. Usage: ice.onBlockingConnectionUnstable(connectionUnstableHandler); ... var connectionUnstableHandler = function() { ... }; Parameters:
ice.onBlockingConnectionLost(callback)Accepts a reference to a callback function. The callback function will be invoked when the blocking connection to the server has been lost and is considered unrecoverable. Usage: ice.onBlockingConnectionLost(connectionLostHandler); ... var connectionLostHandler = function(reconnectionAttempts) { ... }; Parameters:
ice.onBlockingConnectionServerError(callback)Accepts a reference to a callback function. The callback function will be invoked when a server error is received by the browser on the blocking connection. Usage: ice.onBlockingConnectionServerError(serverErrorHandler); ... var serverErrorHandler = function(statusCode, responseText, responseDOM) { ... }; Parameters:
Configuration APIThe following parameters are used to configure certain functional parts of the client. ice.disableDefaultErrorPopupsThis parameter can be used to disable the popups rendered by default when a network error, session expiry or server error occurs. The parameter is usually set when an application or component developer wants to have rendered only the defined custom indicators. Usage:
ice.disableDefaultErrorPopups = true;
Logging APIice.log.debug(logger, message, exception)Logs a DEBUG level message to the console or log window. ice.log.info(logger, message, exception)Logs a INFO level message to the console or log window. ice.log.warn(logger, message, exception)Logs a WARN level message to the console or log window. ice.log.error(logger, message, exception)Logs a ERROR level message to the console or log window. Usage: ice.log.debug(ice.log, 'Debug message'); ice.log.info(ice.log, 'Info message'); ice.log.warn(ice.log, 'Warning message'); try { ... } catch (e) { ice.log.error(ice.log, 'Error occurred', e); } Parameters:
ice.log.childLogger(parentLogger, categoryName)Creates an new child logger that logs its messages into the defined category. Usage: var a = ice.log.childLogger(ice.log, 'A'); ice.log.debug(a, 'message in category A'); //outputs -- [window.A] debug: message in category A var aa = ice.log.childLogger(a, 'AA'); ice.log.warn(aa, 'message in category AA'); //outputs -- [window.A.AA] warning: message in category AA Parameters:
|
| Copyright © 2012 ICEsoft Technologies, Canada Corp. |