This content has been marked as final.
Show 1 reply
-
1. Re: Session Uniqueness from a4j:push
nbelaevski Jan 8, 2009 5:41 AM (in response to speleomaniac)Hi,
You can use this code:public String getSessionId(FacesContext context, UIComponent component) { String id = null; Object session = context.getExternalContext().getSession(false); if (session != null) { if (session instanceof HttpSession) { id = ((HttpSession) session).getId(); } else { Class<? extends Object> sesssionClass = session.getClass(); try { Method getIdMethod = sesssionClass.getMethod("getId"); id = (String) getIdMethod.invoke(session); } catch (SecurityException e) { throw new FacesException(e.getMessage(), e); } catch (NoSuchMethodException e) { throw new FacesException(e.getMessage(), e); } catch (IllegalArgumentException e) { throw new FacesException(e.getMessage(), e); } catch (IllegalAccessException e) { throw new FacesException(e.getMessage(), e); } catch (InvocationTargetException e) { Throwable cause = e.getCause(); throw new FacesException(cause.getMessage(), cause); } } } return id; }