Package javax.portlet.annotations

The javax.portlet.annotations package provides the annotations used for portlet configuration and portlet-specific dependency injection.

See: Description

Package javax.portlet.annotations Description

The javax.portlet.annotations package provides the annotations used for portlet configuration and portlet-specific dependency injection.


The annotation-oriented API provides new capabilities in several areas.

Injectable Portlet Artifacts

Note: Most of these beans are dependent on the portlet request being executed, but some of them could not themselves be declared as @PortletRequestScoped due to technical limitations. These beans should be used within enclosing beans that are either @RenderStateScoped or @PortletRequestScoped to allow the portlet container to properly manage the lifecycle of the injected object. The required enclosing bean scope is noted in the table.

name Description Enclosing Bean Scope Annotation Example
portletConfig The PortletConfig object. Any
private PortletConfig portletConfig;
portletRequest The PortletRequest object. Any
private PortletRequest request;
portletResponse The PortletResponse object. Any
private PortletResponse request;
actionRequest The ActionRequest object. Any
private ActionRequest request;
actionResponse The ActionResponse object. Any
private ActionResponse request;
headerRequest The HeaderRequest object. Any
private HeaderRequest request;
headerResponse The HeaderResponse object. Any
private HeaderResponse request;
renderRequest The RenderRequest object. Any
private RenderRequest request;
renderResponse The RenderResponse object. Any
private RenderResponse request;
eventRequest The EventRequest object. Any
private EventRequest request;
eventResponse The EventResponse object. Any
private EventResponse request;
resourceRequest The ResourceRequest object. Any
private ResourceRequest request;
resourceResponse The ResourceResponse object. Any
private ResourceResponse request;
clientDataRequest The ClientDataRequest object. Any
private ClientDataRequest request;
mimeResponse The MimeResponse object. Any
private MimeResponse request;
stateAwareResponse The StateAwareResponse object. Any
private StateAwareResponse request;
renderParams The RenderParameters object. Any
private RenderParameters renderParams;
mutableRenderParams The MutableRenderParameters object. Any
private MutableRenderParameters mutableRenderParams;
actionParams The ActionParameters object. Any
private ActionParameters actionParams;
resourceParams The ResourceParameters object. Any
private ResourceParameters resourceParams;
portletContext The PortletContext object. Any
private PortletContext portletContext;
portletPreferences The PortletPreferences object. Any
private PortletPreferences preferences;
portletSession The PortletSession object. Any
private PortletSession session;
portletMode The PortletMode object. Any
private PortletMode mode;
windowState The WindowState object. Any
private WindowState windowState;
cookies An list of Cookie objects set for the portlet. See getCookies. Any
private List<Cookie> cookies;
locales An list of supported Locales for the portlet. See getLocales. Any
private List<Locale> locales;
namespace A String representing the unique name space for the portlet window. See getNamespace. @PortletRequestScoped or @RenderStateScoped
private String namespace;
contextPath A String representing the context path for the portlet application. See getContextPath. @PortletRequestScoped or @RenderStateScoped
private String contextPath;
windowId A String representing the unique window ID for the portlet window. See getWindowID. @PortletRequestScoped or @RenderStateScoped
private String windowId;
portletName A String representing the portlet name. See getportletName. @PortletRequestScoped or @RenderStateScoped
private String portletName;

Using the @RenderStateScoped Annotation

The @RenderStateScoped Annotation allows portlet render parameters to be treated as beans. The bean state is stored as a portlet render parameter. The annotation documentation for RenderStateScoped describes the necessary prerequisites.

The paramName element in the annotation can be used to provide a parameter name for storing the bean. This element can also be left empty, in which case the portlet container will generate a parameter name.

When resource URLs are generated, @RenderStateScoped beans valid for the current request are automatically stored on the URL as render parameters. When creating render or action URLs, @RenderStateScoped beans can be automatically stored on the URL with the state valid for the current request by using the appropriate option with the MimeResponse createActionURL and createRenderURL methods.

However, you might want to set a modified @RenderStateScoped bean value on your URL. You can do this using the PortletURL interface setBeanParameter method. You can create a new bean, set the fields as desired, and use the setBeanParameter method to set the new bean on the URL.

Tip: It might be useful to provide your @RenderStateScoped bean with a copy constructor in addition to the required default constructor. You could then create a new @RenderStateScoped bean based on the current state of the injected bean and then update the fields on the new bean as required.

Java Portlet 3.0 API Specification. See the Copyright and License provided with this distribution. Use is subject to license terms.