Reputation: 15110
I was doing some testing and i realized that the writer doesn't get automatically flushed i.e i dont see any response on the client side until all the components have been rendered?
I also tried manually flushing the response writer but it didn't make any difference. Is there a way to allow manual flushes so that the response becomes available to the client earlier?
Thanks
Upvotes: 2
Views: 1015
Reputation: 1109192
Perhaps you used the wrong writer or called flush at the wrong moment or misinterpreted the results (i.e. behaviour is browser/CSS/JS specific). The following test case works for me with Mojarra 2.1.3.
<h:outputText value="#{bean.text}" escape="false" />
<h:outputText value="#{bean.text}" escape="false" />
<h:outputText value="#{bean.text}" escape="false" />
<h:outputText value="#{bean.text}" escape="false" />
<h:outputText value="#{bean.text}" escape="false" />
<h:outputText value="#{bean.text}" escape="false" />
<h:outputText value="#{bean.text}" escape="false" />
<h:outputText value="#{bean.text}" escape="false" />
<h:outputText value="#{bean.text}" escape="false" />
<h:outputText value="#{bean.text}" escape="false" />
with
public String getText() throws Exception {
FacesContext.getCurrentInstance().getExternalContext().responseFlushBuffer();
Thread.sleep(250);
return "<br />a line of text";
}
You see them in browser clearly appearing line by line instead of all at once.
Please note that the above approach is not really recommended. You can finetune the response buffer size with the context param javax.faces.FACELETS_BUFFER_SIZE
.
<context-param>
<!-- Flush every 128 bytes (default is 1024) -->
<param-name>javax.faces.FACELETS_BUFFER_SIZE</param-name>
<param-value>128</param-value>
</context-param>
Upvotes: 3