I've tried all methods, nothing works, in the destination @PostConstruct
the parameter is null.
I am sending a redirect from BeanA to a page (backed by BeanB) and trying to extract the parameter from BeanB. The requirement is to not add the parameters to the URL.
I tried all methods:
FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("userId", userId);
@SessionScoped
bean,ec.getFlash().put("userId", userId);
Any suggestions? I am redirecting with:
FacesContext facesContext = FacesContext.getCurrentInstance();
facesContext.getExternalContext().redirect(url);
The portlet API knows two session scopes: PORTLET_SCOPE
and APPLICATION_SCOPE
The default bridge maps all attributes in the session map to PORTLET_SCOPE
, that means those attributes are only visible to the portlet.
If you want to write and read session attributes for all portlets, you have to use:
PortletSession session = ((PortletSession) FacesContext.getCurrentInstance().
getExternalContext().getSession(true));
// set
session.setAttribute(attributeName, value, PortletSession.APPLICATION_SCOPE);
// get
Object value = session.getAttribute(attributeName, PortletSession.APPLICATION_SCOPE);
In a XHTML you can use #{httpSessionScope.attributeName}
as well.