rendering in a class hierarchy

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

rendering in a class hierarchy

tgiaccone

First I want to thank everyone for the comments on my last request about setting up a seaside/pharo server.  Now on to my next question.

One more about implementation.

Suppose I have a page, and the page is broken up in to components.  A menu, a header,  a synopsis, and a detail record.  Let's focus for a second on the detail record.

In MyApp, there are several different types of detail records, which could be displayed in that region of the page.  They are all sub-classes of one parent class. For the purposes of discussion, let's assume that the parent class is MADetailDisplay, and the sub classes are MAPersonDisplay, MAFamilyDisplay, MAAddressDisplay (though in reality the exact classes aren't that important).

I want each of these to details to render inside  the same div on the page.

<div id="DetailDisplay">

<!-- in this space the detail component renders -->

</div>

Now it would seem very reasonable to give the parent class the responsibility of rendering the tag that surrounds that detail component. In that way any sub class of MADetailDisplay is going to be in the right "location" on the page.

It's not quite clear to me how to do that in Seaside/Smalltalk. Nor is it clear to me if this is really the right way to even think about this problem.


Anyone care to comment?


Tony

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: rendering in a class hierarchy

John Toohey-2
If I understand you correctly, this is what you need to do :-

In the parent's #renderContentOn: html

html div id: #DetailDisplay; with:[
    html render: child1.
    html render: child2.
]

In the parents #children method

children
    ^ Array with: child1 with child2

On Fri, Nov 6, 2009 at 17:27, Tony Giaccone <[hidden email]> wrote:

First I want to thank everyone for the comments on my last request about setting up a seaside/pharo server.  Now on to my next question.

One more about implementation.

Suppose I have a page, and the page is broken up in to components.  A menu, a header,  a synopsis, and a detail record.  Let's focus for a second on the detail record.

In MyApp, there are several different types of detail records, which could be displayed in that region of the page.  They are all sub-classes of one parent class. For the purposes of discussion, let's assume that the parent class is MADetailDisplay, and the sub classes are MAPersonDisplay, MAFamilyDisplay, MAAddressDisplay (though in reality the exact classes aren't that important).

I want each of these to details to render inside  the same div on the page.

<div id="DetailDisplay">

<!-- in this space the detail component renders -->

</div>

Now it would seem very reasonable to give the parent class the responsibility of rendering the tag that surrounds that detail component. In that way any sub class of MADetailDisplay is going to be in the right "location" on the page.

It's not quite clear to me how to do that in Seaside/Smalltalk. Nor is it clear to me if this is really the right way to even think about this problem.


Anyone care to comment?


Tony

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside




--
-JT



_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: rendering in a class hierarchy

tgiaccone
No. I don't think so. The relationship between the parent and child is just inheritance.


 WAComponent  subclass: MADetailDisplay


MAPersonDetail subclass: MADetailDisplay


If I write this in the subclass:

#renderContentOn: html

    super renderContentOn: html
   "Client renders here".

The super's method will be finished when the child's  method starts.


Tony


On Fri, Nov 6, 2009 at 5:43 PM, John Toohey <[hidden email]> wrote:
If I understand you correctly, this is what you need to do :-

In the parent's #renderContentOn: html

html div id: #DetailDisplay; with:[
    html render: child1.
    html render: child2.
]

In the parents #children method

children
    ^ Array with: child1 with child2

On Fri, Nov 6, 2009 at 17:27, Tony Giaccone <[hidden email]> wrote:

First I want to thank everyone for the comments on my last request about setting up a seaside/pharo server.  Now on to my next question.

One more about implementation.

Suppose I have a page, and the page is broken up in to components.  A menu, a header,  a synopsis, and a detail record.  Let's focus for a second on the detail record.

In MyApp, there are several different types of detail records, which could be displayed in that region of the page.  They are all sub-classes of one parent class. For the purposes of discussion, let's assume that the parent class is MADetailDisplay, and the sub classes are MAPersonDisplay, MAFamilyDisplay, MAAddressDisplay (though in reality the exact classes aren't that important).

I want each of these to details to render inside  the same div on the page.

<div id="DetailDisplay">

<!-- in this space the detail component renders -->

</div>

