[Seaside] Multiple copies of the same component on a page

Julian Fitzell jfitzell at gmail.com
Mon May 11 17:47:57 UTC 2009

You don't show what you are doing with "plot" so I don't know how you
are rendering it.

You could do something like:

aPortfolio do: [:each | html render: (PDAssetGraph new asset: each) ]

But Components are supposed to be persistent. So if you don't need
them to persist you should not use Components at all: just create an
object (in 2.9 you'd probably subclass WAPainter but in 2.8 it can
just be a subclass of Object) that responds to #renderOn: and pass
that into #render:. Then the above pattern works fine.

If you want to use Components, you should keep around the instances
between rendering passes. A good way is to use a dictionary:

aPortfolio do: [:each | html render: (theGraphs at: each ifAbsentPut:
(PDAssetGraph new asset: each)) ]

then you can return "theGraphs values" in your #children method.

I just blogged about how to choose whether to use a Component:
Perhaps that will help you decide.


On Mon, May 11, 2009 at 10:33 AM, Paul DeBruicker <pdebruic at gmail.com> wrote:
> Hi,
> I have a component that I would like to render a variable number of times on
> a page with slightly different contents each time it is rendered.  I have an
> ordered collection that contains the different content for each instance of
> the component.  An example of what I'd like to do is the following:
> I have a set of clients. Each client has a different set of assets in their
> portfolio, and has a different number of assets in their portfolio. On one
> page,  I'd like to display a price graph for each of the assets in the
> portfolio for the time the client has held the asset.  Since the timespan
> that the assets have been held will be different for each client, the graphs
> should be independent.  My component will get the time series of prices and
> plot it for an asset for the appropriate time period.
> What I have tried is this:
> aPortfolio do: [:each | plot := PDAssetGraph new asset: each.].
> PDAssetGraph's renderContentOn: method coordinates the collection and
> ploting of the data. But my use of do: above just leaves me with a graph of
> the last asset in the collection on my page.  How can I display and keep all
> the intermediate graphs?  It seems to be pulling the data in for them and is
> probably preparing the graphs as well, but only rendering the last one.
> Thanks for any guidance you can provide.
> Paul
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

More information about the seaside mailing list