[Seaside] What's the difference and why??

Rick Flower rickf at ca-flower.com
Tue Mar 14 07:40:06 UTC 2006

Brian Brown wrote:
> Hi Rick - let's step back for a sec and talk about a different 
> structure....
> :)
> What *I* do, and others may have different patterns for their seaside 
> apps, is to create a main page component, and #call: (this is 
> Smalltalk notation for denoting a message send, or a method call in 
> C++ parlance) the components that I want to show up on the page. So, 
> as a simple example, you might have an initialize method:
> initialize
>     mainPage := MainPage new.
>     aboutPage := AboutPage new.
>     enrollPage := EnrollPage new.
>     contactPage := ContactPage new.
>     menuArea := MenuArea on: self.
> mainPage, aboutPage etc. are instance variables on your main App class 
> - say MyWebApp, where the initialize is located.
> Then, in MyWebApp>>renderContentOn:
> renderContentOn: html
>     html divClass: 'sidebar' with: [html render: menuArea].
>     html divClass: 'contentarea' with: [html render: mainPage].
> Then in MenuArea class, you would have a class side method like:
> on: aComponent
>     ^ (self new) parent: aComponent
> ... back on the instance side (a setter for parent):
> parent: aComponent
>     parent := aComponent
> (parent being an instance var)
> parent
>     ^ parent
> and then:
> renderContentOn: html
>     html unorderedList: [
>            html listItem: [html anchorWithAction: [self parent 
> clearAllDelegates] text: 'Home'.].
>            html listItem: [html anchorWithAction: [self parent 
> mainPage call: self parent aboutPage] text: 'About'.].
>           html listItem: [html anchorWithAction: [self mainPage call: 
> self parent call enrollPage] text: 'Enroll'.].
>            html listItem: [html anchorWithAction: [self mainPage call: 
> self parent call contactPage] text: 'Contact Us'.].
>    ].
> This means that you have to have accessor method for the instance 
> variables that get initialized on the MyWebApp class so that you can 
> call "self parent enrollPage" from the MenuArea component. You could 
> also create convenience methods on your menu page, like:
> enrollPage
>     ^ self parent enrollPage
> Anyway, I hope this gives you a different idea of how you can do some 
> things. Feel free to ask any other questions!

Just one more question.. I've got an "about" page that is called as 
shown directly above (using #call) and it works fine,
but I'd like for that page to be able to render the contents of the same 
menu area class (menuArea object from above)
as the parent object does and am wondering about the best way to do 
that.  I figure I've got two possible ways to do it
 -- one would be to add an "on: " method to my About class so the parent 
class can register its instance with the
aboutPage object at creation time (pros: only one menuArea object), or I 
can just create another instance of the
menuArea everytime the About page is pulled up.. Is there another way to 
do this?  Thanks!

-- Rick

More information about the Seaside mailing list