javax.faces.FactoryFinder Java Examples
The following examples show how to use
javax.faces.FactoryFinder.
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: 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 #3
Source File: MockedJsf2TestContainer.java From deltaspike with Apache License 2.0 | 5 votes |
public void shutdown() { this.application = null; this.servletConfig = null; this.containerConfig = null; this.lifecycle = null; this.renderKit = null; this.servletContext = null; FactoryFinder.releaseFactories(); }
Example #4
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 #5
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 #6
Source File: MockedJsf2TestContainer.java From deltaspike with Apache License 2.0 | 5 votes |
protected void onPreInitJsf() { //init mocked jsf factories addFactory(FactoryFinder.APPLICATION_FACTORY, MockApplicationFactory.class.getName()); addFactory(FactoryFinder.FACES_CONTEXT_FACTORY, MockFacesContextFactory.class.getName()); addFactory(FactoryFinder.LIFECYCLE_FACTORY, MockLifecycleFactory.class.getName()); addFactory(FactoryFinder.RENDER_KIT_FACTORY, MockRenderKitFactory.class.getName()); addFactory(FactoryFinder.EXCEPTION_HANDLER_FACTORY, MockExceptionHandlerFactory.class.getName()); addFactory(FactoryFinder.PARTIAL_VIEW_CONTEXT_FACTORY, MockPartialViewContextFactory.class.getName()); addFactory(FactoryFinder.VISIT_CONTEXT_FACTORY, MockVisitContextFactory.class.getName()); }
Example #7
Source File: MockedJsf2TestContainer.java From deltaspike with Apache License 2.0 | 5 votes |
protected void initJsf() { FactoryFinder.releaseFactories(); onPreInitJsf(); initLifecycle(); initApplication(); initRenderKit(); }
Example #8
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 #9
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 #10
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 #11
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 #12
Source File: ConfigManager.java From netbeans with Apache License 2.0 | 5 votes |
/** * Calls through to {@link javax.faces.FactoryFinder#releaseFactories()} * ignoring any exceptions. */ private void releaseFactories() { try { FactoryFinder.releaseFactories(); } catch (FacesException ignored) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "Exception thrown from FactoryFinder.releaseFactories()", ignored); } } }
Example #13
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 #14
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 #15
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 #16
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 #17
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 #18
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 #19
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 #20
Source File: TestJsf.java From javamelody with Apache License 2.0 | 5 votes |
@Test public void testInitJsfActionListener() throws NoSuchMethodException, SecurityException, InvocationTargetException, IllegalAccessException { final ServletContext servletContext = createNiceMock(ServletContext.class); expect(servletContext.getInitParameter("com.sun.faces.enableTransitionTimeNoOpFlash")) .andReturn(null).anyTimes(); final Enumeration<String> initParameterNames = Collections.emptyEnumeration(); expect(servletContext.getInitParameterNames()).andReturn(initParameterNames).anyTimes(); replay(servletContext); final InitFacesContext facesContext = new InitFacesContext(servletContext); final Method setter = FacesContext.class.getDeclaredMethod("setCurrentInstance", FacesContext.class); setter.setAccessible(true); setter.invoke(null, facesContext); FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY, AppFactory.class.getName()); verify(servletContext); final ActionListener delegateActionListener = createNiceMock(ActionListener.class); FacesContext.getCurrentInstance().getApplication() .setActionListener(delegateActionListener); JsfActionHelper.initJsfActionListener(); final UIComponent uiComponent = createNiceMock(UIComponent.class); final ActionEvent actionEvent = new ActionEvent(uiComponent); final ActionListener actionListener = FacesContext.getCurrentInstance().getApplication() .getActionListener(); actionListener.processAction(actionEvent); MonitoringProxy.getJsfCounter().setDisplayed(false); actionListener.processAction(actionEvent); MonitoringProxy.getJsfCounter().setDisplayed(true); }
Example #21
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 #22
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 #23
Source File: MockedJsf2TestContainer.java From deltaspike with Apache License 2.0 | 4 votes |
protected void addFactory(String factoryName, String className) { FactoryFinder.setFactory(factoryName, className); }
Example #24
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 #25
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(); }