::::::::::::::::::::::::::
Home
Home Page
Method of generation of a code
Displays
Result of binding of the data
Systems of patterns of pages
Data acquisition without use XML
Data acquisition without use XML
Use JSON on the party of the client
Improved online shop
Review Ajax
Departure XMLHttpRequest
Processing of search servleta
 The search processing with help JavaScript
Problems of use Ajax
As it was more than once spoken, organization W3C is engaged mainly in development and creation of b
OASIS
Hands off PHP!
Automatic redirect (Auto Redirect) on PHP
Breaking of passwords becomes more accessible
Web2.0 Layout
Links
:::::::::::::::::::::::::

 

Use JSON on the party of the client


The final moment of process will be transformation of the JSON-given to JavaScript-objects on the party{side} of the client. It can be executed with the help of a simple call eval (), functions which translates the lines containing JavaScript-expressions in a stream. Listing 11 shows transformation of JSON-search to the JavaScript-circuit of object and then the task of listing 5 for reception of a name of the first thing from last turn of the buyer carries out.


Listing 11. A rating of JSON-search



var jsonExpression = "(" + req.responseText + ")";

        var customer = eval (jsonExpression);


// We shall find a name of the first thing in last turn of the buyer

var lastOrder = customer.orders [customer.orders.length-1];

var name = lastOrder.items [0] .name;


Comparison of listing 11 with listing 5 illustrates advantages of use JSON on the party{side} of the client. If your Ajax-project includes job with the big stream of complex{difficult} searches to the server on the party{side} of the client, JSON can, undoubtedly to help you. Linkage JSON and XMLHttpRequest together will lead to to that job with Ajax will start to look as call RPC instead of as search SOA which can introduce reliability in development of your application. In following clause{article} I rassmotrju the circuits intended that a JavaScript-code did{made} calls of the removed procedures for objects of the server.



Lacks JSON


At JSON there are lacks. Using approach JSON illustrated here, there is no way to adapt serialization of objects for a specification on the search, therefore unnecessary fields can be sent often on a network. Besides addition toJSONObject () methods to everyone JavaBean is not determined enough, though it was possible to write simply usual JavaBean for JSON-serializatora with use of introspection and remarks. At last, if your code of the server is connected to services and not used only for maintenance of searches from the Ajax-client in this case it is the best way to use XML because of universal support.




Comparison tekhnik serializations


We have considered five various tekhnik for transfer of a Java-status to the Ajax-client. I have told about the XML-serialization created with own hand, XML-linkage by means of generation of a code, XML-binding by means of the mechanism of display, the XML-generation based on patterns, and at last JSON-serializations manually. Each technics{technical equipment} has the advantages and lacks.



The conclusion


The data collected in table 1, do not assert{approve}, that one it is better than technics{technical equipment} of serialization, than others. After all comparative importance of each of six categories depends on specificity of your project. For example, you will work with hundreds types of the data, you want scale, therefore generation of a code, probably, your best choice in this case. If you need to generate some various performances of the same model of the data, patterns of pages - an output{exit} for this case. If you work above the small project and want to reduce quantity{amount} of a JavaScript-code, it is necessary to use JSON-performance.


I hope, that this clause{article} has provided you with all necessary information for a choice of technology of serialization which most of all approaches for your application. Look section Resources to learn{find out} more about technologies about which it is told here. You should see also following clause{article} of this series, where I shall show you how to write the Ajax-application in language Java with help Direct Web Remoting (DWR.) the DWR-circuit will allow you to call methods of your Java-classes directly from a JavaScript-code. In other words, she will undertake job on serialization of the data, therefore you can use Ajax at higher level of abstraction.


Ajax for Java developers: the Part 1. We build dynamic applications in language Java

Perezagruzka pages - the big barrier in development of Web-applications for Java-developers. In this series author Phillip Makkarti enters completely new way for creation of dynamic Web-application.s Ajax


Ajax - a method of development of Web-applications which uses a code by the machine of the client for change of the data on the Web-server. As a result of Web-page are dynamically updated without perezagruzki the full page interrupting data exchange. With help Ajax you can create richer, more dynamic user interfaces for Web-applications which come nearer on speed and flexibility to the applications which are carried out in a client part of your code.


Ajax is not technology, it is more, than simply model, is a way of definition and the description of useful techniques of development. Ajax - in the sense that developers only start to learn{find out} a new product about it though all components which are carried out in the Ajax-application, are already created several years ago. Such boom occurs because outputs{exits} in 2004 and Maps-applications and a site for vykladyvanija photos Flickr are based 2005 of several big and well-known dynamic Web-interfaces on technology Ajax, in particular Google's Gmail. These interfaces - extremely innovative ideas which have been processed in " Web by 2.0" several developers that has led to to that interest to Ajax to applications has quickly increased.


In this series I shall give you all necessary receptions which are necessary for the beginning development own prilozhenijas use Ajax. In this first clause{article} I shall explain to you concepts Ajax and I shall show fundamental steps in creation of the Ajax-interface for the Web-applications written on Java. I shall use examples of a code to show both a Java-code of the server, and a JavaScript-code of the client that does{makes} Ajax applications such dynamical. In the end I shall specify some "reefs" in Ajax, and also more ample opportunities and systems of access which you should consider before to start{begin} to create Ajax applications.