Thanks for all the replies.

I agree that ExternalContext need a clear() method. It's a shame someone
thought it was a good idea to make clear() throw an Exception in the Sun
RI/TCK tests...!

>public String logout()
{
  HttpServletRequest request =
(HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext
().getRequest();
  HttpSession session = request.getSession();
  session.invalidate();
      
  return "success";
}

I will try this. As I found that getExternalContext().getSession()
returns nothing useful that can be used without a classcast
exception...!

Cheers,

Kevin
--
http://www.alfresco.org


-----Original Message-----
From: Stan Silvert [mailto:[EMAIL PROTECTED] 
Sent: 19 September 2005 17:41
To: MyFaces Development
Subject: RE: Another change since 1.0.9 - SessionMap.clear() - an
explanation

No need to get the request.  ExternalContext already has a getSession()
method.

Also, your code will break in a portlet environment.  If you want to
make it work for both portlets and servlets, see
http://wiki.apache.org/myfaces/UsingPortletUtil.  This will let you know
if you can safely cast to HttpSession or if you need to cast to
PortletSession instead.

Truth be told, ExternalContext needs an invalidate() method.

Stan Silvert
JBoss, Inc.
[EMAIL PROTECTED]
callto://stansilvert

> -----Original Message-----
> From: Cash, Jamie [mailto:[EMAIL PROTECTED]
> Sent: Monday, September 19, 2005 11:02 AM
> To: MyFaces Development
> Subject: RE: Another change since 1.0.9 - SessionMap.clear() - an 
> explanation
> 
> We do something similar. The following logout method works with both
old
> and new myfaces.
> 
> public String logout()
> {
>   HttpServletRequest request =
>
(HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext
()
> .getRequest();
>   HttpSession session = request.getSession();
>   session.invalidate();
> 
>   return "success";
> }
> 
> Regards
> 
> Jamie
> 
> 
> INTERNATIONAL FINANCIAL DATA SERVICES (UK) LTD Tel: +44 1268 44 3000
> ********************** N O T I C E *********************************
> 
> This message and any attachments is intended only for the individual
or
> company to which it is addressed and may contain information which is 
> privileged, confidential or prohibited from disclosure or unauthorised

> use. If the recipient of this transmission is not the intended 
> recipient, or the employee or agent responsible for delivering such 
> materials to the intended recipient, you are hereby notified that any 
> use, any form of reproduction, dissemination, copying, disclosure, 
> modification, distribution and/or publication of this e-mail message
or
> its attachments other than by it's intended recipient is strictly 
> prohibited by the sender. If you have received
it in
> error, please notify us immediately by telephone on the number above 
> and destroy the message and all copies
in
> your possession.
> 
> International Financial Data Services (UK) Ltd is authorised and
regulated
> by the Financial Services Authority.
> 
> This footnote also confirms that this email message has been swept by 
> MIMEsweeper for the presence of computer viruses.
> 
> **********************************************************************

Reply via email to