1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.myfaces.renderkit.html; |
20 | |
|
21 | |
import java.io.IOException; |
22 | |
import java.io.Writer; |
23 | |
import javax.faces.FacesException; |
24 | |
import javax.faces.component.UIComponent; |
25 | |
import javax.faces.context.FacesContext; |
26 | |
import javax.faces.context.ResponseWriter; |
27 | |
import org.apache.myfaces.shared.renderkit.html.HTML; |
28 | |
import org.apache.myfaces.shared.renderkit.html.HtmlResponseWriterImpl; |
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
public class EarlyFlushHtmlResponseWriterImpl extends HtmlResponseWriterImpl |
38 | |
{ |
39 | |
|
40 | |
|
41 | |
|
42 | |
private boolean _endHeadTag; |
43 | |
|
44 | |
public EarlyFlushHtmlResponseWriterImpl(Writer writer, String contentType, String characterEncoding) |
45 | |
{ |
46 | 0 | super(writer, contentType, characterEncoding); |
47 | 0 | } |
48 | |
|
49 | |
public EarlyFlushHtmlResponseWriterImpl(Writer writer, String contentType, String characterEncoding, |
50 | |
boolean wrapScriptContentWithXmlCommentTag) |
51 | |
{ |
52 | 0 | super(writer, contentType, characterEncoding, wrapScriptContentWithXmlCommentTag); |
53 | 0 | } |
54 | |
|
55 | |
public EarlyFlushHtmlResponseWriterImpl(Writer writer, String contentType, String characterEncoding, |
56 | |
boolean wrapScriptContentWithXmlCommentTag, String writerContentTypeMode) throws FacesException |
57 | |
{ |
58 | 0 | super(writer, contentType, characterEncoding, wrapScriptContentWithXmlCommentTag, writerContentTypeMode); |
59 | 0 | } |
60 | |
|
61 | |
@Override |
62 | |
public ResponseWriter cloneWithWriter(Writer writer) |
63 | |
{ |
64 | 0 | EarlyFlushHtmlResponseWriterImpl newWriter |
65 | |
= new EarlyFlushHtmlResponseWriterImpl(writer, getContentType(), getCharacterEncoding(), |
66 | |
getWrapScriptContentWithXmlCommentTag(), getWriterContentTypeMode()); |
67 | 0 | return newWriter; |
68 | |
} |
69 | |
|
70 | |
@Override |
71 | |
public void startElement(String name, UIComponent uiComponent) throws IOException |
72 | |
{ |
73 | 0 | _endHeadTag = false; |
74 | 0 | super.startElement(name, uiComponent); |
75 | 0 | } |
76 | |
|
77 | |
@Override |
78 | |
public void endElement(String name) throws IOException |
79 | |
{ |
80 | 0 | super.endElement(name); |
81 | 0 | if (HTML.HEAD_ELEM.equalsIgnoreCase(name)) |
82 | |
{ |
83 | 0 | _endHeadTag = true; |
84 | |
} |
85 | 0 | } |
86 | |
|
87 | |
@Override |
88 | |
public void flush() throws IOException |
89 | |
{ |
90 | 0 | super.flush(); |
91 | |
|
92 | 0 | if (_endHeadTag) |
93 | |
{ |
94 | 0 | FacesContext facesContext = getFacesContext(); |
95 | 0 | if (!facesContext.getPartialViewContext().isAjaxRequest() && |
96 | |
!facesContext.getPartialViewContext().isPartialRequest()) |
97 | |
{ |
98 | 0 | forceFlush(); |
99 | |
} |
100 | |
} |
101 | 0 | } |
102 | |
} |