Client-server framework
You maintain coherence between the client side and the server side of a web component with a request and response mechanism.
A web component has two representations:
On the server side as a Java™ object, the web component is associated with the current session by its manager. This object is an instance of IlxWComponent. The web component deployer creates component objects in the servlet or JSP.
On the client side as a JavaScript proxy that represents the Java object on the client. The graphical representation is in HTML. This proxy is automatically generated when a component is printed, and is managed by the component itself. You do not have access to it.
The client browser sends requests to the web application server, usually a URL and its parameters. The server sends back responses in the form of a writer in which the deployer can write HTML code. Communication between both sides is managed by a controller servlet object, an instance of the class IlxWController.
Consider the following scenario of a user interaction:
A user performs an action on a web browser, such as clicking a link in the Web Rule Editor.
This action executes a JavaScript proxy method to be called.
The method first registers the data representing the modification applied to the component in a queue stored in the JavaScript environment of the client.
The name of this queue the modified-component queue.
The next time a request is sent to the controller, the data of the modified component queue is added to the request, and the server-side component object is updated accordingly.
Components are thus synchronized between the client side and the server side.
The major issue on the client side is whether or not to redisplay the HTML page. The JavaScript proxy applies modifications to the HTML page by evaluating the user action.
Three possible conditions can arise:
No requirement to redisplay the page (for example, a text field was edited)
The client must redisplay the page: the JavaScript proxy can carry out this task locally
The server must redisplay the page: the JavaScript proxy sends a request to the server
When a modification of the component state is placed in the queue, the JavaScript proxy method evaluates the modification. If the component must be redisplayed through the server, the JavaScript proxy sends a request to the controller.
The requests sent to the server are of type HTTP. They are sent using the XmlHttpRequest ActiveX object (see Microsoft Developer Network) on Internet Explorer 5.01 or later, or using the XmlHttpRequest JavaScript object for Netscape and Mozilla. This means that you can implement a smart redisplay mechanism, because only the modified components must be redisplayed.