Top Description Fields Constructors Methods
jakarta.faces.context

public abstract Class ResponseWriter

extends Writer
Class Inheritance
Known Direct Subclasses
jakarta.faces.context.ResponseWriterWrapper, com.sun.faces.renderkit.html_basic.HtmlResponseWriter
Imports
java.io.IOException, .Writer, jakarta.faces.component.UIComponent

ResponseWriter is an abstract class describing an adapter to an underlying output mechanism for character-based output. In addition to the low-level write() methods inherited from java.io.Writer, this class provides utility methods that are useful in producing elements and attributes for markup languages like HTML and XML.

Field Summary

Inherited from java.io.Writer:
lock

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public abstract ResponseWriter

Returns:

the new ResponseWriter
cloneWithWriter
(Writer
The Writer that is the output destination
writer
)

Create and return a new instance of this ResponseWriter, using the specified Writer as the output destination.

public void
endCDATA()

Close an XML CDATA block.

public abstract void
endDocument()

Write whatever text should end a response.

public abstract void
endElement(String
Name of the element to be ended
name
)

Write the end of an element, after closing any open element created by a call to startElement().

public abstract void
flush()

Redeclares java.io.Flushable.flush.

Implements abstract java.io.Writer.flush.

Flush any ouput buffered by the output method to the underlying Writer or OutputStream.

public abstract String

Returns:

the character encoding
getCharacterEncoding
()

Return the character encoding (such as "ISO-8859-1") for this ResponseWriter.

public abstract String

Returns:

the content type
getContentType
()

Return the content type (such as "text/html") for this ResponseWriter.

public void
startCDATA()

Open an XML CDATA block.

public abstract void
startDocument()

Write whatever text should begin a response.

public abstract void
startElement(String
Name of the element to be started
name
,
UIComponent
The UIComponent (if any) to which this element corresponds. This component is inspected for its pass through attributes as described in the standard HTML_BASIC RenderKit specification.
component
)

Write the start of an element, up to and including the element name.

public abstract void
writeAttribute(String
Attribute name to be added
name
,
Object
Attribute value to be added
value
,
String
Name of the property or attribute (if any) of the UIComponent associated with the containing element, to which this generated attribute corresponds
property
)

Write an attribute name and corresponding value, after converting that text to a String (if necessary), and after performing any escaping appropriate for the markup language being rendered.

public abstract void
writeComment(Object
Text content of the comment
comment
)

Write a comment containing the specified text, after converting that text to a String (if necessary), and after performing any escaping appropriate for the markup language being rendered.

public void
writeDoctype(String
Text content of the doctype
doctype
)

Write a string containing the markup specific doctype.

public void
writePreamble(String
Text content of the preamble
preamble
)

Write a string containing the markup specific preamble.

public abstract void
writeText(Object
Text to be written
text
,
String
Name of the property or attribute (if any) of the UIComponent associated with the containing element, to which this generated text corresponds
property
)

Write an object, after converting it to a String (if necessary), and after performing any escaping appropriate for the markup language being rendered.

public void
writeText(Object
Text to be written
text
,
UIComponent
The UIComponent (if any) to which this element corresponds
component
,
String
Name of the property or attribute (if any) of the UIComponent associated with the containing element, to which this generated text corresponds
property
)

Write an object, after converting it to a String (if necessary), and after performing any escaping appropriate for the markup language being rendered.

public abstract void
writeText(char[]
Text to be written
text
,
int
Starting offset (zero-relative)
off
,
int
Number of characters to be written
len
)

Write text from a character array, after any performing any escaping appropriate for the markup language being rendered.

public abstract void
writeURIAttribute(String
Attribute name to be added
name
,
Object
Attribute value to be added
value
,
String
Name of the property or attribute (if any) of the UIComponent associated with the containing element, to which this generated attribute corresponds
property
)

Write a URI attribute name and corresponding value, after converting that text to a String (if necessary), and after performing any encoding or escaping appropriate to the markup language being rendered.

Inherited from java.io.Writer:
appendappendappendclosenullWriterwritewritewritewritewrite

Constructor Detail

