preferredUrl usage

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

preferredUrl usage

Leon Smith
I have only been using AIDA for two days so please forgive me if this a really stupid question. I have a simple site working following the tutorial, but using different domain objects; ContestSite and Contests. Both have App objects with view methods. The ContestSite lists contests in a tabular format with links to the underlying Contest object.

I am trying to use preferredUrl to create nice links like this:

preferedUrl
| aTitle |
        aTitle := self title trimBlanks.
        aTitle := aTitle copyReplaceAll: ' ' with: '-'.

        ^'/contest/',  aTitle, '.html'

My problem is that my method seems to never get sent. I have stopped and restarted the server, removed and re-added the site, put halts in the method and tried implementing the method on both the App and the model object, but nothing works. Am I supposed to send this message explicitly in ContestSite's viewMain ?

Thanks in advance for any help.
Reply | Threaded
Open this post in threaded view
|

Re: preferredUrl usage

Giuseppe
Have you preferedUrl on instance side of the model domain class?

Example.

AnExample
AnExampleApp

preferedUrl must be on AnExample instance side.

Cheers.

El 18/03/2008, a las 20:43, Leon Smith escribió:

>
> I have only been using AIDA for two days so please forgive me if  
> this a
> really stupid question. I have a simple site working following the  
> tutorial,
> but using different domain objects; ContestSite and Contests. Both  
> have App
> objects with view methods. The ContestSite lists contests in a tabular
> format with links to the underlying Contest object.
>
> I am trying to use preferredUrl to create nice links like this:
>
> preferedUrl
> | aTitle |
> aTitle := self title trimBlanks.
> aTitle := aTitle copyReplaceAll: ' ' with: '-'.
>
>        ^'/contest/',  aTitle, '.html'
>
> My problem is that my method seems to never get sent. I have stopped  
> and
> restarted the server, removed and re-added the site, put halts in  
> the method
> and tried implementing the method on both the App and the model  
> object, but
> nothing works. Am I supposed to send this message explicitly in
> ContestSite's viewMain ?
>
> Thanks in advance for any help.
> --
> View this message in context: http://www.nabble.com/preferredUrl-usage-tp16126092p16126092.html
> Sent from the AIDA/Web mailing list archive at Nabble.com.
>
> _______________________________________________
> Aida mailing list
> [hidden email]
> http://lists.aidaweb.si/mailman/listinfo/aida

_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: preferedUrl usage

Janko Mivšek
In reply to this post by Leon Smith
Hi Leon,welcome to the mailing list!

About preferedUrl usage: this method is called only once per domain
object, when its Url is registered into an URLResolver. If  #preferedUrl
was changed later (or object was already registered with automatic Url
before prefered method was created), then you need to re-register it,
for example:

     (AIDASite named: 'aidademo')
        urlResolver changeToPreferedURL: myDomainObject

Also note that we are using *one r*, not two in preferedUrl! This also
can be a reason for your troubles.

So, try to do above for your ContestSite first to see if it works.

Best regards
Janko

Leon Smith wrote:

> I have only been using AIDA for two days so please forgive me if this a
> really stupid question. I have a simple site working following the tutorial,
> but using different domain objects; ContestSite and Contests. Both have App
> objects with view methods. The ContestSite lists contests in a tabular
> format with links to the underlying Contest object.
>
> I am trying to use preferredUrl to create nice links like this:
>
> preferedUrl
> | aTitle |
> aTitle := self title trimBlanks.
> aTitle := aTitle copyReplaceAll: ' ' with: '-'.
>
>         ^'/contest/',  aTitle, '.html'
>
> My problem is that my method seems to never get sent. I have stopped and
> restarted the server, removed and re-added the site, put halts in the method
> and tried implementing the method on both the App and the model object, but
> nothing works. Am I supposed to send this message explicitly in
> ContestSite's viewMain ?
>
> Thanks in advance for any help.

--
Janko Mivšek
AIDA/Web
Smalltalk Web Application Server
http://www.aidaweb.si
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: preferedUrl usage

Leon Smith
Thanks Janko and Giuseppe for your responses. Janko's response explained the caching behavior thats been driving me mad. Now I have another problem. I stopped my site, removed it, re-created it, stopped the SwazooServer, and evaluated this in a workspace:

| site  |

site := UwaliContestSite demo.
(AIDASite named: 'uwali') urlResolver defaultURL: '/uwali.html' forObject: site .
(AIDASite named: 'uwali')
        urlResolver changeToPreferedURL: site.
site contests do:[ :aContest |
(AIDASite named: 'uwali')
        urlResolver changeToPreferedURL: aContest].


The demo method creates some dummy contest objects, adds them to the contestSite and persists the site as the root object to a GOODS database,

The preferedURL method is on the instance side of ContestApp and looks like this:

preferedUrl
        | aTitle |
        aTitle := self title trimBlanks.
        aTitle := aTitle copyReplaceAll: ' ' with: '-'.
        ^'/uwali/', aTitle, '.html'.

The view method of ContestSite looks like this:

