Java Code Examples for javax.faces.FactoryFinder#getFactory()
The following examples show how to use
javax.faces.FactoryFinder#getFactory() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestProject.java From XPagesExtensionLibrary with Apache License 2.0 | 6 votes |
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; }
Example 2
Source File: TemplateBaseListener.java From sakai with Educational Community License v2.0 | 5 votes |
/** * 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; }
Example 3
Source File: MockedJsf2TestContainer.java From deltaspike with Apache License 2.0 | 5 votes |
protected void initFacesContext() { FacesContextFactory facesContextFactory = (FacesContextFactory) FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY); this.facesContext = facesContextFactory.getFacesContext( this.servletContext, this.request, this.response, this.lifecycle); ((MockFacesContext) this.facesContext).setApplication(this.application); ExceptionHandler exceptionHandler = ((ExceptionHandlerFactory) FactoryFinder.getFactory(FactoryFinder.EXCEPTION_HANDLER_FACTORY)).getExceptionHandler(); this.facesContext.setExceptionHandler(exceptionHandler); ((MockFacesContext) this.facesContext).setExternalContext( new MockExternalContext(this.servletContext, this.request, this.response)); }
Example 4
Source File: MockedJsf2TestContainer.java From deltaspike with Apache License 2.0 | 5 votes |
protected void initRenderKit() { RenderKitFactory renderKitFactory = (RenderKitFactory) FactoryFinder .getFactory(FactoryFinder.RENDER_KIT_FACTORY); this.renderKit = new MockRenderKit(); renderKitFactory.addRenderKit(RenderKitFactory.HTML_BASIC_RENDER_KIT, this.renderKit); }
Example 5
Source File: AddSignatureToViewStateObjects.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 5 votes |
public void runTask() throws Exception { RenderKitFactory rkFactory = (RenderKitFactory) FactoryFinder.getFactory("javax.faces.render.RenderKitFactory"); RenderKitImpl html_basic = (RenderKitImpl) rkFactory.getRenderKit(FacesContext.getCurrentInstance(), "HTML_BASIC"); final RenderKit renderKit = new MyRenderKit(); Field rendererFamiliesField = RenderKitImpl.class.getDeclaredField("rendererFamilies"); rendererFamiliesField.setAccessible(true); HashMap rendererFamiles = (HashMap) rendererFamiliesField.get(html_basic); rendererFamiliesField.set(renderKit, rendererFamiles); rkFactory.addRenderKit("HTML_BASIC", renderKit); JsonElement jsonElement = new Gson().toJsonTree(renderKit); }
Example 6
Source File: SignupServlet.java From sakai with Educational Community License v2.0 | 5 votes |
/** * 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; }
Example 7
Source File: CustomSelectOneRadioTag.java From sakai with Educational Community License v2.0 | 5 votes |
public ValueBinding getValueBinding(String valueRef) { ApplicationFactory af = (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY); Application a = af.getApplication(); return (a.createValueBinding(valueRef)); }
Example 8
Source File: ContextUtil.java From sakai with Educational Community License v2.0 | 5 votes |
/** * 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; }
Example 9
Source File: ContextUtil.java From sakai with Educational Community License v2.0 | 5 votes |
/** * 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; }
Example 10
Source File: MobileActionListener.java From journaldev with MIT License | 5 votes |
public void listAllPhaseListeners() { LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder .getFactory(FactoryFinder.LIFECYCLE_FACTORY); Lifecycle applicationLifecycle = lifecycleFactory .getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE); PhaseListener phaseListeners[] = applicationLifecycle .getPhaseListeners(); for (PhaseListener phaseListener : phaseListeners) { System.out.println(phaseListener.getPhaseId()); } }
Example 11
Source File: ComponentRendererTest.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
private RenderKitCheckInfo[] getRenderKitInfos(FacesContext context) { // get from subclass RenderKitCheckInfo[] kitInfos = createRenderKitInfos(); // validate RenderKitInfos RenderKits exist RenderKitFactory factory = (RenderKitFactory) FactoryFinder .getFactory(FactoryFinder.RENDER_KIT_FACTORY); for (int i = 0; i < kitInfos.length; i++) { RenderKit kit = kitInfos[i].findRenderKit(context, factory); if (null == kit) { assertNotNull("No faces-config containing the renderKit "+ kitInfos[i].getRenderKitId(), /*kit*/null); } } return kitInfos; }
Example 12
Source File: SignupServlet.java From sakai with Educational Community License v2.0 | 5 votes |
/** * 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; }
Example 13
Source File: CustomSelectOneRadioTag.java From sakai with Educational Community License v2.0 | 5 votes |
public ValueBinding getValueBinding(String valueRef) { ApplicationFactory af = (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY); Application a = af.getApplication(); return (a.createValueBinding(valueRef)); }
Example 14
Source File: ContextUtil.java From sakai with Educational Community License v2.0 | 5 votes |
/** * 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; }
Example 15
Source File: ContextUtil.java From sakai with Educational Community License v2.0 | 5 votes |
/** * 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; }
Example 16
Source File: TemplateBaseListener.java From sakai with Educational Community License v2.0 | 5 votes |
/** * 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; }
Example 17
Source File: FacesContextServlet.java From XPagesExtensionLibrary with Apache License 2.0 | 4 votes |
public void init(ServletConfig servletConfig) throws ServletException { this.servletConfig = servletConfig; // Create the FacesContextFactory this.contextFactory = (FacesContextFactory)FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY); }
Example 18
Source File: MockedJsf2TestContainer.java From deltaspike with Apache License 2.0 | 4 votes |
protected void initLifecycle() { LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY); this.lifecycle = lifecycleFactory.getLifecycle(getLifecycleId()); }
Example 19
Source File: MockedJsf2TestContainer.java From deltaspike with Apache License 2.0 | 4 votes |
protected void initApplication() { ApplicationFactory applicationFactory = (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY); this.application = applicationFactory.getApplication(); }