jsquery is a lightweight javascript library that allows the pages in your web application to dynamically get new information from the a server application without requiring a page refresh. It's easy to use, fast, cross-browser and standards compliant. It is created by David H. Bennett.
It is an implementation of an AJAX javascript data generation server, http client, and client result set. jsquery Uses a javascript http client to dynamically map the results of data requests from a Java application server to a web browser HTML form without requiring refresh or page submit (similar to Google Suggest). Server side data can be SQL via JDBC, an object relational mapping using a tool such as Hibernate, returned from a server connecting a group of peers or pipelined from another source like a SOAP server.
The advantage of the jsquery is that it allows you to add AJAX functionality to your web applications without learning a new API and adopting gigantic new proprietary paradigms.
Overview:
The jsquery can be divided into three parts:
i) Javascript http client
» {WebRoot}/js/jsquery_httpclient.js - A javascript http client that calls a server side query and evaluates the results into a jsquery_resultset
ii) Java server side generator in src/com/bensoft/jsquery
» JSGenerator.java - Generates a javascript representation of a 2D data matrix into a jsquery_resultset instance
» ResultSet2JS.java - Converts a Java JDBC ResultSet into javascript using JSGenerator
» Types.java - Defines the simplified types for jsquery_resultset.js which include Number, String, Date, and Boolean.
iii) Javascript ResultSet
» {WebRoot}/js/jsquery_resultset.js - A javascript implementation of the JDBC ResultSet that reads from a query result embedded into a series of javascript arrays that are generated by the server.
Step by Step tutorial:
i) A javascript client function uses the http client to make a request from the server. The request can be encapsulated into a JSP or a Servlet. This is done without any page refresh or submission. A function is defined to call when the data is ready, and the javascript function returns immediately.
ii) The JSP/Servlet reads the request parameters from the URL (GET refs) and generates data. The source can be anything the server has access to such as a SQL database, Object Relational Map, SOAP service, etc...
iii) The JSP/Servlet then returns the data as a set of names and types (metadata) and a 2-dimensional data grid (rows of columns) using javascript Array objects. This data is encapsulated into a block of javascript (1.3. spec) so that the client can easily parse the result using the eval() function. The server side 'streams' the resulting javascript to minimize server memory load.
iv) When the transfer is complete, the http client automatically runs a user defined javascript function that evaluates the result from the server and processes it using a JDBC ResultSet style interface. The client receives the entire result set at once requiring enough memory on the client to hold the entire data set (in other words, don't send 10,000 rows of a large data set to the client!)
Examples:
» demo/demo_client.html
» hello/hello_client.html
» js/test_resultset.html
Licence:
This software is licensed under the terms of the GNU PUBLIC LICENSE
Download:
» download jsquery here
Checkout the good discussion about jsquery here.
For more information on jsquery go here ..