Seaside and urls

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

Seaside and urls

Tommaso DS
Hello everybody,

I am building a web application with Seaside 3.0 and I would like to access single pages of the application with the URL, because I need to access them with other technologies (like javascript libraries).
I was looking into Seaside-REST, but I am wondering if it is the correct way to implement this, also because I would probably loose the session.

Is there a way to provide some kind of routing to Seaside, or is REST the correct way?

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

Re: Seaside and urls

EstebanLM
I'm using Seaside-REST for that (even it is not its purpose), but I needed to hack it a bit (bah, not a BIT really...)

See:

in  WARestfulFilter subclass: #EveRestFilter:

EveRestFilter >>#shoppingList
        <get>
        <path: 'shopping-list'>

        self continueWithRoot: [ :root |
                root startOn: EveUNOPSShoppingListPanel new ].

EveRestFilter >>#continueWithRoot: aBlock
        "Continues the execution of the application.
         I will pass aBlock to the root class of app, which I assume is a REApplication.
         Otherwise, this will fail"
        | requestContext application session rootComponent |
       
        requestContext := self requestContext.
        application := requestContext application.
        session := self obtainSessionWithApplication: application context: requestContext.

        requestContext
                push: session
                during: [
                        rootComponent := requestContext rootComponentIfAbsent: [ nil ].
                        rootComponent ifNil: [
                                rootComponent := (application preferenceAt: #rootClass) new.
                                requestContext rootComponent: rootComponent ].
                        rootComponent do: aBlock.
                        self next handleFiltered: requestContext ].

EveRestFilter >>#obtainSessionWithApplication: application context: requestContext
        | sessionKey session |
       
        sessionKey  := application trackingStrategy keyFromContext: requestContext.
        session := sessionKey ifNotNil: [  
                application cache
                        at: sessionKey  
                        ifAbsent: [ nil] ].
       
        session  ifNil: [
                session := application newSession.
                application register: session ].
               
        ^ session


then in the main component:

EveMainComponent>>startOn: aComponent
        contentComponent show: aComponent



is probably not the best way to do it, but is the easiest way I found, and it works :)

Esteban

On Nov 13, 2013, at 12:24 PM, Tommaso <[hidden email]> wrote:

> Hello everybody,
>
> I am building a web application with Seaside 3.0 and I would like to access single pages of the application with the URL, because I need to access them with other technologies (like javascript libraries).
> I was looking into Seaside-REST, but I am wondering if it is the correct way to implement this, also because I would probably loose the session.
>
> Is there a way to provide some kind of routing to Seaside, or is REST the correct way?
>
> Thank you.
> Tommaso Dal Sasso_______________________________________________
> 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: Seaside and urls

Sabine Manaa
I give a parameter with the url and depending on the parameter I go to this or that page

Example


RKATask is a subclass of Task

RKATask>>go

((self requestContext request fields) at: '_direct' ifAbsent: [ nil ]) isNil 

