本文整理汇总了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;
}
示例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);
}
}
示例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;
}
示例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);
}
示例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");
}
示例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);
}
示例7: remove
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
static public void remove(FacesContext context, ResponseWriter oldRW)
{
context.setResponseWriter(oldRW);
}