RE: [flexcoders] flashgateway.Gateway.getHttpRequest().getSession(true);

2005-03-17 Thread Peter Farland
Hi Devis,

I thought I answered this question for you on Monday?


-Original Message-
From: Peter Farland
Sent: Monday, March 14, 2005 10:15 AM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Servlet Session

I'd suggest you don't use the session servlet in Flex 1.5. Instead, I'd just 
write a normal plain old java object façade that calls the thread-localstatic 
helpers on flashgateway.Gateway

public static HttpServletRequest getHttpRequest()
public static HttpServletResponse getHttpResponse()
public static ServletConfig getServletConfig()

You can get access to the current session from the HttpRequest.

HttpSession session = flashgateway.Gateway.getHttpRequest().getSession(true);


See:

http://www.macromedia.com/support/documentation/en/flex/1_5/migration.html#sessions



Anyway, here's some more detailed instructions:



1. Write some RemoteObject service as a Java class:

-

package sample.session;

import flex.messaging.HttpContext;

import javax.servlet.http.HttpSession;

/**
* A sample Remoting Service that gets and sets 
* attributes from the current session...
*/
public class Session
{
public Session()
{
}

public Object getSessionObject(String name)
{
HttpSession session = HttpContext.getHttpRequest().getSession(true);
return session.getAttribute(name);
}

public void setSessionObject(String name, Object o)
{
HttpSession session = HttpContext.getHttpRequest().getSession(true);
session.setAttribute(name, o);
}
}

-


2. Then add this to your remote-objects whitelist in flex-config.xml:

object name=mySessionService
!-- use-custom-authenticationfalse/use-custom-authentication --
sourcesample.session.Session/source
typestateless-class/type
allow-unnamed-accessfalse/allow-unnamed-access
/object


3. Then change your mx:RemoteObject tag to use this named service:

mx:RemoteObject id=sessionService named=mySessionService/

(Also add fault and result handlers!!)


4. Update your script to use this new RemoteObject by id sessionService.





Re: [flexcoders] flashgateway.Gateway.getHttpRequest().getSession(true);

2005-03-17 Thread [EMAIL PROTECTED]
thank's peter,
sorry but i have had problem with mail mail server :-(
Devis
Peter Farland ha scritto:
Hi Devis,
I thought I answered this question for you on Monday?
-Original Message-
From: Peter Farland
Sent: Monday, March 14, 2005 10:15 AM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Servlet Session
I'd suggest you don't use the session servlet in Flex 1.5. Instead, I'd just 
write a normal plain old java object façade that calls the thread-local static 
helpers on flashgateway.Gateway
public static HttpServletRequest getHttpRequest()
public static HttpServletResponse getHttpResponse()
public static ServletConfig getServletConfig()
You can get access to the current session from the HttpRequest.
HttpSession session = flashgateway.Gateway.getHttpRequest().getSession(true);
See:
http://www.macromedia.com/support/documentation/en/flex/1_5/migration.html#sessions

Anyway, here's some more detailed instructions:

1. Write some RemoteObject service as a Java class:
-
package sample.session;
import flex.messaging.HttpContext;
import javax.servlet.http.HttpSession;
/**
* A sample Remoting Service that gets and sets 
* attributes from the current session...
*/
public class Session
{
public Session()
{
}

public Object getSessionObject(String name)
{
HttpSession session = HttpContext.getHttpRequest().getSession(true);
return session.getAttribute(name);
}
public void setSessionObject(String name, Object o)
{
HttpSession session = HttpContext.getHttpRequest().getSession(true);
session.setAttribute(name, o);
}
}
-
2. Then add this to your remote-objects whitelist in flex-config.xml:
object name=mySessionService
!-- use-custom-authenticationfalse/use-custom-authentication --
sourcesample.session.Session/source
typestateless-class/type
allow-unnamed-accessfalse/allow-unnamed-access
/object
3. Then change your mx:RemoteObject tag to use this named service:
mx:RemoteObject id=sessionService named=mySessionService/
(Also add fault and result handlers!!)
4. Update your script to use this new RemoteObject by id sessionService.

Yahoo! Groups Links