Understanding Components & Children
Components (WAComponents to be exact) are the bricks used to build a Seaside application. An application will be made made up of one or more WAComponent subclasses which #call: and #answer each other to provide the flow and interaction of the web application.
In many cases, what the end user sees as a Page of the website will be made up of several Components. For example, a typical Page might have the following:
- MastHead
- SideBar
- MenuBar
- MainContent
- Footer
If we assume that each of these listed items is a subclass of WAComponent, then they each will be owned by a single
component that I will call SiteEntry?. A very important part of this equation will be the SiteEntry?>>children
method, which should be created to return all the components that will be rendered as part of rendering SiteEntry.
A couple of methods on SiteEntry might be:
initialize mastHead := MastHead new. sideBar := SideBar new. menuBar := MenuBar new. mainContent := MainContent new. footer := Footer new.
children ^ Array with: mastHead with: sideBar with: menuBar with: mainContent with:footer
(there are other ways to do than this using Array>>with:with:..., or storing the children in a collection. This method uses less memory and is easier to write, but is slower)
Any of the Components in the children instance variable on SiteEntry could also be made of many sub components. As long as they properly return the collection of their own children, it will work wonderfully.
If a Component doesn't render any other components, then the default implementation of children on WAComponent will work for you; no need to override it in that case.
Troubleshooting
If the list of children and the actual components being rendered are out of sync, you might receive an error like:
Error: Unprocessed callbacks: #(WAValueCallback WAActionCallback)
... where the Array of unprocessed callbacks will vary based on your app and Components. What this means is that the
application is dutifully going through all the form fields in the Response object and matching them up to the list of children that you told the app would be rendered at this level. Any unmatched (or unconsumed) items will show up in the unprocessed callbacks.
To fix it, figure out where you aren't returning the right children :-)
