public class PartialResponseWriterImpl extends PartialResponseWriter
Double buffering partial response writer to take care if embedded CDATA blocks in update delete etc...
According to the spec 13.4.4.1 Writing The Partial Response implementations have to take care to handle nested cdata blocks properly
This means we cannot allow nested CDATA according to the xml spec http://www.w3.org/TR/REC-xml/#sec-cdata-sect everything within a CDATA block is unparsed except for ]]>
Now we have following problem, that CDATA inserts can happen everywhere not only within the CDATA instructions.
What we have to do now is to double buffer CDATA blocks until their end and also!!! parse their content for CDATA embedding and replace it with an escaped end sequence.
Now parsing CDATA embedding is a little bit problematic in case of PPR because it can happen that someone simply adds a CDATA in a javascript string or somewhere else. Because he/she is not aware that we wrap the entire content into CDATA. Simply encoding and decoding of the CDATA is similarly problematic because the browser then chokes on embedded //<![CDATA[ //]]> sections
What we do for now is to simply remove //<![CDATA[ and //]]> and replace all other pending cdatas with their cdata escapes ]]> becomes <![CDATA[]]]]><![CDATA[>
If this causes problems in corner cases we also can add a second encoding step in case of the cdata Javascript comment removal is not enough to cover all corner cases.
For now I will only implement this in the impl, due to the spec stating that implementations are responsible of the correct CDATA handling!
RENDER_ALL_MARKER, VIEW_STATE_MARKER| Constructor and Description |
|---|
PartialResponseWriterImpl(ResponseWriter writer) |
| Modifier and Type | Method and Description |
|---|---|
Writer |
append(char c) |
Writer |
append(CharSequence csq) |
Writer |
append(CharSequence csq,
int start,
int end) |
ResponseWriter |
cloneWithWriter(Writer writer) |
void |
close() |
void |
endCDATA() |
void |
endElement(String name) |
void |
endError() |
void |
endEval() |
void |
endExtension() |
void |
endInsert() |
void |
endUpdate() |
void |
flush() |
void |
startCDATA() |
void |
startElement(String name,
UIComponent component) |
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 property) |
void |
writeComment(Object comment) |
void |
writeText(char[] text,
int off,
int len) |
void |
writeText(Object text,
String property) |
void |
writeText(Object object,
UIComponent component,
String string) |
void |
writeURIAttribute(String name,
Object value,
String property) |
delete, endDocument, redirect, startDocument, startError, startEval, startExtension, startInsertAfter, startInsertBefore, startUpdate, updateAttributesgetCharacterEncoding, getContentType, getWrapped, writeDoctype, writePreamblepublic PartialResponseWriterImpl(ResponseWriter writer)
public void startCDATA()
throws IOException
startCDATA in class ResponseWriterWrapperIOExceptionpublic void endCDATA()
throws IOException
endCDATA in class ResponseWriterWrapperIOExceptionpublic void endInsert()
throws IOException
endInsert in class PartialResponseWriterIOExceptionpublic void endUpdate()
throws IOException
endUpdate in class PartialResponseWriterIOExceptionpublic void endExtension()
throws IOException
endExtension in class PartialResponseWriterIOExceptionpublic void endEval()
throws IOException
endEval in class PartialResponseWriterIOExceptionpublic void endError()
throws IOException
endError in class PartialResponseWriterIOExceptionpublic void endElement(String name) throws IOException
endElement in class ResponseWriterWrapperIOExceptionpublic void writeComment(Object comment) throws IOException
writeComment in class ResponseWriterWrapperIOExceptionpublic void startElement(String name, UIComponent component) throws IOException
startElement in class ResponseWriterWrapperIOExceptionpublic void writeText(Object text, String property) throws IOException
writeText in class ResponseWriterWrapperIOExceptionpublic void writeText(char[] text,
int off,
int len)
throws IOException
writeText in class ResponseWriterWrapperIOExceptionpublic void write(char[] cbuf,
int off,
int len)
throws IOException
write in class ResponseWriterWrapperIOExceptionpublic ResponseWriter cloneWithWriter(Writer writer)
cloneWithWriter in class ResponseWriterWrapperpublic void writeURIAttribute(String name, Object value, String property) throws IOException
writeURIAttribute in class ResponseWriterWrapperIOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class ResponseWriterWrapperIOExceptionpublic void flush()
throws IOException
flush in interface Flushableflush in class ResponseWriterWrapperIOExceptionpublic void writeAttribute(String name, Object value, String property) throws IOException
writeAttribute in class ResponseWriterWrapperIOExceptionpublic void writeText(Object object, UIComponent component, String string) throws IOException
writeText in class ResponseWriterWrapperIOExceptionpublic Writer append(char c) throws IOException
append in interface Appendableappend in class WriterIOExceptionpublic Writer append(CharSequence csq, int start, int end) throws IOException
append in interface Appendableappend in class WriterIOExceptionpublic Writer append(CharSequence csq) throws IOException
append in interface Appendableappend in class WriterIOExceptionpublic void write(char[] cbuf)
throws IOException
write in class WriterIOExceptionpublic void write(int c)
throws IOException
write in class WriterIOExceptionpublic void write(String str, int off, int len) throws IOException
write in class WriterIOExceptionpublic void write(String str) throws IOException
write in class WriterIOExceptionCopyright © 2022 The Apache Software Foundation. All rights reserved.