• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Assigning Sessions values from DirectAction.java
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Assigning Sessions values from DirectAction.java
      • From: Art Isbell <email@hidden>
    • Re: Assigning Sessions values from DirectAction.java
      • From: Jonathan Rochkind <email@hidden>
  • Prev by Date: Re: Assigning Sessions values from DirectAction.java
  • Next by Date: Re: Assigning Sessions values from DirectAction.java
  • Previous by thread: Re: Assigning Sessions values from DirectAction.java
  • Next by thread: Re: Assigning Sessions values from DirectAction.java
  • Index(es):
    • Date
    • Thread