Paged topic data in JavaScript Classic API
The JavaScript® API provides an interface for using paged topics.
The API contains the following classes:
- PagedTopicHandler
- Provides methods that enable you to change and navigate the page view.
- PagedTopicListener
- Provides callbacks for when an action is performed on a page or the topic.
- PageStatus
- Contains values that describe the status of a page or topic.
Handler methods
The following example code shows some of the handler methods wrapped in functions you can use to add buttons to a client's user interface.// Get the next page in the topic function next() { handler.next(); } // Get the previous page in the topic function prior() { handler.prior(); } // Get the first page in the topic function first() { handler.first(); } // Get the last page in the topic function last() { handler.last(); } // Close the paged view of the topic function pagedclose() { handler.close(); }
Listener methods
The following example code
creates a PagedTopicHandler and implements the listener methods
add, page, ready,
statusChanged, and update.
var connectionDetails = { onDataFunction : function() { }, onCallbackFunction : function() { // Creates the handler for a topic DiffusionClient.createPagedTopicHandler(topic, { ready : function(handler) { // Add here the code you want to run when the handler // is created. // For example, open a view that is 20 lines long and // contains the first page of data: handler.open(20, 1); }, page : function(handler, status, lines) { // Add here the code you want to run when the page is // loaded. }, update : function(handler, status, index, line) { // Add here the code you want to run when a line on // the current page is updated. // For example, refresh the page. handler.refresh(); }, statusChanged : function(handler, status) { // Add here the code you want to run when the status // of the current page changes. // For example, check whether the page is dirty and // refresh the page if this is true. if (status.isDirty){ handler.refresh(); } }, add : function(handler, status, lines) { // Add here the code you want to run when a line is // added to the current page. } }); }, debug : true };