Dynamic Web Development with Seaside

Buy PDF Buy Print

12Embedding Components

Building reusable components and frameworks is the goal of all developers in almost all parts of their applications. The dearth of truly reusable (canned) component libraries for most of the existing web development frameworks is a good indication that this is difficult to do.

Seaside is among the few frameworks poised to change this. It has a solid component model giving one all of the mechanisms necessary to develop well encapsulated components and application development frameworks. We have seen in Section 11.1 that components can be sequenced. In this chapter we show how to embed one component inside another component. In Section 12.6, we will see how to decorate a component to add functionality or change its appearance and as such reuse behavior. With a good component model, the possibility to display components and create new ones by reusing existing ones, writing Seaside applications is very similar to writing GUI applications.

We will start by writing an application which embeds one component, then refactor it into an application built out of two components. Finally we will discuss reuse and show how component decoration support this. We will show how components can be plugged together using events to maximize reuse.

User Contributed Notes

hentai (4 September 2011, 12:50 pm)

This is perhaps the most important chapter of the book, because it illustrates the ability of Seaside to compose applications using components as building blocks. Here is a practical example which I think can tie together many different concepts to show how easily seaside solves web programming problems: Suppose I want to design a 3-panel web page, in which the left panel provides a directory for navigation (see eBay for example), the main panel lists items for sale, and the right panel lists context-sensitive information such as the items included in the shopping card; furthermore, we have a header which lists our current navigation path (using eBay as an example again, Home > Electronics > Cameras & Photo). How can this be designed in Seaside as embedded components?

 

We can consider a main component, corresponding to the main window, with 4 children corresponding to the left panel, main panel, right panel, and header. If a user navigates, using the left panel to a particular location (such as Home > Electronic > Cameras & Photo), the header component should be updated with the current path, while the main panel lists the items for sale in that particular section, and the right panel lists specials for that section. The child components need to communicate with each other (using Announcements) in order update themselves.

 

Can you provide a working example for this description in this chapter? I think it would be an excellent way to describe how components can be embedded in a web app. It would be a very practical example, and well worth the extra code to illustrate these concepts.

Add a Note

Copyright © 17 April 2014 Stéphane Ducasse, Lukas Renggli, C. David Shaffer, Rick Zaccone
This book is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 license.

This book is published using Seaside, Magritte and the Pier book publishing engine.