本文整理匯總了Java中javax.faces.context.ExternalContext.setResponseContentType方法的典型用法代碼示例。如果您正苦於以下問題:Java ExternalContext.setResponseContentType方法的具體用法?Java ExternalContext.setResponseContentType怎麽用?Java ExternalContext.setResponseContentType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.faces.context.ExternalContext
的用法示例。
在下文中一共展示了ExternalContext.setResponseContentType方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: _getResponseWriter
import javax.faces.context.ExternalContext; //導入方法依賴的package包/類
private static ResponseWriter _getResponseWriter(FacesContext context)
throws IOException
{
ExternalContext external = context.getExternalContext();
String contentType = "text/html";
String encoding = "UTF-8";
external.setResponseContentType(contentType);
external.setResponseCharacterEncoding(encoding);
ResponseWriter rw = context.getRenderKit().createResponseWriter(
external.getResponseOutputWriter(),
contentType,
encoding);
context.setResponseWriter(rw);
return rw;
}
示例2: _processRender
import javax.faces.context.ExternalContext; //導入方法依賴的package包/類
private void _processRender(UIComponent viewRoot)
{
ExternalContext extContext = _context.getExternalContext();
extContext.setResponseContentType(_RESPONSE_CONTENT_TYPE);
extContext.addResponseHeader("Pragma", "no-cache");
extContext.addResponseHeader("Cache-control", "no-cache");
if (isRenderAll())
{
_renderAll(_context, viewRoot);
return;
}
ResponseWriter origResponseWriter = _context.getResponseWriter();
RenderingContext rc = RenderingContext.getCurrentInstance();
assert (rc != null);
boolean bufferScripts = _requestType == ReqType.LEGACY || _requestType == ReqType.AJAX_LEGACY;
PPRResponseWriter pprWriter =
new PPRResponseWriter(origResponseWriter, rc, bufferScripts);
_context.setResponseWriter(pprWriter);
if (_requestType == ReqType.AJAX)
{
// Add render Ids as partial targets for the request from <f:ajax>
_addRenderIdsAsPartialTargets(rc);
// Force visit-based rendering for the <f:ajax> requests
PartialPageUtils.forceOptimizedPPR(_context);
}
try
{
pprWriter.startDocument();
// Note that PanelPartialRootRenderer will perform partial visit for the optimized PPR
// if it is enabled
_renderChildren(_context, viewRoot);
// PDA's JavaScript DOM is not capable of updating the ViewState just by
// using ViewState's value, so for PDAs, FormRenderer will again render
// the ViewState as a hidden element during its postscript element rendering
if (!CoreRenderer.isPDA(rc))
{
// Always write out ViewState as a separate update element.
String state =
_context.getApplication().getStateManager().getViewState(_context);
pprWriter.writeViewState(state);
}
pprWriter.endDocument();
}
catch (IOException e)
{
// launder the IOException as a FacesException, we'll unwrap this later
throw new FacesException(e);
}
finally
{
_context.setResponseWriter(origResponseWriter);
}
}