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


Java ApplicationFactory.getApplication方法代码示例

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


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

示例1: handleError

import javax.faces.application.ApplicationFactory; //导入方法依赖的package包/类
/**
 * Handle a server-side error by reporting it back to the client.
 */
public static void handleError(ExternalContext ec, 
                               Throwable t) throws IOException
{
  String error = _getErrorString();
  _LOG.severe(error, t);

  ServletResponse response = (ServletResponse)ec.getResponse();
  PrintWriter writer = response.getWriter();
  XmlResponseWriter rw = new XmlResponseWriter(writer, "UTF-8");
  rw.startDocument();
  rw.startElement("partial-response", null);
  rw.startElement("error", null);
  rw.startElement("error-name", null);
  rw.writeText(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, null);
  rw.endElement("error-name");

  String errorMessage = _getErrorMessage(error);

  // Default exception message contains the type of the exception.
  // Do not send this info to client in Production mode
  ApplicationFactory factory = (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
  Application application = factory.getApplication();
  if (application.getProjectStage() != ProjectStage.Production)
  {
    errorMessage = _getExceptionString(t) + errorMessage;
  }

  rw.startElement("error-message", null);
  rw.writeText(errorMessage, null);
  rw.endElement("error-message");

  rw.endElement("error");
  rw.endElement("partial-response");
  rw.endDocument();
  rw.close();
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:40,代码来源:XmlHttpConfigurator.java

示例2: _createValueExpressionFromApplication

import javax.faces.application.ApplicationFactory; //导入方法依赖的package包/类
private static ValueExpression _createValueExpressionFromApplication(
  String expression,
  Class<?> expectedType)
{
  ApplicationFactory factory = (ApplicationFactory)
    FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
  if (factory != null)
  {
    Application application = factory.getApplication();
    if (application != null)
    {
      ELContext elContext = _getELContext(application);

      ExpressionFactory expressionFactory = application.getExpressionFactory();
      if (expressionFactory != null)
      {
        return expressionFactory.createValueExpression(elContext, expression, expectedType);
      }
    }
  }

  return null;
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:24,代码来源:LazyValueExpression.java

示例3: contextInitialized

import javax.faces.application.ApplicationFactory; //导入方法依赖的package包/类
@Override
public void contextInitialized(ServletContextEvent sce) {
    super.contextInitialized(sce);

    ApplicationFactory factory = (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
    javax.faces.application.Application app = factory.getApplication();
    app.addELResolver(new SpringBeanFacesELResolver());
}
 
开发者ID:UrsZeidler,项目名称:checksumDatabase,代码行数:9,代码来源:Application.java

示例4: lookupTemplateBean

import javax.faces.application.ApplicationFactory; //导入方法依赖的package包/类
/**
 * Helper method to look up template backing bean.
 * @param context the faces context
 * @return the backing bean
 * @throws FacesException
 */
protected TemplateBean lookupTemplateBean(FacesContext context) throws
    FacesException
{
  TemplateBean templateBean;
  //FacesContext facesContext = FacesContext.getCurrentInstance();
  ApplicationFactory factory = (ApplicationFactory) FactoryFinder.getFactory(
      FactoryFinder.APPLICATION_FACTORY);
  Application application = factory.getApplication();
  templateBean = (TemplateBean)
      application.getVariableResolver().resolveVariable(context, "template");
  return templateBean;
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:19,代码来源:TemplateBaseListener.java

示例5: lookupBean

import javax.faces.application.ApplicationFactory; //导入方法依赖的package包/类
/**
 * Helper method to look up backing bean.
 * Don't forget to cast!
 *   e.g. (TemplateBean) ContextUtil.lookupBean("template")
 * @param context the faces context
 * @return the backing bean
 * @throws FacesException
 */
public static Serializable lookupBean(String beanName)
{
  FacesContext facesContext = FacesContext.getCurrentInstance();
  ApplicationFactory factory = (ApplicationFactory) FactoryFinder.
                               getFactory(
                               FactoryFinder.APPLICATION_FACTORY);
  Application application = factory.getApplication();
  Serializable bean = (Serializable)
                      application.getVariableResolver().resolveVariable(
                      facesContext, beanName);
  return bean;
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:21,代码来源:ContextUtil.java

示例6: lookupBeanFromExternalServlet

import javax.faces.application.ApplicationFactory; //导入方法依赖的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;
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:44,代码来源:ContextUtil.java

示例7: getValueBinding

import javax.faces.application.ApplicationFactory; //导入方法依赖的package包/类
public ValueBinding getValueBinding(String valueRef) {
	ApplicationFactory af =
		(ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
	Application a = af.getApplication();

	return (a.createValueBinding(valueRef));
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:8,代码来源:CustomSelectOneRadioTag.java

示例8: lookupBeanFromExternalServlet

import javax.faces.application.ApplicationFactory; //导入方法依赖的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;
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:40,代码来源:SignupServlet.java

示例9: getApplication

import javax.faces.application.ApplicationFactory; //导入方法依赖的package包/类
private static Application getApplication() {
    ApplicationFactory appFactory = (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
    return appFactory.getApplication();
}
 
开发者ID:mgerlich,项目名称:MetFusion,代码行数:5,代码来源:FacesUtils.java

示例10: initApplication

import javax.faces.application.ApplicationFactory; //导入方法依赖的package包/类
protected void initApplication()
{
    ApplicationFactory applicationFactory =
            (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
    this.application = applicationFactory.getApplication();
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:7,代码来源:MockedJsf2TestContainer.java


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