com.liferay.faces.bridge.renderkit.bridge
Class ResponseWriterBridgeImpl

java.lang.Object
  extended by java.io.Writer
      extended by javax.faces.context.ResponseWriter
          extended by javax.faces.context.ResponseWriterWrapper
              extended by com.liferay.faces.bridge.renderkit.bridge.ResponseWriterBridgeCompat_2_0_Impl
                  extended by com.liferay.faces.bridge.renderkit.bridge.ResponseWriterBridgeCompat_2_2_Impl
                      extended by com.liferay.faces.bridge.renderkit.bridge.ResponseWriterBridgeImpl
All Implemented Interfaces:
Closeable, Flushable, Appendable, javax.faces.FacesWrapper<javax.faces.context.ResponseWriter>

public class ResponseWriterBridgeImpl
extends ResponseWriterBridgeCompat_2_2_Impl

This class acts as a portlet filter (in a sense), in that it decorates/wraps the Faces implementation ResponseWriter so that it can transform what is written to the response. The response needs to be filtered because of three limitations in the JSF 2.0/2.1/2.2 jsf.js JavaScript code). The goal is to fix these limitations in JSF 2.3 so that this class will become unnecessary. For more information, see: JAVASERVERFACES-2579

The three limitations in the jsf.js JavaScript code are:

1. The <?xml version="1.0" encoding="UTF-8"?> and <!DOCTYPE> markers is assumed to be valid to keep in the response because jsf.js assumes a servlet environment in which the rendered JSF view takes up the entire DOM in the userAgent/browser.

The workaround for #1 is to simply strip out the offending markers.

2. During "partial" updates in which the javax.faces.ViewRoot is being replaced in the DOM (which is basically a full update of the view -- not really partial), jsf.js attempts to replace everything inside the <body>...</body> elements, which of course is a servlet environment assumption. Instead, it should be the outermost <div> tag rendered by the bridge's BodyRendererBridgeImpl that should be replaced in the DOM.

The workaround for #2 is to substitute the id value of "javax.faces.ViewRoot" with the id of the outermost <div> tag rendered by the bridge's BodyRendererBridgeImpl.

3. Also in the the case of a "partial" update of javax.faces.ViewRoot, jsf.js attempts to dynamically create the javax.faces.ViewState hidden input field if it is not found in the form. The JavaScript code will successfully do this provided it is permitted to replace everything inside the <body>...</body> elements, but since we can't let that happen in a portlet environment, the hidden field does not get created.

The workaround for #3 is to inject the javax.faces.ViewState hidden field into the response if it is not already there.

Author:
Neil Griffin

Field Summary
 
Fields inherited from class com.liferay.faces.bridge.renderkit.bridge.ResponseWriterBridgeCompat_2_2_Impl
CLIENT_WINDOW_PARAM
 
Fields inherited from class com.liferay.faces.bridge.renderkit.bridge.ResponseWriterBridgeCompat_2_0_Impl
ATTRIBUTE_AUTOCOMPLETE, ATTRIBUTE_ID, ATTRIBUTE_NAME, ATTRIBUTE_TYPE, ATTRIBUTE_VALUE, DOCTYPE_MARKER, ELEMENT_INPUT, namespacedParameters, TYPE_HIDDEN, VALUE_OFF, VIEW_STATE_MARKER, XML_MARKER
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
ResponseWriterBridgeImpl(javax.faces.context.ResponseWriter wrappedResponseWriter)
           
 
Method Summary
 javax.faces.context.ResponseWriter cloneWithWriter(Writer writer)
           
 void endCDATA()
           
 void endElement(String elementName)
           
 javax.faces.context.ResponseWriter getWrapped()
           
 void startCDATA()
           
 void startElement(String elementName, javax.faces.component.UIComponent uiComponent)
           
 void writeAttribute(String attributeName, Object attributeValue, String property)
           
 
Methods inherited from class com.liferay.faces.bridge.renderkit.bridge.ResponseWriterBridgeCompat_2_2_Impl
writeClientWindowHiddenField, writePreamble
 
Methods inherited from class com.liferay.faces.bridge.renderkit.bridge.ResponseWriterBridgeCompat_2_0_Impl
write, writeViewStateHiddenField
 
Methods inherited from class javax.faces.context.ResponseWriterWrapper
close, endDocument, flush, getCharacterEncoding, getContentType, startDocument, writeComment, writeText, writeText, writeText, writeURIAttribute
 
Methods inherited from class java.io.Writer
append, append, append, write, write, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResponseWriterBridgeImpl

public ResponseWriterBridgeImpl(javax.faces.context.ResponseWriter wrappedResponseWriter)
Method Detail

cloneWithWriter

public javax.faces.context.ResponseWriter cloneWithWriter(Writer writer)
Overrides:
cloneWithWriter in class javax.faces.context.ResponseWriterWrapper

endCDATA

public void endCDATA()
              throws IOException
Overrides:
endCDATA in class javax.faces.context.ResponseWriterWrapper
Throws:
IOException

endElement

public void endElement(String elementName)
                throws IOException
Overrides:
endElement in class javax.faces.context.ResponseWriterWrapper
Throws:
IOException

startCDATA

public void startCDATA()
                throws IOException
Overrides:
startCDATA in class javax.faces.context.ResponseWriterWrapper
Throws:
IOException

startElement

public void startElement(String elementName,
                         javax.faces.component.UIComponent uiComponent)
                  throws IOException
Overrides:
startElement in class javax.faces.context.ResponseWriterWrapper
Throws:
IOException

writeAttribute

public void writeAttribute(String attributeName,
                           Object attributeValue,
                           String property)
                    throws IOException
Overrides:
writeAttribute in class javax.faces.context.ResponseWriterWrapper
Throws:
IOException

getWrapped

public javax.faces.context.ResponseWriter getWrapped()
Specified by:
getWrapped in interface javax.faces.FacesWrapper<javax.faces.context.ResponseWriter>
Overrides:
getWrapped in class javax.faces.context.ResponseWriterWrapper


Copyright © 2014 Liferay, Inc.. All Rights Reserved.