Interface HeaderResponse
-
- All Superinterfaces:
MimeResponse,PortletResponse
- All Known Implementing Classes:
HeaderResponseWrapper
public interface HeaderResponse extends MimeResponse
The portlet programming interface provides a mechanism to assist portlets when the aggregated portal markup is an HTML or similar document that requires markup for the documentHEADsection to be written and HTTP headers to be set before the render markup for each individual portlet is aggregated. This mechanism is represented in the portlet API by theHeaderPortlet,HeaderRequest, andHeaderResponseinterfaces.The
HeaderResponsedefines an object to assist a portlet in sending a response to the portal. It extends theMimeResponseinterface to provide specific header response functionality to portlets.The portlet container creates a
HeaderResponseobject and passes it as argument to the portlet'srenderHeadersmethod in order to allow the portlet to add response headers and generate markup for the overall portal response documentHEADsection.- Since:
- 3.0
- See Also:
RenderResponse,HeaderRequest,HeaderPortlet,PortletResponse,MimeResponse
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jakarta.portlet.MimeResponse
MimeResponse.Copy
-
-
Field Summary
-
Fields inherited from interface jakarta.portlet.MimeResponse
CACHE_SCOPE, ETAG, EXPIRATION_CACHE, MARKUP_HEAD_ELEMENT, NAMESPACED_RESPONSE, PRIVATE_SCOPE, PUBLIC_SCOPE, USE_CACHED_CONTENT
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddDependency(String name, String scope, String version)Adds a dependency on a page-level resource that is managed by the portal.voidaddDependency(String name, String scope, String version, String markup)Adds a dependency on a page-level resource that is managed by the portal and adds a resource for addition to the page for the dependency.OutputStreamgetPortletOutputStream()Data written to theHeaderResponseoutput stream is added to the aggregated portal documentHEADsection.PrintWritergetWriter()Data written to theHeaderResponsewriter is added to the aggregated portal documentHEADsection.voidsetContentType(String type)Sets the MIME type for the header response.voidsetTitle(String title)This method sets the title of the portlet.-
Methods inherited from interface jakarta.portlet.MimeResponse
createActionURL, createActionURL, createRenderURL, createRenderURL, createResourceURL, flushBuffer, getBufferSize, getCacheControl, getCharacterEncoding, getContentType, getLocale, isCommitted, reset, resetBuffer, setBufferSize
-
Methods inherited from interface jakarta.portlet.PortletResponse
addProperty, addProperty, addProperty, createElement, encodeURL, getNamespace, getProperty, getPropertyNames, getPropertyValues, setProperty
-
-
-
-
Method Detail
-
setTitle
void setTitle(String title)
This method sets the title of the portlet.The value can be a text String
- Parameters:
title- portlet title as text String or resource URI
-
setContentType
void setContentType(String type)
Sets the MIME type for the header response. The portlet should set the content type before callinggetWriter()orgetPortletOutputStream().Calling
setContentTypeaftergetWriterorgetOutputStreamdoes not change the content type.The portlet container will ignore any character encoding specified as part of the content type for
rendercalls.- Specified by:
setContentTypein interfaceMimeResponse- Parameters:
type- the content MIME type- Throws:
IllegalArgumentException- if the given type is not in the list returned byPortletRequest.getResponseContentTypes- See Also:
PortletRequest.getResponseContentTypes(),MimeResponse.getContentType()
-
getWriter
PrintWriter getWriter() throws IOException
Data written to theHeaderResponsewriter is added to the aggregated portal documentHEADsection.Returns a PrintWriter object that can send character text to the portal.
Before calling this method the content type of the render response should be set using the
MimeResponse.setContentType(java.lang.String)method.Either this method or
MimeResponse.getPortletOutputStream()may be called to write the body, not both.- Specified by:
getWriterin interfaceMimeResponse- Returns:
- a
PrintWriterobject that can return character data to the portal - Throws:
IOException- if an input or output exception occurred- See Also:
MimeResponse.setContentType(java.lang.String),MimeResponse.getPortletOutputStream()
-
getPortletOutputStream
OutputStream getPortletOutputStream() throws IOException
Data written to theHeaderResponseoutput stream is added to the aggregated portal documentHEADsection.Returns a
OutputStreamsuitable for writing binary data in the response. The portlet container does not encode the binary data.Before calling this method the content type of the render response must be set using the
MimeResponse.setContentType(java.lang.String)method.Calling
flush()on the OutputStream commits the response.Either this method or
MimeResponse.getWriter()may be called to write the body, not both.- Specified by:
getPortletOutputStreamin interfaceMimeResponse- Returns:
- a
OutputStreamfor writing binary data - Throws:
IOException- if an input or output exception occurred- See Also:
MimeResponse.setContentType(java.lang.String),MimeResponse.getWriter()
-
addDependency
void addDependency(String name, String scope, String version)
Adds a dependency on a page-level resource that is managed by the portal.When a portlet is aggregated onto a page, it may designate resources such as JavaScript files or style sheets that it needs to have on the page in order to operate correctly. These resources typically should be added to the aggregated document
headsection. Such resources are known as portlet dependencies.The portal implementation is responsible for adding the portlet dependencies to the page during aggregation. The resources declared as dependencies are typically such that they should be added to the page only a single time, but may be used by multiple portlets.
Portlet dependencies may be configured statically either through annotations or through the portlet deployment descriptor. The resources to satisfy such dependencies will be made available on all pages on which the portlet is rendered.
The dependency added dynamically through this method is added to the statically declared dependencies for the portlet for the current rendering cycle only.
This method should only be used to add portlet dependencies that can potentially be required by or shared with other portlets as well. Strictly private dependencies, such as JavaScript code needed by this portlet only, should be added to to document head section using the
PortletResponse#addProperty(String, Element)method or by using either thePrintWriterorOutputStreamobject obtained through theHeaderResponse.The manner in which the portal maps the specified name, scope, and version to specific resources is left to the portal implementation.
- Parameters:
name- the resource namescope- the resource scope, may benullor emptyversion- the resource version, may benullor empty- Throws:
IllegalArgumentException- if name isnullor empty- See Also:
PortletResponse.addProperty(String, org.w3c.dom.Element),getWriter(),getPortletOutputStream()
-
addDependency
void addDependency(String name, String scope, String version, String markup)
Adds a dependency on a page-level resource that is managed by the portal and adds a resource for addition to the page for the dependency.See
addDependency(String, String, String)for a discussion of dependencies.The specified markup element representing the resource must be suitable for inclusion in the aggregated portal document
HEADsection. It will generally be either aLINKorSCRIPTtag.This method does not directly place markup into the aggregated page document. The aggregating portal will use the identifying information name, scope, and version along with identifying information for other available page resources to determine which resources will be added to the page.
For example, if a portlet provides a resource with a version of 2.0.0 but another portlet on the same page provides a resource with the same name and scope but a version of 2.1.0, the aggregating portal may choose to include the later version of the resource on the page.
- Parameters:
name- the resource namescope- the resource scope, may benullor emptyversion- the resource version, may benullor emptymarkup- the markup for adding the resource to the page- Throws:
IllegalArgumentException- if name isnullor empty or if markup does not contain valid tags for the documentHEADsection
-
-