本文整理汇总了Java中javax.faces.lifecycle.Lifecycle类的典型用法代码示例。如果您正苦于以下问题:Java Lifecycle类的具体用法?Java Lifecycle怎么用?Java Lifecycle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Lifecycle类属于javax.faces.lifecycle包,在下文中一共展示了Lifecycle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFacesContext
import javax.faces.lifecycle.Lifecycle; //导入依赖的package包/类
/**
* @param request
* @param response
* @return
*/
private FacesContext getFacesContext(final ServletRequest request, final ServletResponse response) {
FacesContext facesContext = FacesContext.getCurrentInstance();
if (facesContext != null) {
return facesContext;
}
FacesContextFactory contextFactory = (FacesContextFactory) FactoryFinder
.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder
.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
Lifecycle lifecycle = lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
ServletContext servletContext = ((HttpServletRequest) request).getSession().getServletContext();
facesContext = contextFactory.getFacesContext(servletContext, request, response, lifecycle);
return facesContext;
}
示例2: getFacesContextImpl
import javax.faces.lifecycle.Lifecycle; //导入依赖的package包/类
/**
* Return a valid FacesContext for the specific context, request and response.
* The FacesContext can be constructor for Servlet and Portlet use.
*
* @param context ServletContext or PortletContext
* @param request ServletRequest or PortletRequest
* @param response ServletReponse or PortletResponse
*
* @return FacesContext
*/
private static FacesContext getFacesContextImpl(Object request, Object response, Object context, String viewRoot)
{
FacesContextFactory contextFactory = (FacesContextFactory)FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
LifecycleFactory lifecycleFactory = (LifecycleFactory)FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
Lifecycle lifecycle = lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
// Doesn't set this instance as the current instance of FacesContext.getCurrentInstance
FacesContext facesContext = contextFactory.getFacesContext(context, request, response, lifecycle);
// Set using our inner class
InnerFacesContext.setFacesContextAsCurrent(facesContext);
// set a new viewRoot, otherwise context.getViewRoot returns null
if (viewRoot == null)
{
viewRoot = FacesHelper.BROWSE_VIEW_ID;
}
UIViewRoot view = facesContext.getApplication().getViewHandler().createView(facesContext, viewRoot);
facesContext.setViewRoot(view);
return facesContext;
}
示例3: jsfDispatchPage
import javax.faces.lifecycle.Lifecycle; //导入依赖的package包/类
/**
* Jsf dispatch page.
*
* @param fctx the faces context
* @param page the pge
*/
private void jsfDispatchPage(FacesContext fctx, String page) {
LifecycleFactory lf = (LifecycleFactory) FactoryFinder
.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
Lifecycle lifecycle = lf.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
ViewHandler vh = fctx.getApplication().getViewHandler();
fctx.getViewRoot().setRenderKitId(vh.calculateRenderKitId(fctx));
fctx.setViewRoot(vh.createView(fctx, page));
// view rendering
try {
lifecycle.render(fctx);
} catch (Exception e) {
LOG.log(Level.INFO, "Error while rendering page. Attempting again" + page,
e);
lifecycle.render(fctx);
} finally {
fctx.release();
}
}
示例4: getFacesContext
import javax.faces.lifecycle.Lifecycle; //导入依赖的package包/类
/**
* Gets the faces context.
*
* @param request the request
* @param response the response
* @return the faces context
*/
protected FacesContext getFacesContext(HttpServletRequest request,
HttpServletResponse response) {
FacesContext facesContext = FacesContext.getCurrentInstance();
if (facesContext == null) {
FacesContextFactory contextFactory = (FacesContextFactory) FactoryFinder
.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder
.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
Lifecycle lifecycle = lifecycleFactory
.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
facesContext = contextFactory.getFacesContext(request.getSession()
.getServletContext(), request, response, lifecycle);
// set a new viewRoot, otherwise context.getViewRoot returns null
UIViewRoot view = facesContext.getApplication().getViewHandler()
.createView(facesContext, "");
facesContext.setViewRoot(view);
}
return facesContext;
}
示例5: getFacesContext
import javax.faces.lifecycle.Lifecycle; //导入依赖的package包/类
public FacesContext getFacesContext(ServletRequest request, ServletResponse response) {
FacesContext facesContext = FacesContext.getCurrentInstance();
if (facesContext != null) {
return facesContext;
}
FacesContextFactory contextFactory = (FacesContextFactory) FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
Lifecycle lifecycle = lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
ServletContext servletContext = ((HttpServletRequest) request).getSession().getServletContext();
facesContext = contextFactory.getFacesContext(servletContext, request, response, lifecycle);
InnerFacesContext.setFacesContextAsCurrentInstance(facesContext);
if (null == facesContext.getViewRoot()) {
facesContext.setViewRoot(new UIViewRoot());
}
return facesContext;
}
示例6: getFacesContext
import javax.faces.lifecycle.Lifecycle; //导入依赖的package包/类
@Override
public FacesContext getFacesContext(final Object context, final Object request, final Object response, final Lifecycle lifecycle)
throws FacesException {
FacesContext ctx = _delegate.getFacesContext(context, request, response, lifecycle);
try {
Class<?> vnClass = Class.forName("org.openntf.domino.xsp.helpers.OpenntfViewNavigatorEx");
} catch (ClassNotFoundException e) {
System.out.println("OpenntfFacesContextFactory unable to resolve ViewNavigatorEx either!");
}
try {
Factory.setClassLoader(Thread.currentThread().getContextClassLoader());
if (ctx instanceof com.ibm.xsp.context.FacesContextEx) {
((com.ibm.xsp.context.FacesContextEx) ctx).addRequestListener(this);
}
// System.out.println("Created OpenntfFacesContext and setup factory");
} catch (Throwable t) {
t.printStackTrace();
}
return ctx;
}
示例7: getFacesContext
import javax.faces.lifecycle.Lifecycle; //导入依赖的package包/类
@Override
public FacesContext getFacesContext(final Object context, final Object request, final Object response, final Lifecycle lifecycle)
throws FacesException {
FacesContext ctx = _delegate.getFacesContext(context, request, response, lifecycle);
Factory.initThread(ODAPlatform.getAppThreadConfig(null));
Factory.setSessionFactory(new XPageCurrentSessionFactory(), SessionType.CURRENT);
Factory.setSessionFactory(new XPageSignerSessionFactory(false), SessionType.SIGNER);
Factory.setSessionFactory(new XPageSignerSessionFactory(true), SessionType.SIGNER_FULL_ACCESS);
// TODO RPr: This is probably the wrong locale. See ViewHandler.calculateLocale
Factory.setUserLocale(ctx.getExternalContext().getRequestLocale());
Factory.setClassLoader(ctx.getContextClassLoader());
// NotesContext ntx = NotesContext.getCurrent();
if (ODAPlatform.isAppGodMode(null)) {
ODAFacesContext localContext = new ODAFacesContext(ctx);
attachListener(localContext);
return localContext;
} else {
attachListener((FacesContextEx) ctx);
return ctx;
}
}
示例8: getFacesContext
import javax.faces.lifecycle.Lifecycle; //导入依赖的package包/类
public FacesContext getFacesContext(final ServletRequest request,
final ServletResponse response, HttpSession ses) {
FacesContext facesContext = FacesContext.getCurrentInstance();
if (facesContext != null) {
return facesContext;
}
FacesContextFactory contextFactory = (FacesContextFactory) FactoryFinder
.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder
.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
Lifecycle lifecycle = lifecycleFactory
.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
ServletContext servletContext = ses.getServletContext();
facesContext = contextFactory.getFacesContext(servletContext, request,
response, lifecycle);
InnerFacesContext.setFacesContextAsCurrentInstance(facesContext);
if (null == facesContext.getViewRoot()) {
UIViewRoot u = new UIViewRoot();
u.setViewId("irgendwas");
facesContext.setViewRoot(u);
}
return facesContext;
}
示例9: getLifecycle
import javax.faces.lifecycle.Lifecycle; //导入依赖的package包/类
@Override
public Lifecycle getLifecycle(String s)
{
Lifecycle result = this.wrapped.getLifecycle(s);
if (this.deactivated)
{
return result;
}
if (this.jsfVersionWithClientWindowDetected)
{
Class<? extends Lifecycle> lifecycleWrapperClass = ClassUtils.tryToLoadClassForName(
"org.apache.deltaspike.jsf.impl.listener.request.JsfClientWindowAwareLifecycleWrapper");
try
{
return (Lifecycle) lifecycleWrapperClass.getConstructor(new Class[] { Lifecycle.class })
.newInstance(new DeltaSpikeLifecycleWrapper(result));
}
catch (Exception e)
{
throw ExceptionUtils.throwAsRuntimeException(e);
}
}
return new DeltaSpikeLifecycleWrapper(result);
}
示例10: getFacesContext
import javax.faces.lifecycle.Lifecycle; //导入依赖的package包/类
/**
* Wrapps the created {@link javax.faces.context.FacesContext} with {@link DeltaSpikeFacesContextWrapper}
* <p/>
* {@inheritDoc}
*/
@Override
public FacesContext getFacesContext(Object context,
Object request,
Object response,
Lifecycle lifecycle)
{
FacesContext facesContext =
this.wrappedFacesContextFactory.getFacesContext(context, request, response, lifecycle);
if (facesContext == null || this.deactivated || facesContext instanceof DeltaSpikeFacesContextWrapper)
{
return facesContext;
}
lazyInit();
return new DeltaSpikeFacesContextWrapper(facesContext, clientWindow);
}
示例11: getFacesContext
import javax.faces.lifecycle.Lifecycle; //导入依赖的package包/类
@Override
@SuppressWarnings ("unchecked")
public FacesContext getFacesContext(
Object context,
Object request,
Object response,
Lifecycle lifecycle)
{
return new CacheRenderKit(_factory.getFacesContext(context, request, response, lifecycle));
}
示例12: MockFacesContext12
import javax.faces.lifecycle.Lifecycle; //导入依赖的package包/类
public MockFacesContext12(ExternalContext ec,
Lifecycle lifecycle,
Application application)
{
super(ec, lifecycle);
elContext = createELContext(application);
elContext.putContext(FacesContext.class, this);
_app = application;
}
示例13: doFilter
import javax.faces.lifecycle.Lifecycle; //导入依赖的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);
}
}
}
示例14: lookupBeanFromExternalServlet
import javax.faces.lifecycle.Lifecycle; //导入依赖的package包/类
/**
* Helper method to look up backing bean, when OUTSIDE faces in a servlet.
* Don't forget to cast!
* e.g. (TemplateBean) ContextUtil.lookupBean("template")
*
* @param beanName
* @param request servlet request
* @param response servlet response
* @return the backing bean
*/
public static Serializable lookupBeanFromExternalServlet(String beanName,
HttpServletRequest request, HttpServletResponse response)
{
// prepare lifecycle
LifecycleFactory lFactory = (LifecycleFactory)
FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
Lifecycle lifecycle =
lFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
FacesContextFactory fcFactory = (FacesContextFactory)
FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
// in the integrated environment, we can't get the ServletContext from the
// HttpSession of the request - because the HttpSession is webcontainer-wide,
// its not tied to a particular servlet.
ServletContext servletContext = M_servletContext;
if (servletContext == null)
{
servletContext = request.getSession().getServletContext();
}
FacesContext facesContext =
fcFactory.getFacesContext(servletContext, request, response, lifecycle);
ApplicationFactory factory = (ApplicationFactory) FactoryFinder.
getFactory(
FactoryFinder.APPLICATION_FACTORY);
Application application = factory.getApplication();
Serializable bean = (Serializable)
application.getVariableResolver().resolveVariable(
facesContext, beanName);
return bean;
}
示例15: lookupBeanFromExternalServlet
import javax.faces.lifecycle.Lifecycle; //导入依赖的package包/类
/**
* Helper method to look up backing bean, when OUTSIDE faces in a servlet.
* Don't forget to cast! e.g. (TemplateBean)
* ContextUtil.lookupBean("template")
*
* @param beanName
* @param request
* servlet request
* @param response
* servlet response
* @return the backing bean
*/
public Serializable lookupBeanFromExternalServlet(String beanName,
HttpServletRequest request, HttpServletResponse response) {
// prepare lifecycle
LifecycleFactory lFactory = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
Lifecycle lifecycle = lFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
FacesContextFactory fcFactory = (FacesContextFactory) FactoryFinder
.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
// in the integrated environment, we can't get the ServletContext from
// the
// HttpSession of the request - because the HttpSession is
// webcontainer-wide,
// its not tied to a particular servlet.
if (this.servletContext == null) {
servletContext = request.getSession().getServletContext();
}
FacesContext facesContext = fcFactory.getFacesContext(servletContext,
request, response, lifecycle);
ApplicationFactory factory = (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
Application application = factory.getApplication();
Serializable bean = (Serializable) application.getVariableResolver().resolveVariable(facesContext, beanName);
return bean;
}