To some extent these decision end up being subjective design decisions but there are some pretty compelling reasons why you might need to use a Component. I took a crack at answering the question but I encourage you to post or look for alternate answers there if you think mine is wrong in some way. I think the question is an excellent one so I'd also encourage you to upvote the question and/or answer if you think it is appropriate.
While we're on the topic, asking and answering Seaside questions on StackOverflow might help gain us some exposure and legitimacy. I actively monitor the RSS feed for Seaside questions and I'm guessing a few other developers do as well.
The main content of my answer was:
First of all, you are correct that you do not need to use a Component in order to access the Session. Seaside 2.9 moves
#sessionup to a new class
WAObjectwhich makes it accessible to almost all Seaside objects (including Components) but you can definitely refer to
WACurrentSessionyourself for now in 2.8.
Components provide roughly the following functionality in 2.8:
#renderContentOn:is called with an instance of whatever renderer class you specify in
#rendererClass(instead of whatever renderer is in use when your object is asked to render itself)
- A hook (
#updateUrl:) to allow updating the URL used by the renderer to generate links
- Hooks (
#script) to allow updating the HEAD section of the HTML document
- The ability to be the root of an Application
- Hooks (
#states) to make state backtracking easier
- A hook (
#initialRequest:) to allow initialization based on the request that caused the Session to be created
- A facility (
#children) to make sure all components below you will also have the above hooks called on them
- The ability to add Decorations
- The ability to show/answer/call (uses Decorations)
- Some convenience methods (
If you don't need any of the above, you don't need a Component. If you need any of the above, you pretty much do need a Component unless you want to implement the equivalent functionality on your own class.
The simplest metric is probably: if you intend to keep the object around between HTTP requests it should be a Component; if you intend to throw the object away and create it on each rendering pass it probably doesn't need to be. If you imagine an application that was displaying blog pages, you'd probably have Components for a menu, a blog roll, the blog body, each comment, and so on. You might want to factor out the reading of the blog's markup and generation of its HTML so that you could support different markups or different renderers and so that the comment Components could support the same markup. This could be done with a non-Component class that implements
#renderOn:and could be created and used by other Components as needed.
Seaside 2.9 currently splits up the above functionality by making
WAPresenterconcrete and introducing
WAPainteras its superclass. 1-3 above are implemented on
WAPainterand 4-7 on
WAPresenterso you have your choice of what to subclass depending on your needs. It also removes a lot of methods from WAPresenter and WAComponent in an effort to make them easier for end users to understand.