本文整理汇总了Java中javax.faces.FactoryFinder类的典型用法代码示例。如果您正苦于以下问题:Java FactoryFinder类的具体用法?Java FactoryFinder怎么用?Java FactoryFinder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FactoryFinder类属于javax.faces包,在下文中一共展示了FactoryFinder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: _getResponseStateManager
import javax.faces.FactoryFinder; //导入依赖的package包/类
static private ResponseStateManager _getResponseStateManager(
FacesContext context,
String renderKitId)
{
RenderKitFactory factory = (RenderKitFactory)
FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
RenderKit kit = factory.getRenderKit(context, renderKitId);
return kit.getResponseStateManager();
}
示例2: handleError
import javax.faces.FactoryFinder; //导入依赖的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();
}
示例3: _createValueExpressionFromApplication
import javax.faces.FactoryFinder; //导入依赖的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;
}
示例4: getRenderKit
import javax.faces.FactoryFinder; //导入依赖的package包/类
static public RenderKit getRenderKit(FacesContext context)
{
RenderKitFactory factory = (RenderKitFactory)
FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
factory.addRenderKit(RenderKitFactory.HTML_BASIC_RENDER_KIT, new BasicHtmlRenderKit());
String renderKitId = null;
if (context.getViewRoot() != null)
renderKitId = context.getViewRoot().getRenderKitId();
if (renderKitId == null)
renderKitId = "org.apache.myfaces.trinidad.core";
RenderKit renderKit = factory.getRenderKit(context,renderKitId);
if (renderKit == null)
throw new IllegalStateException("Could not create renderKit " + renderKitId);
return renderKit;
}
示例5: getFacesContext
import javax.faces.FactoryFinder; //导入依赖的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;
}
示例6: setUp
import javax.faces.FactoryFinder; //导入依赖的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);
}
示例7: getJSFInfo
import javax.faces.FactoryFinder; //导入依赖的package包/类
/**
* gets JSF information like JSF version and Faces context.
*
* @return the JSF info
*/
public static Map<String, Object> getJSFInfo() {
final LinkedHashMap<String, Object> details = new LinkedHashMap<String, Object>();
final FacesContext context = FacesContext.getCurrentInstance();
final Application application = context.getApplication();
final ViewHandler viewHandler = application.getViewHandler();
final ViewDeclarationLanguage vdl = viewHandler.getViewDeclarationLanguage(context, context.getViewRoot().getViewId());
final LifecycleFactory LifecycleFactory = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
details.put("JSF-Version", FacesContext.class.getPackage().getImplementationVersion());
details.put("JSF-Version-Package", FacesContext.class.getPackage().getName());
details.put("FacesContext", context.getClass());
details.put("Application", application.getClass());
details.put("ViewHandler", viewHandler.getClass());
details.put("ViewDeclarationLanguage", vdl.getClass());
details.put("LifecycleFactory", LifecycleFactory.getClass());
return details;
}
示例8: setupResponseWriter
import javax.faces.FactoryFinder; //导入依赖的package包/类
/** setup the JSF response writer. */
private ResponseWriter setupResponseWriter(final String mimetype,
final HttpServletResponse response,
final FacesContext facesContext)
throws IOException
{
final OutputStream os = response.getOutputStream();
final UIViewRoot viewRoot = facesContext.getViewRoot();
final RenderKitFactory renderFactory = (RenderKitFactory)
FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
final RenderKit renderKit =
renderFactory.getRenderKit(facesContext, viewRoot.getRenderKitId());
final ResponseWriter writer =
renderKit.createResponseWriter(new OutputStreamWriter(os, "UTF-8"),
mimetype,
"UTF-8");
facesContext.setResponseWriter(writer);
// must be text/xml otherwise IE doesn't parse the response properly into responseXML
response.setContentType(mimetype);
return writer;
}
示例9: getFacesContextImpl
import javax.faces.FactoryFinder; //导入依赖的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;
}
示例10: createFacesContext
import javax.faces.FactoryFinder; //导入依赖的package包/类
public static FacesContext createFacesContext(AbstractXspTest test,
HttpServletRequest request) throws Exception {
FacesController controller = (FacesController) test.getTestLocalVars().get("controller");
if( null == controller ){
bootstrap(test);
controller = (FacesController) test.getTestLocalVars().get("controller");
}
LocalServletContext servletContext = (LocalServletContext) test.getTestLocalVars().get("servletContext");
HttpServletResponse response = new LocalHttpServletResponse(servletContext, null);
FacesContextFactory factory1 = (FacesContextFactory)FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
FacesContext context = factory1.getFacesContext(servletContext, request, response, controller.getLifecycle());
String sessionId = request.getSession().getId();
SessionUtil.setSessionId(context, sessionId);
test.getTestLocalVars().put("facesContext", context);
return context;
}
示例11: jsfDispatchPage
import javax.faces.FactoryFinder; //导入依赖的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();
}
}
示例12: getFacesContext
import javax.faces.FactoryFinder; //导入依赖的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;
}
示例13: getFacesContext
import javax.faces.FactoryFinder; //导入依赖的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;
}
示例14: getFacesContext
import javax.faces.FactoryFinder; //导入依赖的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;
}
示例15: getApplication
import javax.faces.FactoryFinder; //导入依赖的package包/类
@Override
public Application getApplication()
{
if (_application == null)
{
_application = ((ApplicationFactory) FactoryFinder.getFactory(
FactoryFinder.APPLICATION_FACTORY)).getApplication();
}
return _application;
}