Re: Assigning Sessions values from DirectAction.java
Re: Assigning Sessions values from DirectAction.java
- Subject: Re: Assigning Sessions values from DirectAction.java
- From: Jonathan Rochkind <email@hidden>
- Date: Thu, 27 Mar 2003 17:19:14 -0600
Well, I don't think you are in the session you think you are in, then. In
the session you are really in, that variable had not been set yet. I'd
guess the direct action isn't picking up the previously existing session,
so it's making it's own new session, which of course doesn't have any
non-initial state set in it yet.
How did the user get to that direct action? Normally, if you use
WOHyperlink to generate a direct action link, and the page it's coming from
had a session, WOHyperlink will put ?wosid=[sessionID] on the end of the
URL. That's how the direct action picks up the session.
If you are not using WOHyperlink to generate the link to the direct
action... how are you generating it?
--Jonathan
At 10:47 PM 3/27/2003 +0000, Riaz Lalehzari wrote:
Thanks Jonathan and kaj,
At the moment I am still having some difficulties with this. Basically
when I wrote the same code assigning a value to a session variable from a
method not in the directAction.java file, it would work fine, but the same
code in my action method would not do the same thing. I think my
declarations are incorrect. What I am doing is this:
In my action method I say:
Session session;
session = (Session)session();
((Session)session()).value = variable;
System.out.println("Value from session:" +
((Session)session()).sessionUserID); - (Correct output)
In another method in another java file I say:
Session session;
session = (Session)session();
System.out.println("Value from session:" +
((Session)session()).sessionUserID); - (NULL will always be output)
What is confusing me is that if I cut and paste the code from my action
method into another java files method and assign the value there, all
other methods can see the same value I assigned correctly.
Riaz :)
---------------------------------------------------------------
From: Jonathan Rochkind <email@hidden>
To: "Riaz Lalehzari" <email@hidden>
Subject: Re: Assigning Sessions values from DirectAction.java
Date: Thu, 27 Mar 2003 10:20:42 -0600
At 06:28 AM 3/27/2003 +0000, you wrote:
Hello All,
How can I assign a value to one of my session variables from within an
action method in DirectAction.java? I've tried
session().setObjectForKey(variable, "val") and session.setVal(variable).
The same way you assign a value to one of your session variables from
inside a WOComponent, or from anywhere else really. Nothing special about
it being inside an action method.
Your application's session is usually called Session. But the session()
method is defined returning the superclass WOSession. You need to cast to
Session, and then you can access any API you've defined on Session.
((Session) session()).variable = "val";
Or better, if you've defined a setVariable method:
((Session)session()).setVariable("val");
Riaz
_________________________________________________________________
Hotmail now available on Australian mobile phones. Go to
http://ninemsn.com.au/mobilecentral/hotmail_mobile.asp
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
_________________________________________________________________
Hotmail now available on Australian mobile phones. Go to
http://ninemsn.com.au/mobilecentral/hotmail_mobile.asp
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.