ifFalse: [ 
self call: (RKALayoutView new  createLogin: #transient)].
....otherwise another call: ((AnotherView new)])

hope this is clear, otherwise please ask
Sabine


On Wed, Nov 13, 2013 at 5:00 PM, EstebanLM [via Smalltalk] <[hidden email]> wrote:
I'm using Seaside-REST for that (even it is not its purpose), but I needed to hack it a bit (bah, not a BIT really...)

See:

in  WARestfulFilter subclass: #EveRestFilter:

EveRestFilter >>#shoppingList
        <get>
        <path: 'shopping-list'>

        self continueWithRoot: [ :root |
                root startOn: EveUNOPSShoppingListPanel new ].

EveRestFilter >>#continueWithRoot: aBlock
        "Continues the execution of the application.
         I will pass aBlock to the root class of app, which I assume is a REApplication.
         Otherwise, this will fail"
        | requestContext application session rootComponent |
       
        requestContext := self requestContext.
        application := requestContext application.
        session := self obtainSessionWithApplication: application context: requestContext.

        requestContext
                push: session
                during: [
                        rootComponent := requestContext rootComponentIfAbsent: [ nil ].
                        rootComponent ifNil: [
                                rootComponent := (application preferenceAt: #rootClass) new.
                                requestContext rootComponent: rootComponent ].
                        rootComponent do: aBlock.
                        self next handleFiltered: requestContext ].

EveRestFilter >>#obtainSessionWithApplication: application context: requestContext
        | sessionKey session |
       
        sessionKey  := application trackingStrategy keyFromContext: requestContext.
        session := sessionKey ifNotNil: [  
                application cache
                        at: sessionKey  
                        ifAbsent: [ nil] ].
       
        session  ifNil: [
                session := application newSession.
                application register: session ].
               
        ^ session


then in the main component:

EveMainComponent>>startOn: aComponent
        contentComponent show: aComponent



is probably not the best way to do it, but is the easiest way I found, and it works :)

Esteban

On Nov 13, 2013, at 12:24 PM, Tommaso <[hidden email]> wrote:

> Hello everybody,
>
> I am building a web application with Seaside 3.0 and I would like to access single pages of the application with the URL, because I need to access them with other technologies (like javascript libraries).
> I was looking into Seaside-REST, but I am wondering if it is the correct way to implement this, also because I would probably loose the session.
>
> Is there a way to provide some kind of routing to Seaside, or is REST the correct way?
>
> Thank you.
> Tommaso Dal Sasso_______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
If you reply to this email, your message will be added to the discussion below:
http://forum.world.st/Seaside-and-urls-tp4721764p4721775.html
To start a new topic under Seaside General, email [hidden email]
To unsubscribe from Seaside, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: Seaside and urls

Philippe Marschall
In reply to this post by EstebanLM
On Wed, Nov 13, 2013 at 4:59 PM, Esteban Lorenzano <[hidden email]> wrote:

> I'm using Seaside-REST for that (even it is not its purpose), but I needed to hack it a bit (bah, not a BIT really...)
>
> See:
>
> in  WARestfulFilter subclass: #EveRestFilter:
>
> EveRestFilter >>#shoppingList
>         <get>
>         <path: 'shopping-list'>
>
>         self continueWithRoot: [ :root |
>                 root startOn: EveUNOPSShoppingListPanel new ].
>
> EveRestFilter >>#continueWithRoot: aBlock
>         "Continues the execution of the application.
>          I will pass aBlock to the root class of app, which I assume is a REApplication.
>          Otherwise, this will fail"
>         | requestContext application session rootComponent |
>
>         requestContext := self requestContext.
>         application := requestContext application.
>         session := self obtainSessionWithApplication: application context: requestContext.
>
>         requestContext
>                 push: session
>                 during: [
>                         rootComponent := requestContext rootComponentIfAbsent: [ nil ].
>                         rootComponent ifNil: [
>                                 rootComponent := (application preferenceAt: #rootClass) new.
>                                 requestContext rootComponent: rootComponent ].
>                         rootComponent do: aBlock.
>                         self next handleFiltered: requestContext ].
>
> EveRestFilter >>#obtainSessionWithApplication: application context: requestContext
>         | sessionKey session |
>
>         sessionKey  := application trackingStrategy keyFromContext: requestContext.
>         session := sessionKey ifNotNil: [
>                 application cache
>                         at: sessionKey
>                         ifAbsent: [ nil] ].
>
>         session  ifNil: [
>                 session := application newSession.
>                 application register: session ].
>
>         ^ session
>
>
> then in the main component:
>
> EveMainComponent>>startOn: aComponent
>         contentComponent show: aComponent
>
>
>
> is probably not the best way to do it, but is the easiest way I found, and it works :)

In Seaside 3.1 there is WARestfulComponentFilter >> #startSessionWithRoot:

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

Re: Seaside and urls

Sabine Manaa
Hi Philipe,

great. I will use it as soon as I switch to 3.0

Regards
Sabine


On Wed, Nov 13, 2013 at 10:19 PM, Philippe Marschall [via Smalltalk] <[hidden email]> wrote:
On Wed, Nov 13, 2013 at 4:59 PM, Esteban Lorenzano <[hidden email]> wrote:

> I'm using Seaside-REST for that (even it is not its purpose), but I needed to hack it a bit (bah, not a BIT really...)
>
> See:
>
> in  WARestfulFilter subclass: #EveRestFilter:
>
> EveRestFilter >>#shoppingList
>         <get>
>         <path: 'shopping-list'>
>
>         self continueWithRoot: [ :root |
>                 root startOn: EveUNOPSShoppingListPanel new ].
>
> EveRestFilter >>#continueWithRoot: aBlock
>         "Continues the execution of the application.
>          I will pass aBlock to the root class of app, which I assume is a REApplication.
>          Otherwise, this will fail"
>         | requestContext application session rootComponent |
>
>         requestContext := self requestContext.
>         application := requestContext application.
>         session := self obtainSessionWithApplication: application context: requestContext.
>
>         requestContext
>                 push: session
>                 during: [
>                         rootComponent := requestContext rootComponentIfAbsent: [ nil ].
>                         rootComponent ifNil: [
>                                 rootComponent := (application preferenceAt: #rootClass) new.
>                                 requestContext rootComponent: rootComponent ].
>                         rootComponent do: aBlock.
>                         self next handleFiltered: requestContext ].
>
> EveRestFilter >>#obtainSessionWithApplication: application context: requestContext
>         | sessionKey session |
>
>         sessionKey  := application trackingStrategy keyFromContext: requestContext.
>         session := sessionKey ifNotNil: [
>                 application cache
>                         at: sessionKey
>                         ifAbsent: [ nil] ].
>
>         session  ifNil: [
>                 session := application newSession.
>                 application register: session ].
>
>         ^ session
>
>
> then in the main component:
>
> EveMainComponent>>startOn: aComponent
>         contentComponent show: aComponent
>
>
>
> is probably not the best way to do it, but is the easiest way I found, and it works :)
In Seaside 3.1 there is WARestfulComponentFilter >> #startSessionWithRoot:

Cheers
Philippe
_______________________________________________
seaside mailing list
If you reply to this email, your message will be added to the discussion below:
http://forum.world.st/Seaside-and-urls-tp4721764p4721861.html
To start a new topic under Seaside General, email [hidden email]
To unsubscribe from Seaside, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: Seaside and urls

philippeback
In reply to this post by Tommaso DS
I tried a quick hack on my app.

So yes, there is a way to have direct pages access.

WAComponent>>updateUrl:

You can add this to your main app component:

updateUrl: aUrl
        super updateUrl: aUrl.
        aUrl addToPath:  self contentView class printString asLowercase


here the contentView thing is what I use to tell what's in the main content area of my system.

Now, you need to pick that back up and set the contentView to the right location for a new session.

HTH
Reply | Threaded
Open this post in threaded view
|

Re: Seaside and urls

Esteban A. Maringolo
In reply to this post by Philippe Marschall
Is there some documentation about this?

Is there any Metacello configuration ready to be used with Pharo 2?

Regards,

Esteban A. Maringolo


2013/11/13 Philippe Marschall <[hidden email]>:

> On Wed, Nov 13, 2013 at 4:59 PM, Esteban Lorenzano <[hidden email]> wrote:
>> I'm using Seaside-REST for that (even it is not its purpose), but I needed to hack it a bit (bah, not a BIT really...)
>>
>> See:
>>
>> in  WARestfulFilter subclass: #EveRestFilter:
>>
>> EveRestFilter >>#shoppingList
>>         <get>
>>         <path: 'shopping-list'>
>>
>>         self continueWithRoot: [ :root |
>>                 root startOn: EveUNOPSShoppingListPanel new ].
>>
>> EveRestFilter >>#continueWithRoot: aBlock
>>         "Continues the execution of the application.
>>          I will pass aBlock to the root class of app, which I assume is a REApplication.
>>          Otherwise, this will fail"
>>         | requestContext application session rootComponent |
>>
>>         requestContext := self requestContext.
>>         application := requestContext application.
>>         session := self obtainSessionWithApplication: application context: requestContext.
>>
>>         requestContext
>>                 push: session
>>                 during: [
>>                         rootComponent := requestContext rootComponentIfAbsent: [ nil ].
>>                         rootComponent ifNil: [
>>                                 rootComponent := (application preferenceAt: #rootClass) new.
>>                                 requestContext rootComponent: rootComponent ].
>>                         rootComponent do: aBlock.
>>                         self next handleFiltered: requestContext ].
>>
>> EveRestFilter >>#obtainSessionWithApplication: application context: requestContext
>>         | sessionKey session |
>>
>>         sessionKey  := application trackingStrategy keyFromContext: requestContext.
>>         session := sessionKey ifNotNil: [
>>                 application cache
>>                         at: sessionKey
>>                         ifAbsent: [ nil] ].
>>
>>         session  ifNil: [
>>                 session := application newSession.
>>                 application register: session ].
>>
>>         ^ session
>>
>>
>> then in the main component:
>>
>> EveMainComponent>>startOn: aComponent
>>         contentComponent show: aComponent
>>
>>
>>
>> is probably not the best way to do it, but is the easiest way I found, and it works :)
>
> In Seaside 3.1 there is WARestfulComponentFilter >> #startSessionWithRoot:
>
> Cheers
> Philippe
> _______________________________________________
> 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: Seaside and urls

EstebanLM
In reply to this post by Sabine Manaa

On Nov 14, 2013, at 5:31 AM, Sabine Knöfel <[hidden email]> wrote:

Hi Philipe,

great. I will use it as soon as I switch to 3.0

Regards
Sabine


On Wed, Nov 13, 2013 at 10:19 PM, Philippe Marschall [via Smalltalk] <<a href="x-msg://12/user/SendEmail.jtp?type=node&amp;node=4721941&amp;i=0" target="_top" rel="nofollow" link="external">[hidden email]> wrote:
On Wed, Nov 13, 2013 at 4:59 PM, Esteban Lorenzano <[hidden email]> wrote:

> I'm using Seaside-REST for that (even it is not its purpose), but I needed to hack it a bit (bah, not a BIT really...) 
> 
> See: 
> 
> in  WARestfulFilter subclass: #EveRestFilter: 
> 
> EveRestFilter >>#shoppingList 
>         <get> 
>         <path: 'shopping-list'> 
> 
>         self continueWithRoot: [ :root | 
>                 root startOn: EveUNOPSShoppingListPanel new ]. 
> 
> EveRestFilter >>#continueWithRoot: aBlock 
>         "Continues the execution of the application. 
>          I will pass aBlock to the root class of app, which I assume is a REApplication. 
>          Otherwise, this will fail" 
>         | requestContext application session rootComponent | 
> 
>         requestContext := self requestContext. 
>         application := requestContext application. 
>         session := self obtainSessionWithApplication: application context: requestContext. 
> 
>         requestContext 
>                 push: session 
>                 during: [ 
>                         rootComponent := requestContext rootComponentIfAbsent: [ nil ]. 
>                         rootComponent ifNil: [ 
>                                 rootComponent := (application preferenceAt: #rootClass) new. 
>                                 requestContext rootComponent: rootComponent ]. 
>                         rootComponent do: aBlock. 
>                         self next handleFiltered: requestContext ]. 
> 
> EveRestFilter >>#obtainSessionWithApplication: application context: requestContext 
>         | sessionKey session | 
> 
>         sessionKey  := application trackingStrategy keyFromContext: requestContext. 
>         session := sessionKey ifNotNil: [ 
>                 application cache 
>                         at: sessionKey 
>                         ifAbsent: [ nil] ]. 
> 
>         session  ifNil: [ 
>                 session := application newSession. 
>                 application register: session ]. 
> 
>         ^ session 
> 
> 
> then in the main component: 
> 
> EveMainComponent>>startOn: aComponent 
>         contentComponent show: aComponent 
> 
> 
> 
> is probably not the best way to do it, but is the easiest way I found, and it works :)
In Seaside 3.1 there is WARestfulComponentFilter >> #startSessionWithRoot: 

cool :)
but my intention was to not create a new session each time I use an URL instead a callback... this way (and using session cookies), I can use some "hard links" mixed with my app.

Esteban 




Cheers 
Philippe 
_______________________________________________ 
seaside mailing list 
If you reply to this email, your message will be added to the discussion below:
http://forum.world.st/Seaside-and-urls-tp4721764p4721861.html
To start a new topic under Seaside General, email <a href="x-msg://12/user/SendEmail.jtp?type=node&amp;node=4721941&amp;i=1" target="_top" rel="nofollow" link="external">[hidden email] 
To unsubscribe from Seaside, click here.
NAML



View this message in context: Re: Seaside and urls
Sent from the Seaside General mailing list archive at Nabble.com.
_______________________________________________
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