CDI Portlet Predefined Beans

Liferay DXP provides injectable portlet artifacts for CDI called Portlet Predefined Beans, as specified by JSR 362. There are two types of predefined beans:

The table below describes these attributes for each bean:

Artifact: The bean’s type.

Bean EL Name: Expression Language (EL) name for accessing the bean in a JSP or JSF page.

Qualifier: Annotation applied to the bean for defining and selecting a bean implementation.

Valid during (phase): The portlet phases in which the bean is valid.

Portlet Request Scoped Beans

These beans have the @PortletRequestScoped annotation. Here are their artifact types, bean EL names, and annotation qualifiers, along with their valid portlet phases.

Table 1: Portlet Request Scoped Beans1

ArtifactBean EL NameQualifierValid during
PortletConfigportletConfig-all
PortletRequestportletRequest-all
PortletResponseportletResponse-all
ActionRequestactionRequest-action
ActionResponseactionResponse-action
HeaderRequestheaderRequest-header
HeaderResponseheaderResponse-header
RenderRequestrenderRequest-render
RenderResponserenderResponse-render
EventRequesteventRequest-event
EventResponseeventResponse-event
ResourceRequestresourceRequest-resource
ResourceResponseresourceResponse-resource
StateAwareResponsestateAwareResponse-action, event
MimeResponsemimeResponse-header, render, resource
ClientDataRequestclientDataRequest-action, resource
RenderParametersrenderParams-all
MutableRenderParametersmutableRenderParams-action, event
ActionParametersactionParams-action
ResourceParametersresourceParams-resource
PortletContextportletContext-all
PortletModeportletMode-all
WindowStatewindowState-all
PortletPreferencesportletPreferences-all
Cookies(List<Cookie>)cookies-all
PortletSessionportletSession-all
Locales(List<Locale>)locales-all

Dependent Scoped Beans

These beans use the @Dependent scope. They’re of type java.lang.String, which is final. This disqualifies them from being proxied. To prevent using dependent scoped beans in a scope broader than their original scope, you should only inject them into @PortletRequestScoped beans.

Table 2: Dependent Scoped Beans2

ArtifactBean EL NameQualifierValid during
Namespace (String)namespace@Namespaceall
ContextPath (String)contextPath@ContextPathall
WindowID (String)windowId@WindowIdall
Portlet name (String)portletName@PortletNameall

CDI Dependency Injection


  1. Martin Scott Nicklous, Java™ Portlet Specification 3.0, page 122.

  2. Martin Scott Nicklous, Java™ Portlet Specification 3.0, page 123.

Capabilities

Product

Contact Us

Connect

Powered by Liferay
© 2024 Liferay Inc. All Rights Reserved • Privacy Policy