viewMain
        | e |
        e := WebElement new.
        e addTextH1: 'Uwali Contest Site'.
        e table class: #webGrid.
       self observee contests do: [:each |
            e cell addText: each title.
          e newCell addText: each categoryTitle.
            e newCell addText: ', ', each shortDescription.
                e newCell addLinkTo: each  text: each title.
            e newRow].
        self pageFrameWith: e title: 'Contest Site'

Now the link looks good (eg. /uwali/dummy-contest-one.html ), but when I click on it, I get an error message that says "Cannot find aWebApplication for object aContest". I'm sure that the problem is with my addLinkTo: syntax above, but I'm not sure how to fix it.

Thanks

Leon
Reply | Threaded
Open this post in threaded view
|

Re: preferedUrl usage

Rob Rothwell
In reply to this post by Janko Mivšek
On Tue, Mar 18, 2008 at 4:37 PM, Janko Mivšek <[hidden email]> wrote:
Hi Leon,welcome to the mailing list!

About preferedUrl usage: this method is called only once per domain
object, when its Url is registered into an URLResolver. If  #preferedUrl
was changed later (or object was already registered with automatic Url
before prefered method was created), then you need to re-register it,
for example:

    (AIDASite named: 'aidademo')
       urlResolver changeToPreferedURL: myDomainObject

Thanks for this good piece of information.  I have done the same thing wrong myself, but figured as long as everything else was working I would worry about it later!  Now I don't have to!

Janko,

Can you help me to be able to contribute to your site?  I would really like to start filling out your Programmer's Guide to include all these good tidbits and would like to start earning my way!

Rob Rothwell

_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: preferredUrl usage

Leon Smith
In reply to this post by Leon Smith
I found it ! I screwed up my naming conventions. I have an UwaliContestSite, so I created an UwaliContestSiteApp, and I have a model object named Contest, but I created an UwaliContestApp for it instead of just ContestApp.

Thanks very much for your help, and I'm sorry to have taken up your time with a stupid typo.

Leon
Reply | Threaded
Open this post in threaded view
|

Re: preferedUrl usage

Janko Mivšek
In reply to this post by Leon Smith
Leon,

Always remember that in Aida Urls point to domain objects and never to
Apps (web representaions of domain objects). Also, preferedUrl method
must be implemented on domain object, not App!

So, first, put preferedUrl in Contest, not ContestApp. Also, viewMain
must be in ContestSiteApp, not ContestSite.

Therefore you'll have:

   UwaliContestSite
     UwaliContest

and

   UwaliContestSiteApp (subclass of WebApplication)
   UwaliContestApp (subclass of WebApplication)

Remember that App class must be exactly a combination of domain class +
'App'. In your example UwaliContest > UwaliContestApp .

Do you have your classes as shown above?

Janko



Leon Smith wrote:

> Thanks Janko and Giuseppe for your responses. Janko's response explained the
> caching behavior thats been driving me mad. Now I have another problem. I
> stopped my site, removed it, re-created it, stopped the SwazooServer, and
> evaluated this in a workspace:
>
> | site  |
>
> site := UwaliContestSite demo.
> (AIDASite named: 'uwali') urlResolver defaultURL: '/uwali.html' forObject:
> site .
> (AIDASite named: 'uwali')
>         urlResolver changeToPreferedURL: site.
> site contests do:[ :aContest |
> (AIDASite named: 'uwali')
>         urlResolver changeToPreferedURL: aContest].
>
>
> The demo method creates some dummy contest objects, adds them to the
> contestSite and persists the site as the root object to a GOODS database,
>
> The preferedURL method is on the instance side of ContestApp and looks like
> this:
>
> preferedUrl
> | aTitle |
> aTitle := self title trimBlanks.
> aTitle := aTitle copyReplaceAll: ' ' with: '-'.
> ^'/uwali/', aTitle, '.html'.
>
> The view method of ContestSite looks like this:
>
> viewMain
>         | e |
>         e := WebElement new.
>         e addTextH1: 'Uwali Contest Site'.
> e table class: #webGrid.
>        self observee contests do: [:each |
>             e cell addText: each title.
> e newCell addText: each categoryTitle.
>             e newCell addText: ', ', each shortDescription.
> e newCell addLinkTo: each  text: each title.
>             e newRow].
>         self pageFrameWith: e title: 'Contest Site'
>
> Now the link looks good (eg. /uwali/dummy-contest-one.html ), but when I
> click on it, I get an error message that says "Cannot find aWebApplication
> for object aContest". I'm sure that the problem is with my addLinkTo: syntax
> above, but I'm not sure how to fix it.
>
> Thanks
>
> Leon

--
Janko Mivšek
AIDA/Web
Smalltalk Web Application Server
http://www.aidaweb.si
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: preferredUrl usage

Janko Mivšek
In reply to this post by Leon Smith
Leon Smith wrote:
> I found it ! I screwed up my naming conventions. I have an UwaliContestSite,
> so I created an UwaliContestSiteApp, and I have a model object named
> Contest, but I created an UwaliContestApp for it instead of just ContestApp.
>
> Thanks very much for your help, and I'm sorry to have taken up your time
> with a stupid typo.

Well, you pointed out what we must address more in tutorial and docs!
Thanks for that.

Janko



--
Janko Mivšek
AIDA/Web
Smalltalk Web Application Server
http://www.aidaweb.si
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida