當前位置: 首頁>>代碼示例>>Java>>正文


Java ExternalContext.setResponseContentType方法代碼示例

本文整理匯總了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;
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:20,代碼來源:SkinPregenerationService.java

示例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);
  }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:65,代碼來源:PartialViewContextImpl.java


注:本文中的javax.faces.context.ExternalContext.setResponseContentType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。