org.apache.myfaces.context
Class PartialResponseWriterImpl
java.lang.Object
java.io.Writer
javax.faces.context.ResponseWriter
javax.faces.context.ResponseWriterWrapper
javax.faces.context.PartialResponseWriter
org.apache.myfaces.context.PartialResponseWriterImpl
- All Implemented Interfaces:
- java.io.Closeable, java.io.Flushable, java.lang.Appendable, javax.faces.FacesWrapper<javax.faces.context.ResponseWriter>
public class PartialResponseWriterImpl
- extends javax.faces.context.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 // sections
What we do for now is to simply remove //
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!
- Version:
- $Revision$ $Date$
- Author:
- Werner Punz (latest modification by $Author$)
Fields inherited from class javax.faces.context.PartialResponseWriter |
RENDER_ALL_MARKER, VIEW_STATE_MARKER |
Fields inherited from class java.io.Writer |
lock |
Method Summary |
java.io.Writer |
append(char c)
|
java.io.Writer |
append(java.lang.CharSequence csq)
|
java.io.Writer |
append(java.lang.CharSequence csq,
int start,
int end)
|
javax.faces.context.ResponseWriter |
cloneWithWriter(java.io.Writer writer)
|
void |
close()
|
void |
endCDATA()
|
void |
endElement(java.lang.String name)
|
void |
endError()
|
void |
endEval()
|
void |
endExtension()
|
void |
endInsert()
|
void |
endUpdate()
|
void |
flush()
|
void |
startCDATA()
|
void |
startElement(java.lang.String name,
javax.faces.component.UIComponent component)
|
void |
write(char[] cbuf)
|
void |
write(char[] cbuf,
int off,
int len)
|
void |
write(int c)
|
void |
write(java.lang.String str)
|
void |
write(java.lang.String str,
int off,
int len)
|
void |
writeAttribute(java.lang.String name,
java.lang.Object value,
java.lang.String property)
|
void |
writeComment(java.lang.Object comment)
|
void |
writeText(char[] text,
int off,
int len)
|
void |
writeText(java.lang.Object text,
java.lang.String property)
|
void |
writeText(java.lang.Object object,
javax.faces.component.UIComponent component,
java.lang.String string)
|
void |
writeURIAttribute(java.lang.String name,
java.lang.Object value,
java.lang.String property)
|
Methods inherited from class javax.faces.context.PartialResponseWriter |
delete, endDocument, getWrapped, redirect, startDocument, startError, startEval, startExtension, startInsertAfter, startInsertBefore, startUpdate, updateAttributes |
Methods inherited from class javax.faces.context.ResponseWriterWrapper |
getCharacterEncoding, getContentType |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PartialResponseWriterImpl
public PartialResponseWriterImpl(javax.faces.context.ResponseWriter writer)
startCDATA
public void startCDATA()
throws java.io.IOException
- Overrides:
startCDATA
in class javax.faces.context.PartialResponseWriter
- Throws:
java.io.IOException
endCDATA
public void endCDATA()
throws java.io.IOException
- Overrides:
endCDATA
in class javax.faces.context.PartialResponseWriter
- Throws:
java.io.IOException
endInsert
public void endInsert()
throws java.io.IOException
- Overrides:
endInsert
in class javax.faces.context.PartialResponseWriter
- Throws:
java.io.IOException
endUpdate
public void endUpdate()
throws java.io.IOException
- Overrides:
endUpdate
in class javax.faces.context.PartialResponseWriter
- Throws:
java.io.IOException
endExtension
public void endExtension()
throws java.io.IOException
- Overrides:
endExtension
in class javax.faces.context.PartialResponseWriter
- Throws:
java.io.IOException
endEval
public void endEval()
throws java.io.IOException
- Overrides:
endEval
in class javax.faces.context.PartialResponseWriter
- Throws:
java.io.IOException
endError
public void endError()
throws java.io.IOException
- Overrides:
endError
in class javax.faces.context.PartialResponseWriter
- Throws:
java.io.IOException
endElement
public void endElement(java.lang.String name)
throws java.io.IOException
- Overrides:
endElement
in class javax.faces.context.ResponseWriterWrapper
- Throws:
java.io.IOException
writeComment
public void writeComment(java.lang.Object comment)
throws java.io.IOException
- Overrides:
writeComment
in class javax.faces.context.ResponseWriterWrapper
- Throws:
java.io.IOException
startElement
public void startElement(java.lang.String name,
javax.faces.component.UIComponent component)
throws java.io.IOException
- Overrides:
startElement
in class javax.faces.context.ResponseWriterWrapper
- Throws:
java.io.IOException
writeText
public void writeText(java.lang.Object text,
java.lang.String property)
throws java.io.IOException
- Overrides:
writeText
in class javax.faces.context.ResponseWriterWrapper
- Throws:
java.io.IOException
writeText
public void writeText(char[] text,
int off,
int len)
throws java.io.IOException
- Overrides:
writeText
in class javax.faces.context.ResponseWriterWrapper
- Throws:
java.io.IOException
write
public void write(char[] cbuf,
int off,
int len)
throws java.io.IOException
- Overrides:
write
in class javax.faces.context.ResponseWriterWrapper
- Throws:
java.io.IOException
cloneWithWriter
public javax.faces.context.ResponseWriter cloneWithWriter(java.io.Writer writer)
- Overrides:
cloneWithWriter
in class javax.faces.context.ResponseWriterWrapper
writeURIAttribute
public void writeURIAttribute(java.lang.String name,
java.lang.Object value,
java.lang.String property)
throws java.io.IOException
- Overrides:
writeURIAttribute
in class javax.faces.context.ResponseWriterWrapper
- Throws:
java.io.IOException
close
public void close()
throws java.io.IOException
- Specified by:
close
in interface java.io.Closeable
- Overrides:
close
in class javax.faces.context.ResponseWriterWrapper
- Throws:
java.io.IOException
flush
public void flush()
throws java.io.IOException
- Specified by:
flush
in interface java.io.Flushable
- Overrides:
flush
in class javax.faces.context.ResponseWriterWrapper
- Throws:
java.io.IOException
writeAttribute
public void writeAttribute(java.lang.String name,
java.lang.Object value,
java.lang.String property)
throws java.io.IOException
- Overrides:
writeAttribute
in class javax.faces.context.ResponseWriterWrapper
- Throws:
java.io.IOException
writeText
public void writeText(java.lang.Object object,
javax.faces.component.UIComponent component,
java.lang.String string)
throws java.io.IOException
- Overrides:
writeText
in class javax.faces.context.ResponseWriterWrapper
- Throws:
java.io.IOException
append
public java.io.Writer append(char c)
throws java.io.IOException
- Specified by:
append
in interface java.lang.Appendable
- Overrides:
append
in class java.io.Writer
- Throws:
java.io.IOException
append
public java.io.Writer append(java.lang.CharSequence csq,
int start,
int end)
throws java.io.IOException
- Specified by:
append
in interface java.lang.Appendable
- Overrides:
append
in class java.io.Writer
- Throws:
java.io.IOException
append
public java.io.Writer append(java.lang.CharSequence csq)
throws java.io.IOException
- Specified by:
append
in interface java.lang.Appendable
- Overrides:
append
in class java.io.Writer
- Throws:
java.io.IOException
write
public void write(char[] cbuf)
throws java.io.IOException
- Overrides:
write
in class java.io.Writer
- Throws:
java.io.IOException
write
public void write(int c)
throws java.io.IOException
- Overrides:
write
in class java.io.Writer
- Throws:
java.io.IOException
write
public void write(java.lang.String str,
int off,
int len)
throws java.io.IOException
- Overrides:
write
in class java.io.Writer
- Throws:
java.io.IOException
write
public void write(java.lang.String str)
throws java.io.IOException
- Overrides:
write
in class java.io.Writer
- Throws:
java.io.IOException
Copyright © 2011 The Apache Software Foundation. All Rights Reserved.