Now it would seem very reasonable to give the parent class the responsibility of rendering the tag that surrounds that detail component. In that way any sub class of MADetailDisplay is going to be in the right "location" on the page.

It's not quite clear to me how to do that in Seaside/Smalltalk. Nor is it clear to me if this is really the right way to even think about this problem.


Anyone care to comment?


Tony

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside




--
-JT



_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside



_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: rendering in a class hierarchy

John Toohey-2
First point, you should never call #renderContentOn. The framework is responsible for calling that. 

Assume you have a Task that is the root of your application. In the Task's #go method, you will do something like this :-

go
    self call: MyParentComponent new.

Seaside will then call the #renderContentOn method for that component. As your component has children, you then call #render: with the canvas passed into to parent's #renderContentOn, to render each child component.

If I'm not being clear, please ask more questions, and also checkout the new Seaside book at http://book.seaside.st for more examples and explanations.

On Fri, Nov 6, 2009 at 18:08, Tony Giaccone <[hidden email]> wrote:
No. I don't think so. The relationship between the parent and child is just inheritance.


 WAComponent  subclass: MADetailDisplay


MAPersonDetail subclass: MADetailDisplay


If I write this in the subclass:

#renderContentOn: html

    super renderContentOn: html
   "Client renders here".

The super's method will be finished when the child's  method starts.


Tony



On Fri, Nov 6, 2009 at 5:43 PM, John Toohey <[hidden email]> wrote:
If I understand you correctly, this is what you need to do :-

In the parent's #renderContentOn: html

html div id: #DetailDisplay; with:[
    html render: child1.
    html render: child2.
]

In the parents #children method

children
    ^ Array with: child1 with child2

On Fri, Nov 6, 2009 at 17:27, Tony Giaccone <[hidden email]> wrote:

First I want to thank everyone for the comments on my last request about setting up a seaside/pharo server.  Now on to my next question.

One more about implementation.

Suppose I have a page, and the page is broken up in to components.  A menu, a header,  a synopsis, and a detail record.  Let's focus for a second on the detail record.

In MyApp, there are several different types of detail records, which could be displayed in that region of the page.  They are all sub-classes of one parent class. For the purposes of discussion, let's assume that the parent class is MADetailDisplay, and the sub classes are MAPersonDisplay, MAFamilyDisplay, MAAddressDisplay (though in reality the exact classes aren't that important).

I want each of these to details to render inside  the same div on the page.

<div id="DetailDisplay">

<!-- in this space the detail component renders -->

</div>

Now it would seem very reasonable to give the parent class the responsibility of rendering the tag that surrounds that detail component. In that way any sub class of MADetailDisplay is going to be in the right "location" on the page.

It's not quite clear to me how to do that in Seaside/Smalltalk. Nor is it clear to me if this is really the right way to even think about this problem.


Anyone care to comment?


Tony

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside




--
-JT



_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside



_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside




--
-JT



_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: rendering in a class hierarchy

Stuart Herring-2
In reply to this post by tgiaccone
On Sat, Nov 7, 2009 at 9:27 AM, Tony Giaccone <[hidden email]> wrote:

>
>
> I want each of these to details to render inside  the same div on the page.
>
> <div id="DetailDisplay">
>
> <!-- in this space the detail component renders -->
>
> </div>
>
> Now it would seem very reasonable to give the parent class the
> responsibility of rendering the tag that surrounds that detail component. In
> that way any sub class of MADetailDisplay is going to be in the right
> "location" on the page.
>

In that case, your sub classes are no longer general purpose
WAComponents, but are in fact MADetailDisplay components, and
therefore it would seem reasonable that they would have a different
protocol.

Therefore I would suggest in the parent:

MADetailDisplay>>renderContentOn: html
   html div id: #DetailDisplay; with: [
       self renderDetailOn: html
   ]

MADetailDisplay>>renderDetailOn: html
   self subclassResponsibility.

Then implement #renderDetailOn: in your sub classes, rather than
#renderContentOn:

Of course, if it's important that your child components really are
general purpose WAComponents, then you have a different problem - in
that case I'd suggest you use composition instead: put the wrapping
div in a parent component (not a parent class).

Regards,
Stuart
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside