In this video from Chapter 6 of “Learning Web Development with Seaside” we look at how Seaside addresses the common web application challenge of storing application state. We start by launching our Seaside One Click Experience and refactoring our #’renderContentOn:’ method so that the change time links are in a separate method. We then add another anchor to report which flight was selected. Clicking on the anchor evaluates a callback that displays the selected flight using Seaside’s #’inform:’ method.

When we run the application we can view various flights, clicking the “Later” link till we get to a desired flight. We select a flight for August 26 and see that the flight for August 26 was selected. If we use the “Later” link to move to a flight on the 28th, and then use the browser’s back button to move to a flight on the 27th, clicking the “Book flight” link ends up selecting a flight on the 28th because that was the last page rendered by the server (the server doesn’t know that we clicked the browser’s back button).

We can observe the same effect by using two tabs (or windows) in the browser. We view the September 1 flight in one tab and then switch back to the August 28 flight in another tab. Clicking the “Book flight” link again gives us the wrong flight because the server has saved the most recent state which came from the other tab.

Seaside provides a simple way of addressing this common web development problem. We can identify which objects have state that is associated with the page being displayed. When an action takes place on that page, the objects are restored to their original state.

Now we return to the application, click “Later” a few times so that a flight on the 5th is displayed. Click the back button to return to a flight on the 3rd, and click the “Book flight” link. We see that now we correctly get the flight from the 3rd. Likewise, if we use a second tab we can view a flight for the 6th in one tab and still select a flight for the 3rd in the other tab.

This demonstrates the ability Seaside provides for easily associating domain states with specific pages rendered to the client. We can now save our Seaside code.

For more information go to