On 12.02.2010, at 08:10, Lukas Renggli wrote:
+mycomponent|child=title+
+mycomponent|child=abstract+
are not the same on one page. Is there a way to specify that I want to use the identical
component if the embedded label (mycomponent) is the same? May I did something wrong but I
always get different objects and it does make sense to me . Would be nice if this would
bedoable. Otherwise I guess I need to do my own component-per-page-cache.
Pier creates one component instance per link that reefers to the component.
I don't think it makes sense to have the same instance of a component
twice on a page. You wouldn't do that in Seaside either. The behavior
in basically undefined since the two components share their state. In
you example it would depend on the initialization order whether the
parameter child would be set to 'title' or 'abstract'.
Well, I don't think there are many use cases where it makes sense, that is
right. Usually there is no point in sharing a component. In my case it is different. If
you assume that the parameters are functioning as configurators of the component then you
are right. The behaviour would dependent on the order of the links.
If you understand the parameters as filters than there is no danger here. My idea is to
have something like this
MyMaComponent class>>descriptionChild
^ MAStringDescription new
parameterName: 'child';
accessor: #child;
label: 'Child component';
priority: 100;
yourself
MyMAComponent class>on: aMAContainerComponent
^ self new component: aMAContainerComponent
MyMAComponent>>child: aString
childDescription := self description detect: [:each| each parameterName = aString]
MyMAComponent>>childDescription
^ childDescription
MyMAComponent>>renderContentOn: html
html render: (self childAt: self childDescription)
If I'm not completley wrong I could spread one MAContainerComponent all over one page.
If forms would be nestable than this could work for even more than one component. I hope
you see that for this use case I really like to have the same object all the time. Well,
but I think I have to figure it out myself. I think I first need to find the place where
the components are created and if the label (mycomponent) is available at that time. If
yes I could alter my component to create instances over a cache. A cache structure-label
to component that resides in the users session should do the trick.
I would be glad if this doesn't sound completely stupid to you and you might have one
or two hints how to proceed.
If you components have no state and are just plain
stateless renders
you might want to look at value links.
Well, there is state because I'm after forms.
Norbert