Re: Assigning Sessions values from DirectAction.java
Re: Assigning Sessions values from DirectAction.java
- Subject: Re: Assigning Sessions values from DirectAction.java
- From: "Riaz Lalehzari" <email@hidden>
- Date: Thu, 27 Mar 2003 22:47:46 +0000
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.