Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Noobie] Making one action available to all WOComponents



On 23-Dec-06, at 5:31 PM, email@hidden wrote:
I would like to provide a "logout" button on just about every html- page that i render in my WO-Application which would set some session variables back to null and redirect the user to the 'Main' page.
However i'm failing at finding the right spot ...

Hi Malte!

I'd suggest writing something like the following in your Session.java:

public WOComponent logout() {
// arrange for this session to terminate at the end of the Request/ Response loop
terminate();


// return a page to confirm that we're logged out
// note: make sure that LoggedOutPage doesn't have component action links
// use direct actions with ?wosid = false binding
Application application = (Application)WOApplication.application();
return application.pageWithName("LoggedOutPage", context());
}


This code arranges to terminate the current session and sends to user to a page which confirms that they've logged out. You can create hyperlink which invokes this action directly or as Miguel mentioned, you can create a custom logout component which calls this method.

Since you're terminating the session, there's really no need to clear any session variables. They will go away when garbage collection gets around to cleaning up the instance. (Yes, yes, you can null them if you want to. :-)

Finally, a note about the LoggedOutPage! I like to give users a confirmation that they've terminated their session. That's why I send them to a page which says their session is terminated. I also like that page to have a link back to the main/login page of the app however I DON'T want a session hanging around. That means that the LoggedOutPage needs to have direct actions only. That way, when the user logs out, the session count of the application actually goes down. (Your sysadmins will appreciate this design when they look at the session count when trying to decide if any users are actually using your application!!)

I hope that's clear!
Good luck!
Mark
__
Mark Ritchie
Diamond Lake Consulting Inc.
Toronto Ontario Canada



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/email@hidden

This email sent to email@hidden
References: 
 >[Noobie] Making one action available to all WOComponents (From: email@hidden)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.