Architecture Overview"
Line 30: | Line 30: | ||
</blockquote> | </blockquote> | ||
=Execution Flow of Loading a Page= | =Execution Flow of Loading a Page= | ||
+ | |||
+ | #When a user types a URL or clicks a hyperlink at the browser, a request is sent to the Web server. If the request URL matches ZK's configured URL pattern<ref>For more information, please refer to [[ZK_Configuration_Reference/web.xml/ZK_Loader|ZK Configuration Reference]]</ref>, the ZK loader is then invoked to serve this request. | ||
+ | #ZK loader loads the specified page and interprets it to create proper components accordingly<ref>If URL is mapped to a richlet, the richlet will be called to handle all UI composition. For more information, please refer to [[ZK Developer's Reference/Component Handling/Richlet|Richlet]].</ref>. | ||
+ | #After interpreting the whole page, ZK loader renders the result into a HTML page. The HTML page is then sent back to the browser accompanied with ZK Client Engine<ref>ZK Client Engine is written in JavaScript. Browsers will cache ZK Client engine, so ZK Client engine is usually sent only once at the first visit.</ref>. | ||
+ | #ZK Client engine renders the widgets into DOM elements and inserts the DOM elements into the browser's DOM tree to make them visible to users. | ||
+ | #Then, ZK Client engine sits at the browser to serve the requests made by user, widgets or the application. If it is going to another page, the execution flow starts over again. If it is going to send Ajax request back, another execution flow starts as described in the following section. | ||
+ | |||
+ | <blockquote> | ||
+ | ---- | ||
+ | <references/> | ||
+ | </blockquote> | ||
=Execution Flow of Serving an Ajax Request= | =Execution Flow of Serving an Ajax Request= |
Revision as of 05:06, 2 November 2010
Application Developer's Perspective
A ZK application runs at the server. It could access the backend resources, assemble UI with components, listen to user's activity, and then manipulate components to update UI. All are done at the server. The synchronization of the states of the components between the browser and the server is done automatically by ZK, and transparent to the application.
When running at the server, the application can access the full stack of Java technology. User activities are, including Ajax and Server Push, abstracted to event objects. UI are composed by POJO-like components. It is the most productive approach to develop a modern Web application.
With ZK's Server+client Fusion architecture, your application won't stop at the server. The application could enhance the interactivity by adding optional client-side functionality, such as client-side event handling, visual effect customizing, and even UI composing without the server-side code. ZK enables the seamless fusion ranging from pure server-centric, to pure client-centric. You could have the best of two worlds: productivity and flexibility.
Component Developer's Perspective
Each UI object in ZK consists of a component and a widget. A component is a Java object running at the server which represents a UI object which can be manipulated by a Java application. A component has all the behavior of a UI object except it has no visual part. A widget is a JavaScript object[1] running at the client. This object represents the UI object which interacts with the user. Therefore, a widget usually has a visual appearance, and handles events happening at the client.
The relationship between a component and a widget is one-to-one. However, if a component is not attached to a page, it won't have the corresponding widget at the client. On the other hand, the application is allowed to instantiate widgets at the client directly without the corresponding component.
How to synchronize the states and distribute the load is really up to the component. ZK Client Engine and Update Engine work together to provide an elegant and robust channel to simplify the implementation.
For example, assume we want to implement a component that allows a user to click on a DOM element to show some detailed information of a component. There are at least two approaches to implement it. First, we could load the detailed information to the client when the widget is instantiated, and then show the detail with pure-client code. Alternatively, we might prefer not to load the detailed information at the beginning, and then send a request back to the server for fulfilling the detail when the user clicks on it.
Obviously, the first approach requires more bandwidth for the initial request but responses faster when users click on it. However, it is generally transparent to the application developers, and the implementation of a component can be enhanced later as the project goes.
- ↑ It depends on the client. For Ajax-enabled browsers, it is a JavaScript object. For ZK Reach for Android, it is a Java object running on an Android device.
Execution Flow of Loading a Page
- When a user types a URL or clicks a hyperlink at the browser, a request is sent to the Web server. If the request URL matches ZK's configured URL pattern[1], the ZK loader is then invoked to serve this request.
- ZK loader loads the specified page and interprets it to create proper components accordingly[2].
- After interpreting the whole page, ZK loader renders the result into a HTML page. The HTML page is then sent back to the browser accompanied with ZK Client Engine[3].
- ZK Client engine renders the widgets into DOM elements and inserts the DOM elements into the browser's DOM tree to make them visible to users.
- Then, ZK Client engine sits at the browser to serve the requests made by user, widgets or the application. If it is going to another page, the execution flow starts over again. If it is going to send Ajax request back, another execution flow starts as described in the following section.
- ↑ For more information, please refer to ZK Configuration Reference
- ↑ If URL is mapped to a richlet, the richlet will be called to handle all UI composition. For more information, please refer to Richlet.
- ↑ ZK Client Engine is written in JavaScript. Browsers will cache ZK Client engine, so ZK Client engine is usually sent only once at the first visit.
Execution Flow of Serving an Ajax Request
Version History
Last Update : 2010/11/2
Version | Date | Content |
---|---|---|