当前位置: 首页>>代码示例>>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;未经允许,请勿转载。