[Seaside] #call: #answer / sessions
Ramiro Diaz Trepat
ramirodt at gmail.com
Tue Feb 6 03:15:17 UTC 2007
Hello Ramón,
I implemented this component Dictionary that you told me about in
the mail below. This method would recycle component instances instead
of creating a new one every time.
The problem is that when I #call: an already used instance, my
Squeak image starts consuming resources rapidly and indeed it hangs in
about 5 seconds.
I have tried this with very simple classes, like a WAComponent
subclass that renders "hello" and another that renders "goodbye" and
always presents the same behaviour (Mac and LInux VMs). But it works
perfectly if I create a new instance every time tough.
I'm sure I must be doing something wrong...
In the main component's rendering method, I have anchors like this:
html anchor callback: [self dispatch: HelloComponent ]; with: 'Hello'.
html anchor callback: [self dispatch: GoodbyeComponent ]; with: 'Goodbye'.
then:
#dispatch: activeComponentClass
| tmpComp |
tmpComp := currentComponent.
currentComponent := self componentFor: activeComponentClass.
tmpComp call: currentComponent.
and the #componentFor: method is exactly as you wrote it.
Do you see anything wrong?
Thanks
r.
PS: nobody answers my questions about using a reverse proxy with a
seaside app :(
On 1/18/07, Ramon Leon <ramon.leon at allresnet.com> wrote:
<snip>
> >
> > I'm asking because I am developing my first real basic, but
> > comertial application in Seaside, and I have not cached up
> > with it real well yet.
> > I have a very simple page, with a header, a navigation bar
> > and a main area, very similar to the Sushi Store. But I have
> > a WAComponent for each of those (header, navbar, etc.),
> > placed an the page using divs.
> > The component of the navication bar, simply shows some
> > options that when clicked, #call the proper component to be
> > displayed on the main area. What I have to do for the
> > component to be displayed on the main area is calling the
> > #call method from the previous component that is on the main
> > area, otherwise this newly selected component will be
> > displayed on the navigation bar DIV.
> > Is this the proper way to build a basic web app that displays
> > a specific component for whatever is clicked on the navigation bar?
>
> Yes, this is correct. I like to have a currentComponent in a layout like
> this, and simply have the menus say
>
> currentComponent call: SomeNewComponent new.
>
> >From the outer container, which acts like a mediator controlling what item
> is displayed. Expect the component to get garbage collected after it's no
> longer displayed since you're not holding onto a reference. If you want to
> reuse existing components rather than creating them on each invocation, you
> could do...
>
> currentComponent call: (self componentFor: SomeNewComponent)
>
> componentFor: aComponent
> ^components at: aComponent ifAbsentPut:[aComponent new]
>
> And use the components class as a key into a dictionary so you can reuse the
> same instance each time they click that menu item. Since you're holding a
> reference to it, it won't be gc'd just because it's not displayed and you
> can use the original instance over and over, meaning it'll maintain any
> state it previously held, a sometimes very useful and unexpected thing in a
> web application.
More information about the Seaside
mailing list