Newbie question

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

Newbie question

Nicolas Petton
Hi,

I'm working on a small blog engine, mostly to learn AIDA/Web.

I've got a Blog, and some posts.
In BlogApp>>viewMain, I want to display the posts :

BlogApp>>vewMain
        |e|
        e := WebElement new.
        self observee posts do: [:each |
                e add: (PostApp new observee: each)].
        self pageFrameWith: e title: self observee title.

It does not work (return halt).
What's wrong ?

Thanks,

Nicolas
--
Nicolas Petton
http://nico.bioskop.fr
             ___
           ooooooo
          OOOOOOOOO
         |Smalltalk|
          OOOOOOOOO
           ooooooo
            \   /
             [|]
--------------------------------
Ma cl? GPG est disponible ici :
http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xE788C34D

-------------- section suivante --------------
Une pi?ce jointe non texte a ?t? nettoy?e...
Nom: non disponible
Type: application/pgp-signature
Taille: 189 octets
Desc: Ceci est une partie de message
        =?ISO-8859-1?Q?num=E9riquement?= =?ISO-8859-1?Q?_sign=E9e?=
Url: http://lists.aidaweb.si/pipermail/aida/attachments/20071018/ad0ca590/attachment.sig 

Reply | Threaded
Open this post in threaded view
|

Newbie question

Janko Mivšek
Nicolas,

nicolas petton wrote:

> I'm working on a small blog engine, mostly to learn AIDA/Web.
>
> I've got a Blog, and some posts.
> In BlogApp>>viewMain, I want to display the posts :
>
> BlogApp>>vewMain
> |e|
> e := WebElement new.
> self observee posts do: [:each |
> e add: (PostApp new observee: each)].
> self pageFrameWith: e title: self observee title.
>
> It does not work (return halt).
> What's wrong ?

e add: (PostApp new observee: each)

You don't need to make PostApp manually, it is automatically created
when you access that domain object for a first time. What you need is to
add a link to that domain object:

e addLinkTo: each text: eaxh title.

So, a whole viewMain would be:

BlogApp>>viewMain
  |e|
  e := WebElement new.
  self observee posts do: [:each |
  e addLinkTo: each text: each title.
                e addBreak].
  self pageFrameWith: e title: self observee title.

Best regards
Janko

--
Janko Miv?ek
AIDA/Web
Smalltalk Web Application Server
http://www.aidaweb.si

Reply | Threaded
Open this post in threaded view
|

Newbie question

Nicolas Petton

Le jeudi 18 octobre 2007 ? 17:09 +0200, Janko Miv?ek a ?crit :

> Nicolas,
>
> nicolas petton wrote:
>
> > I'm working on a small blog engine, mostly to learn AIDA/Web.
> >
> > I've got a Blog, and some posts.
> > In BlogApp>>viewMain, I want to display the posts :
> >
> > BlogApp>>vewMain
> > |e|
> > e := WebElement new.
> > self observee posts do: [:each |
> > e add: (PostApp new observee: each)].
> > self pageFrameWith: e title: self observee title.
> >
> > It does not work (return halt).
> > What's wrong ?
>
> e add: (PostApp new observee: each)
>
> You don't need to make PostApp manually, it is automatically created
> when you access that domain object for a first time. What you need is to
> add a link to that domain object:
>
> e addLinkTo: each text: eaxh title.
>
> So, a whole viewMain would be:
>
> BlogApp>>viewMain
>   |e|
>   e := WebElement new.
>   self observee posts do: [:each |
>   e addLinkTo: each text: each title.
> e addBreak].
>   self pageFrameWith: e title: self observee title.
>
Thank you Janko, but I want to display all posts, not links to them.
In PostApp>>viewMain I have :

viewMain
        |e|
        e := WebElement new.
        e addTextH1: self observee title.
        e addText: self observee contents.
        self pageFrameWith: e title: self observee title.

A solution would be to rewrite this in BlogApp>>viewMain in a block, but
I don't want to duplicate my code. That's why I wrote in
BlogApp>>viewMain "e add: (PostApp new observee: each)".

Nicolas
> Best regards
> Janko
>
--
Nicolas Petton
http://nico.bioskop.fr
             ___
           ooooooo
          OOOOOOOOO
         |Smalltalk|
          OOOOOOOOO
           ooooooo
            \   /
             [|]
--------------------------------
Ma cl? GPG est disponible ici :
http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xE788C34D

-------------- section suivante --------------
Une pi?ce jointe non texte a ?t? nettoy?e...
Nom: non disponible
Type: application/pgp-signature
Taille: 189 octets
Desc: Ceci est une partie de message
        =?ISO-8859-1?Q?num=E9riquement?= =?ISO-8859-1?Q?_sign=E9e?=
Url: http://lists.aidaweb.si/pipermail/aida/attachments/20071018/cb1d8b27/attachment.sig 

Reply | Threaded
Open this post in threaded view
|

Newbie question

Janko Mivšek


nicolas petton wrote:

> Le jeudi 18 octobre 2007 ? 17:09 +0200, Janko Miv?ek a ?crit :
>> Nicolas,
>>
>> nicolas petton wrote:
>>
>>> I'm working on a small blog engine, mostly to learn AIDA/Web.
>>>
>>> I've got a Blog, and some posts.
>>> In BlogApp>>viewMain, I want to display the posts :
>>>
>>> BlogApp>>vewMain
>>> |e|
>>> e := WebElement new.
>>> self observee posts do: [:each |
>>> e add: (PostApp new observee: each)].
>>> self pageFrameWith: e title: self observee title.
>>>
>>> It does not work (return halt).
>>> What's wrong ?
>> e add: (PostApp new observee: each)
>>
>> You don't need to make PostApp manually, it is automatically created
>> when you access that domain object for a first time. What you need is to
>> add a link to that domain object:
>>
>> e addLinkTo: each text: eaxh title.
>>
>> So, a whole viewMain would be:
>>
>> BlogApp>>viewMain
>>   |e|
>>   e := WebElement new.
>>   self observee posts do: [:each |
>>   e addLinkTo: each text: each title.
>> e addBreak].
>>   self pageFrameWith: e title: self observee title.
>>
> Thank you Janko, but I want to display all posts, not links to them.
> In PostApp>>viewMain I have :
>
> viewMain
> |e|
> e := WebElement new.
> e addTextH1: self observee title.
> e addText: self observee contents.
> self pageFrameWith: e title: self observee title.
>
> A solution would be to rewrite this in BlogApp>>viewMain in a block, but
> I don't want to duplicate my code. That's why I wrote in
> BlogApp>>viewMain "e add: (PostApp new observee: each)".

Then try to put that e from PostApp>>viewMain in a separate method like
#introElement and then in BlogApp simply call:

        e add: post webApp introElement.

But this is a bit hackish kind of reuse IMHO and I never do that way. If
I really want to make a reusable part of web page, I make a special
component (as subclass of WebElement) and reuse it elsewhere. But in
your case it is just simpler to replicate that code in PostApp.

Best regards
Janko



--
Janko Miv?ek
AIDA/Web
Smalltalk Web Application Server
http://www.aidaweb.si