From: Adam Dickmeiss Date: Wed, 26 Aug 2015 11:02:33 +0000 (+0200) Subject: Update ajaxdev.xml and make ti part of the dist PAZ-1025 X-Git-Tag: v1.12.2~5 X-Git-Url: http://sru.miketaylor.org.uk/?a=commitdiff_plain;h=d16956d6005644721a7eeeafa5c5467e8b8bd9b2;p=pazpar2-moved-to-github.git Update ajaxdev.xml and make ti part of the dist PAZ-1025 --- diff --git a/doc/Makefile.am b/doc/Makefile.am index 8061df2..75ea688 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -3,7 +3,7 @@ SUBDIRS = common SUFFIXES=.1 .5 .7 .8 .pdf .esp .xml -XMLFILES = book.xml manref.xml gpl-2.0.xml local.ent +XMLFILES = book.xml ajaxdev.xml manref.xml gpl-2.0.xml local.ent MAINXML = $(srcdir)/book.xml diff --git a/doc/ajaxdev.xml b/doc/ajaxdev.xml index c351230..0a19373 100644 --- a/doc/ajaxdev.xml +++ b/doc/ajaxdev.xml @@ -1,7 +1,6 @@
Ajax client development - Pazpar2 offers programmer a simple Web Service protocol that can be used (queried in a request/response fashion) from any, server- or @@ -14,33 +13,27 @@ finished. Blocking and waiting for usually slow back-end targets is one of the biggest functionality issues in a federated search engine. - - Pz2.js - - Pazpar2 comes with a small JavaScript library called pz2.js. This - library is designed to simplify development of an Ajax-based pazpar2 + Pazpar2 comes with a small JavaScript library called + pz2.js. + This library is designed to simplify development of an Ajax-based pazpar2 client and alleviate programmer from the low-level details like polling the web service, fetching and parsing returned XML output or managing timers, sessions and basic state variables. - The library supports most major browsers including Firefox 1.5+, IE 6+, Safari 2+, Opera 9+ and Konqueror. - The library can work in two modes: a session-aware mode and a session-less mode. - In the session-aware mode, the library assumes that the pazpar2 daemon is contacted directly (preferably via Apache proxy to avoid security breaches) and tracks the session Ids internally. - In the session-less mode the library assumes that the client is identified on the server and the session Ids are not managed @@ -49,56 +42,49 @@ language like PHP that can identify clients and relate them to open pazpar2 sessions). - - Using pz2.js - + Using pz2.js - Client development with the pz2.js is strongly event based and the + Client development with the pz2.js is strongly event based and the style should be familiar to most JavaScript developers. A simple client (jsdemo) is distributed with pazpar2's source code and shows - how to set-up and use pz2.js. + how to set-up and use pz2.js. - In short, programmer starts by instantiating the pz2 object and passing an array of parameters to the constructor. The parameter array specifies callbacks used for handling responses to the pazpar2 commands. Additionally, the parameter array is used to configure - run-time parameters of the pz2.js like polling timer time-outs, - session-mode and XSLT style-sheets. + run-time parameters of the pz2.js like polling + timer time-outs, session-mode and XSLT style-sheets. - Command callbacks - Callback naming is simple and follows “on” prefix plus command name scheme (like onsearch, onshow, onrecord, ... etc.). When programmer - calls a function like show or record on the pz2 object, pz2.js will + calls a function like show or record on the pz2 object, pz2.js will keep on polling pazpar2 (until the backend targets are idle) and with each command's response an assigned callback will be called. In case of pazpar2's internal error an error callback is called. - - my_paz = new pz2 ( + my_paz = new pz2 ( { "pazpar2path": "/pazpar2/search.pz2", "usesessions" : true, - + // assigning command handler, turns on automatic polling "onshow": my_onshow, // polling period for each command can be specified - "showtime": 500, - + "showtime": 500, + "onterm": my_onterm, - // facet terms are specified as a comma separated list - "termlist": "subject,author", - + // facet terms are specified as a comma separated list + "termlist": "subject,author", + "onrecord": my_onrecord } ); - Each command callback is a user defined function that takes a hash object as a parameter. The hash object contains parsed pazpar2 @@ -106,14 +92,13 @@ response XML document). Within the handler programmer further processes the data and updates the viewed document. - - function my_onstat(data) { - var stat = document.getElementById("stat"); - stat.innerHTML = '<span>Active clients: '+ data.activeclients - + '/' + data.clients + ' | </span>' - + '<span>Retrieved records: ' + data.records - + '/' + data.hits + '</span>'; + function my_onstat(data) { + var stat = document.getElementById("stat"); + stat.innerHTML = '<span>Active clients: '+ data.activeclients + + '/' + data.clients + ' | </span>' + + '<span>Retrieved records: ' + data.records + + '/' + data.hits + '</span>'; } function my_onshow(data) { @@ -128,20 +113,16 @@ Element_appendTransformResult(someDiv, data.xmlDoc, data.xslDoc); } - - pz2.js on runtime - + pz2.js on runtime The search process is initiated by calling the search method on the instantiated pz2 object. To initiate short status reports and per-target status information methods stat and bytarget have to be called accordingly. - my_paz.search (query, recPergPage, 'relevance'); - Managing the results (keeping track of the browsed results page and sorting) is up to the client's programmer. At any point the show @@ -149,43 +130,34 @@ different sorting criteria or range and without re-executing the search on the back-end. - my_paz.show (1, 10, 'relevance'); - To retrieve a detailed record the record command is called. When calling record command one may temporarily override its default callback by specifying the handler parameter. This might be useful when retrieving raw records that need to be processed differently. - my_paz.record (recId, 2, 'opac', { “callback”: temp_callback, “args”, caller_args}); - - - PARAMATERS ARRAY - + PARAMETERS ARRAY pazpar2path server path to pazpar2 (relative to the portal), when pazpar2 is installed as a package this does not have to be set - usesessions - boolean, when set to true pz2.js will manage sessions internally otherwise it's left to the server-side script, default true + boolean, when set to true pz2.js will manage sessions internally otherwise it's left to the server-side script, default true - autoInit bolean, sets auto initialization of pazpar2 session on the object instantiation, default true, valid only if usesession is set to true - detailstylesheet path to the xsl presentation stylesheet (relative to the portal) used for the detailed record display - + errorhandler - callback function called on any, pazpar2 or pz2.js' internal, error + callback function called on any, pazpar2 or pz2.js' internal, error oninit specifies init response callback function @@ -226,9 +198,9 @@ - + METHODS - + stop () stop activity by clearing timeouts @@ -260,15 +232,15 @@ start polling for pazpar2 status - + - Pz2.js comes with a set of cross-browser helper classes and functions. + pz2.js comes with a set of cross-browser helper classes and functions. Ajax helper class - pzHttpRequest + pzHttpRequest a cross-browser Ajax wrapper class constructor (url, errorHandler) @@ -288,7 +260,7 @@ XML helper functions - + document.newXmlDoc (root) create new XML document with root node as specified in parameter @@ -319,7 +291,7 @@ parse all descendants into an associative array - +