Re: Component action context().hasSession() returns false? [Was Re: context().hasSession() returns false... then true?]
Re: Component action context().hasSession() returns false? [Was Re: context().hasSession() returns false... then true?]
- Subject: Re: Component action context().hasSession() returns false? [Was Re: context().hasSession() returns false... then true?]
- From: Lachlan Deck <email@hidden>
- Date: Tue, 1 Jul 2008 13:45:00 +1000
On 01/07/2008, at 1:51 AM, Rams wrote:
On Jun 29, 2008, at 8:43 PM, Lachlan Deck wrote:
On 28/06/2008, at 1:20 AM, Rams wrote:
Hi everyone...
I should add, I am currently using component actions. I'm not
defaulting to direct actions yet... so I'm under the impression
that there should always be a session present.
Not always so. But you can force a session to be invoked by
referencing session() in your component.
The only time session() is called in my Main WO or any of it's
embedded components, is in the authenticated method.
public Boolean authenticated() {
return (context().hasSession() &&
session().valueForKey(User.ENTITY_NAME.toLowerCase()) != null);
}
You can also try context().sessionID() to see if it has one. You can
also look at com.webobjects.jspservlet.WOServletContext which is
relevant when running in servlet environments.
I think you'll find that context().hasSession() is not checking for
the presence of a jspServlet sessionID. So you'll need to adjust your
if statement to suit.
But since I'm logging session creation in the Session() constructor,
I know one should already exists. context().hasSession() is
returning false even though a session exists.
You can also look at WOApplication.restoreSessionWithID(sessionID,
woContext);
with regards,
--
Lachlan Deck
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden