本文整理汇总了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();
}
示例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;
}
示例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());
}
示例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;
}
示例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;
}
示例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;
}
示例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));
}
示例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;
}
示例9: getApplication
import javax.faces.application.ApplicationFactory; //导入方法依赖的package包/类
private static Application getApplication() {
ApplicationFactory appFactory = (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
return appFactory.getApplication();
}
示例10: initApplication
import javax.faces.application.ApplicationFactory; //导入方法依赖的package包/类
protected void initApplication()
{
ApplicationFactory applicationFactory =
(ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
this.application = applicationFactory.getApplication();
}