Rendering a structure's children.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Rendering a structure's children.

Nick Brown
I've been writing a couple of Pier components, let's call them
StructureA and StructureB (both subclassed from PRStructure), and each
has a corresponding view (answered by #viewComponentClass), ViewA and
ViewB (subclassed from PRDefaultView).

Now I find I want to embed a 'B' inside of an 'A', so that ViewB gets
rendered inside of ViewA.

I've added a StructureB instance as a child of the StructureA instance.

What I can't figure out is, from within ViewA>>renderContentOn:, how do
I go about getting hold of an instance of ViewB, so that I can pass it
as an arg to "html render: ... "  ?

(I could instantiate ViewB myself, but presumably I would at a minimum
have to set the context ivar to something, but I know not what.)

Or am I going about this the wrong way?

Cheers,
Nick Brown
_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Rendering a structure's children.

Lukas Renggli
> I've been writing a couple of Pier components, let's call them
> StructureA and StructureB (both subclassed from PRStructure), and each
> has a corresponding view (answered by #viewComponentClass), ViewA and
> ViewB (subclassed from PRDefaultView).
>
> Now I find I want to embed a 'B' inside of an 'A', so that ViewB gets
> rendered inside of ViewA.
>
> I've added a StructureB instance as a child of the StructureA instance.
>
> What I can't figure out is, from within ViewA>>renderContentOn:, how do
> I go about getting hold of an instance of ViewB, so that I can pass it
> as an arg to "html render: ... "  ?

Views do not really nest well. It probably can be done, but is
certainly tricky. What I would do is to extract the rendering code of
ViewA and ViewB to separate classes (components, renderable objects,
visitors, ...) that can then be arbitrarily composed in ViewA and B.
This is also what the blog is to display the posts in different ways.

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch

_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Rendering a structure's children.

Nick Brown
On 03/02/2010 20:30, Lukas Renggli wrote:
> Views do not really nest well. It probably can be done, but is
> certainly tricky. What I would do is to extract the rendering code of
> ViewA and ViewB to separate classes (components, renderable objects,
> visitors, ...) that can then be arbitrarily composed in ViewA and B.
> This is also what the blog is to display the posts in different ways.
>
> Lukas
>
>    
OK, thanks Lukas. I'll proceed along those lines.

Cheers,
Nick Brown
_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki