Iliad - Maintaining the client and the server synced


The problem

Iliad uses controller methods of applications to dispatch requests to stateful widgets. When the user intracts with widgets, they will be updated with AJAX requests.
Controllers are oftenly used to get a domain object from the request's url, and store it in the application.

In some edge cases, inconsistencies between the server and the client state may happen. The problem can happen with several windows/tabs opened with different urls on the same application. During a normal request, the domain object will be stored in the application depending on the URL. If several tabs are opened, each request may have set a different domain object in the application. As AJAX requests will only update dirty widgets, not call controller methods, the underlying domain object can be different from what the user expects.

Possible solutions

First class controllers

There are different solutions to this problem. One solution would be to update the application state for each request, even AJAX ones. This solution would require big backward incompatible changes in Iliad, as we would need first class controllers, with several methods, one for dispatching to the right buildable object, and one for updating the state from the request (this method would be called for each request).

Registering the state of domain objects

Seaside uses a technique of registering the state of user interface objects, to make backtracking work, in the #states method of components. Iliad doesn't handle the back button the same way, so registering the state of user interface objects is not required.

However, another solution to the problem would be to use a similar technique to register domain objects of the application for each normal request, and restore it when an AJAX request comes. This would bring the burden to the developer, but Iliad could offer a solution by automatically registering the 'model' instance variable of applications by default. Developers could then override the registering method to register other objects.


None of the above solutions is perfect. I don't know yet which solution would be the best for Iliad, but Iliad will include one solution to this problem soon. Comments and other ideas are welcome :)

User login