本文整理匯總了Java中javax.faces.context.FacesContext.release方法的典型用法代碼示例。如果您正苦於以下問題:Java FacesContext.release方法的具體用法?Java FacesContext.release怎麽用?Java FacesContext.release使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.faces.context.FacesContext
的用法示例。
在下文中一共展示了FacesContext.release方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setUp
import javax.faces.context.FacesContext; //導入方法依賴的package包/類
@Override
protected void setUp() throws Exception
{
super.setUp();
FacesContext oldFacesContext = facesContext;
UIViewRoot oldViewRoot = oldFacesContext.getViewRoot();
oldFacesContext.release();
facesContext = new MockFacesContext12(externalContext,
lifecycle,
application);
facesContext.setViewRoot(oldViewRoot);
facesContext.setApplication(application);
facesContext.getViewRoot().setRenderKitId("org.apache.myfaces.trinidad.core");
RenderKitFactory renderKitFactory = (RenderKitFactory)
FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
Mock mockRenderKitty = mock(RenderKit.class);
RenderKit renderKit = (RenderKit) mockRenderKitty.proxy();
_mockRenderKit = new MockRenderKitWrapper(mockRenderKitty, renderKit);
renderKitFactory.addRenderKit("org.apache.myfaces.trinidad.core", renderKit);
}
示例2: setUp
import javax.faces.context.FacesContext; //導入方法依賴的package包/類
@Override
protected void setUp() throws Exception
{
super.setUp();
// Set up a JSF 1.2 FacesContext
FacesContext oldFacesContext = facesContext;
UIViewRoot oldViewRoot = oldFacesContext.getViewRoot();
oldFacesContext.release();
facesContext = new MockFacesContext12(externalContext,
lifecycle,
application);
facesContext.setViewRoot(oldViewRoot);
facesContext.setApplication(application);
}
示例3: doFilter
import javax.faces.context.FacesContext; //導入方法依賴的package包/類
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
{
FacesContextFactory contextFactory = (FacesContextFactory) FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
Lifecycle lifecycle = lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
// Either set a private member
// servletContext = filterConfig.getServletContext();
// in your filter init() method or set it here like this:
// ServletContext servletContext =
// ((HttpServletRequest) request).getSession().getServletContext();
// Note that the above line would fail if you are using any other
// protocol than http
// Doesn't set this instance as the current instance of
// FacesContext.getCurrentInstance
FacesContext facesContext = contextFactory.getFacesContext(servletContext, request, response, lifecycle);
// Set using our inner class
InnerFacesContext.setFacesContextAsCurrentInstance(facesContext);
try
{
// call the filter chain
chain.doFilter(request, response);
}
finally
{
// Clean up after ourselves as FacesContext is a ThreadLocal object
try
{
facesContext.release();
}
catch (IllegalStateException ex)
{
// Perhaps the FacesContext has already been released?
log.warn("Double release of faces context?", ex);
}
}
}