seaside problem of understanding

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

seaside problem of understanding

Joachim Jaeckel
Hello,

maybe one of you could do me a favor...?

I try currently making friends with seaside. And bought the Tutorial
book etc. But I have definetly a problem, running the example of the book.

I first tried it in gst, and the most simple thing worked, than I came
to step 2 (beginning of chapter 4) and from that point, gst is running
wild, if I try to call the web-site of the tutorial app.

After all, I tried it today with pharo, because the book is based on
squeak and pharo should be very similiar. But even here, I have the same
problem.

Maybe one of you, who has a deeper knowledge of smalltalk and maybe
seaside, could point me to the problem in my script. I don't find any
mistake...

Would be really great.

The problem comes up, if I use in the STRootComponent the
initializeMenuComponent method. If not, everything works. But I can't
see any error in this.

(If I use in the STRootComponent a line like "menuComponent:
StMenuComponent new;" than everything is fine.

Please see the script attached, I have currently no idea anymore.

Regards,
Joachim.

Namespace current: STTutTodoApp [

    Seaside.WAComponent subclass: StMenuComponent [
        | entries |

        entries [ ^entries ]
        entries: someEntries [ entries := someEntries ]

        initialize [
            super initialize.
            entries := OrderedCollection new.
        ]

        addEntry: aString withAction: aBlock [
            self entries add: aString -> aBlock
        ]

        renderContentOn: html [
            html anchor callback: []; with: 'Pre'.
            html space.
            html anchor callback: []; with: (entries size printString).
            html space.

        ]
    ]

    Seaside.WAComponent subclass: StListComponent [

        renderContentOn: html [
            html table: [
                html
                    tableRow: [ html tableData: [html text: 'Table entry' ]];
                    tableRow: [ html tableData: [html text: 'Table entry' ]]
            ]
        ]
    ]

    Seaside.WAComponent subclass: STRootComponent [
        | menuComponent listComponent |

        STRootComponent class >> canBeRoot [
            ^true
        ]

        menuComponent [ ^menuComponent ]
        menuComponent: aMenu [ menuComponent := aMenu ]

        listComponent [ ^listComponent ]
        listComponent: aList [ listComponent := aList ]

        initialize [
            super initialize.
            self
                menuComponent: self initializeMenuComponent;
                listComponent: StListComponent new.
        ]

        initializeMenuComponent [
            | bla |
            bla := StMenuComponent new.
            bla addEntry: 'All1' withAction: [].
            bla addEntry: 'All2' withAction: [].
            self menuComponent: bla.
        ]

        children [
            ^Array with: (self menuComponent) with: (self listComponent)
        ]

        renderContentOn: html [
            "I render everything by calling html"

            html heading: 'ToDo-List'.
            html div
                class: 'menu';
                with: self menuComponent.
            html div
                class: 'list';
                with: self listComponent.
        ]
    ]

]

STTutTodoApp.STRootComponent registerAsApplication: 'STTutorial'

_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: seaside problem of understanding

Frank Church-3
2009/6/10 Joachim Jaeckel <[hidden email]>:

> Hello,
>
> maybe one of you could do me a favor...?
>
> I try currently making friends with seaside. And bought the Tutorial book
> etc. But I have definetly a problem, running the example of the book.
>
> I first tried it in gst, and the most simple thing worked, than I came to
> step 2 (beginning of chapter 4) and from that point, gst is running wild, if
> I try to call the web-site of the tutorial app.
>
> After all, I tried it today with pharo, because the book is based on squeak
> and pharo should be very similiar. But even here, I have the same problem.
>
> Maybe one of you, who has a deeper knowledge of smalltalk and maybe seaside,
> could point me to the problem in my script. I don't find any mistake...
>
> Would be really great.
>
> The problem comes up, if I use in the STRootComponent the
> initializeMenuComponent method. If not, everything works. But I can't see
> any error in this.
>
> (If I use in the STRootComponent a line like "menuComponent: StMenuComponent
> new;" than everything is fine.
>
> Please see the script attached, I have currently no idea anymore.
>
> Regards,
> Joachim.
>
> Namespace current: STTutTodoApp [
>
>    Seaside.WAComponent subclass: StMenuComponent [
>        | entries |
>
>        entries [ ^entries ]
>        entries: someEntries [ entries := someEntries ]
>
>        initialize [
>            super initialize.
>            entries := OrderedCollection new.
>        ]
>
>        addEntry: aString withAction: aBlock [
>            self entries add: aString -> aBlock
>        ]
>
>        renderContentOn: html [
>            html anchor callback: []; with: 'Pre'.
>            html space.
>            html anchor callback: []; with: (entries size printString).
>            html space.
>
>        ]
>    ]
>
>    Seaside.WAComponent subclass: StListComponent [
>
>        renderContentOn: html [
>            html table: [
>                html
>                    tableRow: [ html tableData: [html text: 'Table entry' ]];
>                    tableRow: [ html tableData: [html text: 'Table entry' ]]
>            ]
>        ]
>    ]
>
>    Seaside.WAComponent subclass: STRootComponent [
>        | menuComponent listComponent |
>
>        STRootComponent class >> canBeRoot [
>            ^true
>        ]
>
>        menuComponent [ ^menuComponent ]
>        menuComponent: aMenu [ menuComponent := aMenu ]
>
>        listComponent [ ^listComponent ]
>        listComponent: aList [ listComponent := aList ]
>
>        initialize [
>            super initialize.
>            self
>                menuComponent: self initializeMenuComponent;
>                listComponent: StListComponent new.
>        ]
>
>        initializeMenuComponent [
>            | bla |
>            bla := StMenuComponent new.
>            bla addEntry: 'All1' withAction: [].
>            bla addEntry: 'All2' withAction: [].
>            self menuComponent: bla.
>        ]
>
>        children [
>            ^Array with: (self menuComponent) with: (self listComponent)
>        ]
>
>        renderContentOn: html [
>            "I render everything by calling html"
>
>            html heading: 'ToDo-List'.
>            html div
>                class: 'menu';
>                with: self menuComponent.
>            html div
>                class: 'list';
>                with: self listComponent.
>        ]
>    ]
>
> ]
>
> STTutTodoApp.STRootComponent registerAsApplication: 'STTutorial'
>
> _______________________________________________
> help-smalltalk mailing list
> [hidden email]
> http://lists.gnu.org/mailman/listinfo/help-smalltalk
>
>

I am a Smalltalk newbie, but it looks like you are making a recursive call.

remove the 'self'' before initializeMenuComponent as
initializeMenuComponent references self already. Just my 2 cents.

>        initialize [
>            super initialize.
>            self
>                menuComponent: self initializeMenuComponent;
>                listComponent: StListComponent new.
>        ]


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: seaside problem of understanding

Paolo Bonzini-3
>>        menuComponent [ ^menuComponent ]
>>        menuComponent: aMenu [ menuComponent := aMenu ]
>>
>>        initialize [
>>            super initialize.
>>            self
>>                menuComponent: self initializeMenuComponent;
>>                listComponent: StListComponent new.
>>        ]
>>
>>        initializeMenuComponent [
>>            | bla |
>>            bla := StMenuComponent new.
>>            bla addEntry: 'All1' withAction: [].
>>            bla addEntry: 'All2' withAction: [].
>>            self menuComponent: bla.
>>        ]
>
> I am a Smalltalk newbie, but it looks like you are making a recursive call.

Yes, but not the way you thought. :-)  And you set me on the right path,
so thanks!

The last line should just "^bla".  Now it's returning self, so
menuComponent is initialized to self.  That's recursive indeed.

Paolo


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: seaside problem of understanding

Joachim Jaeckel
Thanks to all!

 > The last line should just "^bla".  Now it's returning self, so
 > menuComponent is initialized to self.  That's recursive indeed.

Oh man!...

You're so right.

I expect there an return-value and it was already assigned... ok...

Thanks, I looked so many hours and tried so many different ways, to
locate the error. But I haven't seen this one...

Thanks, again! :-)


Joachim.


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk