LoginComponent as Subcomponent

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

LoginComponent as Subcomponent

seaside_list
Hi,

Maybe someone can help me...

I have a root component in my app with a banner and toolbar, navigation and working area subcomponents. Toolbar and navigation area change contents dependent on session state, and the working area is where all
the nice forms for the user are being displayed.

Now I want to have some components to only show up if a user is logged on and has been authenticated. I have found how to do this in a tutorial by Roger Whitney. He suggests using a special session class (which I already do for other reasons) and use the code below to ensure the login component is always being called by the session if no user is logged on:

MySession>>#user
   user ifNil: [self loginUser].
   ^user

MySession>>#loginUser
   ^user := self mainClass new call: SeasideLogin new

(for the full tutorial look here: http://www.eli.sdsu.edu/courses/fall04/cs683/notes/seasideLogin/seasideLogin.html)

My problem is that this code makes the login component (SeasideLogin) the only component in my browser, that replaces the root component.
I'd like to let my current working area component to be replaced by the login component, just as if the current component in the working area had done a call: .

How can I achieve this?
I tried the following:
I added an inst var for the current rootComponent for the session.
I subclassed WARenderLoopMain and overrode #createRoot to not create a new instance of the rootComponent but gets the session's instance and has its working area's subcomponent call: the login component.
At first, this looks good: the loginComponent only occupied the working area. But the #answer: of the loginComponent does not return to where I thought it should, and the loginComponent stays in the working area forver. If it had been call:ed by the component that was in place before, it would have delegated back.

The only idea I have now is that I could create a new common superclass for all my components that can possibly appear in the working area and implement a #login method that does the call:. But this would mean that subcomponents need to know more about their environment than I think would be good.

Would an #onAnswer: help me? How do others solve this problem?

Thanks for hints

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

Re: LoginComponent as Subcomponent

Brian Brown-6
Here is an old tutorial of using GOODS with a login component scheme, also
using a WATask as the app root component. It's actually easy to use without
GOODS, so you should be able to get some good ideas from it.

http://www.techgame.net/projects/Seaside/wiki/UsingGOODS

Now I do it a bit differently, but this method will work. If I get some
time in the next week I can post a generic login component that works
with GOODS and ROE or a Collection.

Brian


[hidden email] wrote:
 
> Hi,
>
> Maybe someone can help me...
>
[snip]


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

Re: LoginComponent as Subcomponent

Philippe Marschall
In reply to this post by seaside_list
2006/10/5, [hidden email] <[hidden email]>:

> Hi,
>
> Maybe someone can help me...
>
> I have a root component in my app with a banner and toolbar, navigation and working area subcomponents. Toolbar and navigation area change contents dependent on session state, and the working area is where all
> the nice forms for the user are being displayed.
>
> Now I want to have some components to only show up if a user is logged on and has been authenticated. I have found how to do this in a tutorial by Roger Whitney. He suggests using a special session class (which I already do for other reasons) and use the code below to ensure the login component is always being called by the session if no user is logged on:
>
> MySession>>#user
>    user ifNil: [self loginUser].
>    ^user
>
> MySession>>#loginUser
>    ^user := self mainClass new call: SeasideLogin new
>
> (for the full tutorial look here: http://www.eli.sdsu.edu/courses/fall04/cs683/notes/seasideLogin/seasideLogin.html)
>
> My problem is that this code makes the login component (SeasideLogin) the only component in my browser, that replaces the root component.
> I'd like to let my current working area component to be replaced by the login component, just as if the current component in the working area had done a call: .
>
> How can I achieve this?

Make a call on the working area.

> I tried the following:
> I added an inst var for the current rootComponent for the session.
> I subclassed WARenderLoopMain and overrode #createRoot to not create a new instance of the rootComponent but gets the session's instance and has its working area's subcomponent call: the login component.
> At first, this looks good: the loginComponent only occupied the working area. But the #answer: of the loginComponent does not return to where I thought it should, and the loginComponent stays in the working area forver. If it had been call:ed by the component that was in place before, it would have delegated back.
>
> The only idea I have now is that I could create a new common superclass for all my components that can possibly appear in the working area and implement a #login method that does the call:. But this would mean that subcomponents need to know more about their environment than I think would be good.

What about a common baseclass for all components that conatian

isVisible
    ^true

renderOn: html
    self isVisible ifTrue: [ super renderOn: html ]

for components that need login add:

isVisible
    ^self session isLoggedIn

and then somewhere in the navigation or menu

    html anchor
        callback: [ self  workingArea call: LoginCopnent new ]

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