ResponseWriterback to summary
public ResponseWriter()

Method Detail

cloneWithWriterback to summary
public abstract ResponseWriter cloneWithWriter(Writer writer)

Create and return a new instance of this ResponseWriter, using the specified Writer as the output destination.

Parameters
writer:Writer

The Writer that is the output destination

Returns:ResponseWriter

the new ResponseWriter

endCDATAback to summary
public void endCDATA() throws IOException

Close an XML CDATA block. The default implementation of this method takes no action when invoked.

Exceptions
IOException:
if input/output error occures
endDocumentback to summary
public abstract void endDocument() throws IOException

Write whatever text should end a response. If there is an open element that has been created by a call to startElement(), that element will be closed first.

Exceptions
IOException:
if an input/output error occurs
endElementback to summary
public abstract void endElement(String name) throws IOException

Write the end of an element, after closing any open element created by a call to startElement(). Elements must be closed in the inverse order from which they were opened; it is an error to do otherwise.

If the argument component's pass through attributes includes an attribute of the name given by the value of the symbolic constant jakarta.faces.render.Renderer#PASSTHROUGH_RENDERER_LOCALNAME_KEY, use that as the element name, instead of the value passed as the first parameter to this method.

Parameters
name:String

Name of the element to be ended

Exceptions
IOException:
if an input/output error occurs
NullPointerException:
if name is null
flushback to summary
public abstract void flush() throws IOException

Redeclares java.io.Flushable.flush.

Implements abstract java.io.Writer.flush.

Flush any ouput buffered by the output method to the underlying Writer or OutputStream. This method will not flush the underlying Writer or OutputStream; it simply clears any values buffered by this ResponseWriter.

Annotations
@Override
Exceptions
IOException:

Doc from java.io.Writer.flush.

If an I/O error occurs

getCharacterEncodingback to summary
public abstract String getCharacterEncoding()

Return the character encoding (such as "ISO-8859-1") for this ResponseWriter. Please see the IANA for a list of character encodings.

Returns:String

the character encoding

getContentTypeback to summary
public abstract String getContentType()

Return the content type (such as "text/html") for this ResponseWriter.

Note

this must not include the "charset=" suffix.

Returns:String

the content type

startCDATAback to summary
public void startCDATA() throws IOException

Open an XML CDATA block. Note that XML does not allow nested CDATA blocks, though this method does not enforce that constraint. The default implementation of this method takes no action when invoked.

Exceptions
IOException:
if input/output error occures
startDocumentback to summary
public abstract void startDocument() throws IOException

Write whatever text should begin a response.

Exceptions
IOException:
if an input/output error occurs
startElementback to summary
public abstract void startElement(String name, UIComponent component) throws IOException

Write the start of an element, up to and including the element name. Once this method has been called, clients can call the writeAttribute() or writeURIAttribute() methods to add attributes and corresponding values. The starting element will be closed (that is, the trailing '>' character added) on any subsequent call to startElement(), writeComment(), writeText(), endElement(), endDocument(), close(), flush(), or write().

If the argument component's pass through attributes includes an attribute of the name given by the value of the symbolic constant jakarta.faces.render.Renderer#PASSTHROUGH_RENDERER_LOCALNAME_KEY, use that as the element name, instead of the value passed as the first parameter to this method. Care must be taken so that this value is not also rendered when any other pass through attributes on this component are rendered.

Parameters
name:String

Name of the element to be started

component:UIComponent

The UIComponent (if any) to which this element corresponds. This component is inspected for its pass through attributes as described in the standard HTML_BASIC RenderKit specification.

Exceptions
IOException:
if an input/output error occurs
NullPointerException:
if name is null
writeAttributeback to summary
public abstract void writeAttribute(String name, Object value, String property) throws IOException

Write an attribute name and corresponding value, after converting that text to a String (if necessary), and after performing any escaping appropriate for the markup language being rendered. This method may only be called after a call to startElement(), and before the opened element has been closed.

Parameters
name:String

Attribute name to be added

value:Object

Attribute value to be added

property:String

Name of the property or attribute (if any) of the UIComponent associated with the containing element, to which this generated attribute corresponds

