当前位置: 首页>>代码示例>>Java>>正文


Java FacesContext.setResponseWriter方法代码示例

本文整理汇总了Java中javax.faces.context.FacesContext.setResponseWriter方法的典型用法代码示例。如果您正苦于以下问题:Java FacesContext.setResponseWriter方法的具体用法?Java FacesContext.setResponseWriter怎么用?Java FacesContext.setResponseWriter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.faces.context.FacesContext的用法示例。


在下文中一共展示了FacesContext.setResponseWriter方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: _getResponseWriter

import javax.faces.context.FacesContext; //导入方法依赖的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: _renderAll

import javax.faces.context.FacesContext; //导入方法依赖的package包/类
private void _renderAll(FacesContext context, UIComponent viewRoot)
{
  ResponseWriter origResponseWriter = context.getResponseWriter();

  // Use JSF-supplied PartialResponseWriter, since we are rendering the full page
  PartialResponseWriter rw = new PartialResponseWriter(origResponseWriter);

  context.setResponseWriter(rw);

  try
  {
    rw.startDocument();

    rw.startUpdate(PartialResponseWriter.RENDER_ALL_MARKER);
    _renderChildren(context, viewRoot);
    rw.endUpdate();

    //write out JSF state
    rw.startUpdate(StateUtils.getViewStateId(FacesContext.getCurrentInstance()));
    String state = context.getApplication().getStateManager().getViewState(context);
    rw.write(state);
    rw.endUpdate();

    rw.endDocument();
  }
  catch(IOException e)
  {
    throw new FacesException(e);
  }
  finally
  {
    context.setResponseWriter(origResponseWriter);
  }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:35,代码来源:PartialViewContextImpl.java

示例3: install

import javax.faces.context.FacesContext; //导入方法依赖的package包/类
static public ResponseWriter install(FacesContext context)
{
  ResponseWriter oldRW = context.getResponseWriter();
  
  ResponseWriter newRW = new RepeatIdResponseWriter(oldRW);
  context.setResponseWriter(newRW);
  
  return oldRW;
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:10,代码来源:RepeatIdResponseWriter.java

示例4: encodeBegin

import javax.faces.context.FacesContext; //导入方法依赖的package包/类
@Override
public void encodeBegin(FacesContext context)
{
  _savedWriter = context.getResponseWriter();
  
  ResponseWriter wrappedWriter = _savedWriter.cloneWithWriter(_writer);
  
  if (!_lenient)
    wrappedWriter = new CheckUIComponent(wrappedWriter);
      
  context.setResponseWriter(wrappedWriter);
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:13,代码来源:GatherContent.java

示例5: encodeEnd

import javax.faces.context.FacesContext; //导入方法依赖的package包/类
@Override
public void encodeEnd(FacesContext context)
{
  // check that we have balanced elements in the CheckUIComponent
  if (!_lenient)
  {
    ResponseWriter wrappedWriter = context.getResponseWriter();
    
    if (wrappedWriter instanceof CheckUIComponent)
    {
      int finishingDepth = ((CheckUIComponent)wrappedWriter).getDepth();
      
      if (finishingDepth != 0)
      {
        AssertionFailedError failure = new AssertionFailedError("Elements not completely popped during rendering");
        
        _result.addError(_test, failure);          
      }
    }
  }
  
  context.setResponseWriter(_savedWriter);
  _savedWriter = null;
  
  RenderingContext arc = RenderingContext.getCurrentInstance();

  // Our hidden label utility code makes sure it never writes out
  // the same label twice consecutively - but between batches of
  // gathered content, that's a bad thing
  HiddenLabelUtils.rememberLabel(arc, "forgetTheLabel");
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:32,代码来源:GatherContent.java

示例6: service

import javax.faces.context.FacesContext; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
static private void service(FacesContext context, String name)
  throws IOException
{
  if (_processReturnDialog(context,name))
  {
    return;
  }

  HttpServletResponse response =
    (HttpServletResponse) context.getExternalContext().getResponse();

  if (!_isValidEntry(name))
  {
    response.sendError(HttpServletResponse.SC_BAD_REQUEST);
    return;
  }

  // Only use "text/html" for now, even if the browser thinks
  // it supports "text/html".
  String contentType = "text/html";
  String encoding = JspUtils.getEncoding(context, "UTF-8");

  if (encoding == null)
    response.setContentType(contentType);
  else
    response.setContentType(contentType +
                            "; charset=" + encoding);

  // =-=AEW Getting the Writer straight off of the ServletResponse
  // means losing buffered and unsynchronized goodness
  ResponseWriter responseWriter = context.getRenderKit().createResponseWriter(
    response.getWriter(),
    contentType,
    encoding);
  context.setResponseWriter(responseWriter);

  Map<String, String> requestParams = 
    context.getExternalContext().getRequestParameterMap();
  
  String localeName = requestParams.get("loc");
  if (localeName != null)
  {
    Locale locale =
      LocaleUtils.getLocaleForIANAString(localeName);
    // Push the locale into JSF land
    context.getViewRoot().setLocale(locale);
  }

  _service(context, name);
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:52,代码来源:GenericEntry.java

示例7: remove

import javax.faces.context.FacesContext; //导入方法依赖的package包/类
static public void remove(FacesContext context, ResponseWriter oldRW)
{
  context.setResponseWriter(oldRW);
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:5,代码来源:RepeatIdResponseWriter.java


注:本文中的javax.faces.context.FacesContext.setResponseWriter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。