本文整理汇总了Java中javax.faces.application.ApplicationFactory类的典型用法代码示例。如果您正苦于以下问题:Java ApplicationFactory类的具体用法?Java ApplicationFactory怎么用?Java ApplicationFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ApplicationFactory类属于javax.faces.application包,在下文中一共展示了ApplicationFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getApplication
import javax.faces.application.ApplicationFactory; //导入依赖的package包/类
@Override
public Application getApplication()
{
if (_application == null)
{
_application = ((ApplicationFactory) FactoryFinder.getFactory(
FactoryFinder.APPLICATION_FACTORY)).getApplication();
}
return _application;
}
示例4: _getELResolver
import javax.faces.application.ApplicationFactory; //导入依赖的package包/类
static private ELResolver _getELResolver(FacesContext context)
{
// First try the FacesContext, which is a faster way to
// get the ELResolver (and the 99.9% scenario)
if (context != null)
return context.getApplication().getELResolver();
// If that fails, then we're likely outside of the JSF lifecycle.
// Look to the ApplicationFactory.
ApplicationFactory factory = (ApplicationFactory)
FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
return factory.getApplication().getELResolver();
}
示例5: 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());
}
示例6: 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;
}
示例7: 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;
}
示例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 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;
}
示例9: 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));
}
示例10: 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;
}
示例11: EventDrivenUpdatesContext
import javax.faces.application.ApplicationFactory; //导入依赖的package包/类
/**
* Initializes an {@link EventDrivenUpdatesContext}.
*
* @param config a configuration
*/
public EventDrivenUpdatesContext(EventDrivenUpdatesConfig config) {
this.config = config;
final ApplicationFactory applicationFactory = (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
if (applicationFactory != null) {
applicationFactory.getApplication().subscribeToEvent(
PostAddToViewEvent.class, config.getListener());
}
}
示例12: getWrapped
import javax.faces.application.ApplicationFactory; //导入依赖的package包/类
/**
* Returns the wrapped factory.
*/
@Override
public ApplicationFactory getWrapped() {
return wrapped;
}
示例13: CdiApplicationFactory
import javax.faces.application.ApplicationFactory; //导入依赖的package包/类
public CdiApplicationFactory(ApplicationFactory delegate) {
this.delegate = delegate;
}
示例14: StarterApplicationFactory
import javax.faces.application.ApplicationFactory; //导入依赖的package包/类
public StarterApplicationFactory(ApplicationFactory factory) {
super(factory);
if (_debug)
System.out.println(getClass().getName() + " created with delegate");
}
示例15: OpenNTFApplicationFactory
import javax.faces.application.ApplicationFactory; //导入依赖的package包/类
public OpenNTFApplicationFactory(ApplicationFactory factory) {
super(factory);
if (_debug)
System.out.println(getClass().getName() + " created with delegate");
}