Exceptions
IOException:
if an input/output error occurs
IllegalStateException:
if this method is called when there is no currently open element
NullPointerException:
if name is null
writeCommentback to summary
public abstract void writeComment(Object comment) throws IOException

Write a comment containing the specified text, after converting that text to a String (if necessary), and after performing any escaping appropriate for the markup language being rendered. If there is an open element that has been created by a call to startElement(), that element will be closed first.

Parameters
comment:Object

Text content of the comment

Exceptions
IOException:
if an input/output error occurs
NullPointerException:
if comment is null
writeDoctypeback to summary
public void writeDoctype(String doctype) throws IOException

Write a string containing the markup specific doctype. No escaping is performed. The default implementation simply calls through to write(java.lang.String) .

The implementation makes no checks if this is the correct place in the response to have a doctype, nor does it prevent the doctype from being written more than once.

Parameters
doctype:String

Text content of the doctype

Exceptions
IOException:
if an input/output error occurs
Since
2.2
writePreambleback to summary
public void writePreamble(String preamble) throws IOException

Write a string containing the markup specific preamble. No escaping is performed. The default implementation simply calls through to write(java.lang.String) .

The implementation makes no checks if this is the correct place in the response to have a preamble, nor does it prevent the preamble from being written more than once.

Parameters
preamble:String

Text content of the preamble

Exceptions
IOException:
if an input/output error occurs
Since
2.2
writeTextback to summary
public abstract void writeText(Object text, String property) throws IOException

Write an object, after converting it to a String (if necessary), and after performing any escaping appropriate for the markup language being rendered. If there is an open element that has been created by a call to startElement(), that element will be closed first.

Parameters
text:Object

Text to be written

property:String

Name of the property or attribute (if any) of the UIComponent associated with the containing element, to which this generated text corresponds

Exceptions
IOException:
if an input/output error occurs
NullPointerException:
if text is null
writeTextback to summary
public void writeText(Object text, UIComponent component, String property) throws IOException

Write an object, after converting it to a String (if necessary), and after performing any escaping appropriate for the markup language being rendered. This method is equivalent to writeText(java.lang.Object, java.lang.String) but adds a component property to allow custom ResponseWriter implementations to associate a component with an arbitrary portion of text.

The default implementation simply ignores the component argument and calls through to writeText(java.lang.Object, java.lang.String)

Parameters
text:Object

Text to be written

component:UIComponent

The UIComponent (if any) to which this element corresponds

property:String

Name of the property or attribute (if any) of the UIComponent associated with the containing element, to which this generated text corresponds

Exceptions
IOException:
if an input/output error occurs
NullPointerException:
if text is null
Since
1.2
writeTextback to summary
public abstract void writeText(char[] text, int off, int len) throws IOException

Write text from a character array, after any performing any escaping appropriate for the markup language being rendered. If there is an open element that has been created by a call to startElement(), that element will be closed first.

Parameters
text:char[]

Text to be written

off:int

Starting offset (zero-relative)

len:int

Number of characters to be written

Exceptions
IOException:
if an input/output error occurs
IndexOutOfBoundsException:
if the calculated starting or ending position is outside the bounds of the character array
NullPointerException:
if text is null
writeURIAttributeback to summary
public abstract void writeURIAttribute(String name, Object value, String property) throws IOException

Write a URI attribute name and corresponding value, after converting that text to a String (if necessary), and after performing any encoding or escaping appropriate to the markup language being rendered. When rendering in a WWW environment, the escaping conventions established in the W3C URI spec document <http://www.w3.org/Addressing/URL/uri-spec.html> must be followed. In particular, spaces ' ' must be encoded as %20 and not the plus character '+'. This method may only be called after a call to startElement(), and before the opened element has been closed.

Parameters
name:String

Attribute name to be added

value:Object

Attribute value to be added

property:String

Name of the property or attribute (if any) of the UIComponent associated with the containing element, to which this generated attribute corresponds

Exceptions
IOException:
if an input/output error occurs
IllegalStateException:
if this method is called when there is no currently open element
NullPointerException:
if name is null