示例#1
0
 /**
  * Get SessionBean.
  *
  * @param request PortletRequest
  * @return Vlado2PortletSessionBean
  */
 private static Vlado2PortletSessionBean getSessionBean(PortletRequest request) {
   PortletSession session = request.getPortletSession();
   if (session == null) return null;
   Vlado2PortletSessionBean sessionBean =
       (Vlado2PortletSessionBean) session.getAttribute(SESSION_BEAN);
   if (sessionBean == null) {
     sessionBean = new Vlado2PortletSessionBean();
     session.setAttribute(SESSION_BEAN, sessionBean);
   }
   return sessionBean;
 }
 public void addListener(SessionListener sessionListener) {
   ServletExternalContext.SessionListeners listeners =
       (ServletExternalContext.SessionListeners)
           portletSession.getAttribute(
               ServletExternalContext.SESSION_LISTENERS, PortletSession.APPLICATION_SCOPE);
   if (listeners == null) {
     listeners = new ServletExternalContext.SessionListeners();
     portletSession.setAttribute(
         ServletExternalContext.SESSION_LISTENERS, listeners, PortletSession.APPLICATION_SCOPE);
   }
   listeners.addListener(sessionListener);
 }