public class HtmlResponseWriter
extends jakarta.faces.context.ResponseWriter
HtmlResponseWriter is an Html specific implementation of the ResponseWriter abstract
class. Kudos to Adam Winer (Oracle) for much of this code.
| Constructor and Description |
|---|
HtmlResponseWriter(Writer writer,
String contentType,
String encoding)
Constructor sets the
ResponseWriter and encoding, and enables script hiding by default. |
HtmlResponseWriter(Writer writer,
String contentType,
String encoding,
Boolean isScriptHidingEnabled,
Boolean isScriptInAttributeValueEnabled,
WebConfiguration.DisableUnicodeEscaping disableUnicodeEscaping,
boolean isPartial)
Constructor sets the
ResponseWriter and encoding. |
| Modifier and Type | Method and Description |
|---|---|
jakarta.faces.context.ResponseWriter |
cloneWithWriter(Writer writer)
Create a new instance of this
ResponseWriter using a different Writer. |
void |
close()
Methods From
java.io.Writer |
void |
endCDATA()
Closes the CDATA block.
|
void |
endDocument()
Output the text for the end of a document.
|
void |
endElement(String name)
Write the end of an element.
|
void |
flush()
Flush any buffered output to the contained writer.
|
String |
getCharacterEncoding()
Return the character encoding (such as "ISO-8859-1") for this
ResponseWriter. |
String |
getContentType()
Return the content type (such as "text/html") for this
ResponseWriter. |
void |
startCDATA()
Starts a CDATA block.
|
void |
startDocument()
Write the text that should begin a response.
|
void |
startElement(String name,
jakarta.faces.component.UIComponent componentForElement)
Write the start of an element, up to and including the element name.
|
void |
write(char[] cbuf) |
void |
write(char[] cbuf,
int off,
int len) |
void |
write(int c) |
void |
write(String str) |
void |
write(String str,
int off,
int len) |
void |
writeAttribute(String name,
Object value,
String componentPropertyName)
Write a properly escaped attribute name and the corresponding value.
|
void |
writeComment(Object comment)
Write a comment string containing the specified text.
|
void |
writeText(char text)
Write a properly escaped single character, If there is an open element that has been created by a call to
startElement(), that element will be closed first. |
void |
writeText(char[] text)
Write properly escaped text from a character array.
|
void |
writeText(char[] text,
int off,
int len)
Write properly escaped text from a character array.
|
void |
writeText(Object text,
String componentPropertyName)
Write a properly escaped object.
|
void |
writeURIAttribute(String name,
Object value,
String componentPropertyName)
Write a properly encoded URI attribute name and the corresponding value.
|
public HtmlResponseWriter(Writer writer, String contentType, String encoding) throws jakarta.faces.FacesException
ResponseWriter and encoding, and enables script hiding by default.writer - the ResponseWritercontentType - the content type.encoding - the character encoding.jakarta.faces.FacesException - the encoding is not recognized.public HtmlResponseWriter(Writer writer, String contentType, String encoding, Boolean isScriptHidingEnabled, Boolean isScriptInAttributeValueEnabled, WebConfiguration.DisableUnicodeEscaping disableUnicodeEscaping, boolean isPartial) throws jakarta.faces.FacesException
Constructor sets the ResponseWriter and encoding.
The argument configPrefs is a map of configurable prefs that affect this instance's behavior. Supported keys are:
BooleanWebContextInitParameter.EnableJSStyleHiding: true if the writer should attempt to hide JS from
older browsers
writer - the ResponseWritercontentType - the content type.encoding - the character encoding.jakarta.faces.FacesException - the encoding is not recognized.public void close()
throws IOException
java.io.Writerclose in interface Closeableclose in interface AutoCloseableclose in class WriterIOExceptionpublic void flush()
throws IOException
flush in interface Flushableflush in class jakarta.faces.context.ResponseWriterIOException - if an input/output error occurs.public String getContentType()
jakarta.faces.context.ResponseWriter
Return the content type (such as "text/html") for this ResponseWriter. Note: this must not include the
"charset=" suffix.
getContentType in class jakarta.faces.context.ResponseWriterpublic jakarta.faces.context.ResponseWriter cloneWithWriter(Writer writer)
Create a new instance of this ResponseWriter using a different Writer.
cloneWithWriter in class jakarta.faces.context.ResponseWriterwriter - The Writer that will be used to create another ResponseWriter.ResponseWriterpublic void endDocument()
throws IOException
endDocument in class jakarta.faces.context.ResponseWriterIOException - if an input/output error occurspublic void endElement(String name) throws IOException
Write the end of an element. This method will first close any open element created by a call to
startElement().
endElement in class jakarta.faces.context.ResponseWritername - Name of the element to be endedIOException - if an input/output error occursNullPointerException - if name is nullpublic String getCharacterEncoding()
jakarta.faces.context.ResponseWriter
Return the character encoding (such as "ISO-8859-1") for this ResponseWriter. Please see
the IANA for a list of character encodings.
getCharacterEncoding in class jakarta.faces.context.ResponseWriterpublic void startDocument()
throws IOException
Write the text that should begin a response.
startDocument in class jakarta.faces.context.ResponseWriterIOException - if an input/output error occurspublic void startElement(String name, jakarta.faces.component.UIComponent componentForElement) throws IOException
Write the start of an element, up to and including the element name. Clients call writeAttribute() or
writeURIAttribute() methods to add attributes after calling this method.
startElement in class jakarta.faces.context.ResponseWritername - Name of the starting elementcomponentForElement - The UIComponent instance that applies to this element. This argument may be
null.IOException - if an input/output error occursNullPointerException - if name is nullpublic void startCDATA()
throws IOException
startCDATA in class jakarta.faces.context.ResponseWriterIOException - on a read/write errorIllegalStateException - If startCDATA is called a second time before endCDATA.public void endCDATA()
throws IOException
endCDATA in class jakarta.faces.context.ResponseWriterIOExceptionpublic void write(char[] cbuf)
throws IOException
write in class WriterIOExceptionpublic void write(int c)
throws IOException
write in class WriterIOExceptionpublic void write(String str) throws IOException
write in class WriterIOExceptionpublic void write(char[] cbuf,
int off,
int len)
throws IOException
write in class WriterIOExceptionpublic void write(String str, int off, int len) throws IOException
write in class WriterIOExceptionpublic void writeAttribute(String name, Object value, String componentPropertyName) throws IOException
Write a properly escaped attribute name and the corresponding value. The value text will be converted to a String if
necessary. This method may only be called after a call to startElement(), and before the opened element
has been closed.
writeAttribute in class jakarta.faces.context.ResponseWritername - Attribute name to be addedvalue - Attribute value to be addedcomponentPropertyName - The name of the component property to which this attribute argument applies. This
argument may be null.IllegalStateException - if this method is called when there is no currently open elementIOException - if an input/output error occursNullPointerException - if name is nullpublic void writeComment(Object comment) throws IOException
Write a comment string containing the specified text. The text will be converted to a String if necessary. If there
is an open element that has been created by a call to startElement(), that element will be closed first.
writeComment in class jakarta.faces.context.ResponseWritercomment - Text content of the commentIOException - if an input/output error occursNullPointerException - if comment is nullpublic void writeText(char text)
throws IOException
Write a properly escaped single character, If there is an open element that has been created by a call to
startElement(), that element will be closed first.
All angle bracket occurrences in the argument must be escaped using the > < syntax.
text - Text to be writtenIOException - if an input/output error occurspublic void writeText(char[] text)
throws IOException
Write properly escaped text from a character array. The output from this command is identical to the invocation:
writeText(c, 0, c.length). If there is an open element that has been created by a call to
startElement(), that element will be closed first.
All angle bracket occurrences in the argument must be escaped using the > < syntax.
text - Text to be writtenIOException - if an input/output error occursNullPointerException - if text is nullpublic void writeText(Object text, String componentPropertyName) throws IOException
Write a properly escaped object. The object will be converted to a String if necessary. If there is an open element
that has been created by a call to startElement(), that element will be closed first.
writeText in class jakarta.faces.context.ResponseWritertext - Text to be writtencomponentPropertyName - The name of the component property to which this text argument applies. This argument
may be null.IOException - if an input/output error occursNullPointerException - if text is nullpublic void writeText(char[] text,
int off,
int len)
throws IOException
Write properly escaped text from a character array. If there is an open element that has been created by a call to
startElement(), that element will be closed first.
All angle bracket occurrences in the argument must be escaped using the > < syntax.
writeText in class jakarta.faces.context.ResponseWritertext - Text to be writtenoff - Starting offset (zero-relative)len - Number of characters to be writtenIndexOutOfBoundsException - if the calculated starting or ending position is outside the bounds of the
character arrayIOException - if an input/output error occursNullPointerException - if text is nullpublic void writeURIAttribute(String name, Object value, String componentPropertyName) throws IOException
Write a properly encoded URI attribute name and the corresponding value. The value text will be converted to a String
if necessary). This method may only be called after a call to startElement(), and before the opened
element has been closed.
writeURIAttribute in class jakarta.faces.context.ResponseWritername - Attribute name to be addedvalue - Attribute value to be addedcomponentPropertyName - The name of the component property to which this attribute argument applies. This
argument may be null.IllegalStateException - if this method is called when there is no currently open elementIOException - if an input/output error occursNullPointerException - if name or value is nullCopyright © 2010–2022 JBoss by Red Hat. All rights reserved.