javax.faces.render.RenderKitFactory Java Examples

The following examples show how to use javax.faces.render.RenderKitFactory. 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: ComponentRendererTest.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
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 #2
Source File: AddSignatureToViewStateObjects.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
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 #3
Source File: MockedJsf2TestContainer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
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 #4
Source File: MockedJsf2TestContainer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
protected void initDefaultView()
{
    UIViewRoot root = new UIViewRoot();
    root.setViewId("/viewId");
    root.setLocale(getLocale());
    root.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
    this.facesContext.setViewRoot(root);
}
 
Example #5
Source File: MockedJsfContainerTest.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Test
public void firstTest()
{
    Assert.assertEquals(0, requestScopedBean.getCount());
    requestScopedBean.increaseCount();
    Assert.assertEquals(1, requestScopedBean.getCount());

    Assert.assertEquals(0, sessionScopedBean.getCount());
    sessionScopedBean.increaseCount();
    Assert.assertEquals(1, sessionScopedBean.getCount());

    Assert.assertNotNull(FacesContext.getCurrentInstance().getViewRoot());
    Assert.assertEquals("/viewId", FacesContext.getCurrentInstance().getViewRoot().getViewId());

    UIViewRoot uiViewRoot = new UIViewRoot();
    uiViewRoot.setViewId("/test1.xhtml");
    uiViewRoot.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
    FacesContext.getCurrentInstance().setViewRoot(uiViewRoot);
    Assert.assertEquals("/test1.xhtml", FacesContext.getCurrentInstance().getViewRoot().getViewId());

    Assert.assertNotNull(FacesContext.getCurrentInstance().getExternalContext());
    Assert.assertNotNull(FacesContext.getCurrentInstance().getApplication());
    Assert.assertNotNull(FacesContext.getCurrentInstance().getELContext());
    Assert.assertNotNull(FacesContext.getCurrentInstance().getPartialViewContext());
    Assert.assertNotNull(FacesContext.getCurrentInstance().getRenderKit());
    Assert.assertNotNull(FacesContext.getCurrentInstance().getExceptionHandler());

    Assert.assertNull(FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("test"));
    FacesContext.getCurrentInstance().getExternalContext().getRequestMap().put("test", "1");
    Assert.assertEquals("1", FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("test"));
}
 
Example #6
Source File: MockedJsfContainerTest.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Test
public void secondTest()
{
    Assert.assertEquals(0, requestScopedBean.getCount());
    requestScopedBean.increaseCount();
    Assert.assertEquals(1, requestScopedBean.getCount());

    Assert.assertEquals(0, sessionScopedBean.getCount());
    sessionScopedBean.increaseCount();
    Assert.assertEquals(1, sessionScopedBean.getCount());

    Assert.assertNotNull(FacesContext.getCurrentInstance().getViewRoot());
    Assert.assertEquals("/viewId", FacesContext.getCurrentInstance().getViewRoot().getViewId());

    UIViewRoot uiViewRoot = new UIViewRoot();
    uiViewRoot.setViewId("/test2.xhtml");
    uiViewRoot.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
    FacesContext.getCurrentInstance().setViewRoot(uiViewRoot);
    Assert.assertEquals("/test2.xhtml", FacesContext.getCurrentInstance().getViewRoot().getViewId());

    Assert.assertNotNull(FacesContext.getCurrentInstance().getExternalContext());
    Assert.assertNotNull(FacesContext.getCurrentInstance().getApplication());
    Assert.assertNotNull(FacesContext.getCurrentInstance().getELContext());
    Assert.assertNotNull(FacesContext.getCurrentInstance().getPartialViewContext());
    Assert.assertNotNull(FacesContext.getCurrentInstance().getRenderKit());
    Assert.assertNotNull(FacesContext.getCurrentInstance().getExceptionHandler());

    Assert.assertNull(FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("test"));
    FacesContext.getCurrentInstance().getExternalContext().getRequestMap().put("test", "2");
    Assert.assertEquals("2", FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("test"));
}
 
Example #7
Source File: ComponentRendererTest.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
/**
 * Return a RenderKit, lazily created.
 */
public RenderKit findRenderKit(FacesContext context, RenderKitFactory factory) {
  _renderKit = factory.getRenderKit(context, getRenderKitId());
  return _renderKit;
}
 
Example #8
Source File: ComponentRendererTest.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
/**
 * Return the renderKit infos, where none are null.
 * 
 * @return
 */
protected RenderKitCheckInfo[] createRenderKitInfos() {
    RenderKitCheckInfo[] result = new RenderKitCheckInfo[1];
    result[0] = new RenderKitCheckInfo(RenderKitFactory.HTML_BASIC_RENDER_KIT, "html", getHtmlNoRendererSkips());
    return result;
}
 
Example #9
Source File: JsfContainerTest.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
@Test
public void firstTest()
{
    Assert.assertEquals(0, requestScopedBean.getCount());
    requestScopedBean.increaseCount();
    Assert.assertEquals(1, requestScopedBean.getCount());

    Assert.assertEquals(0, sessionScopedBean.getCount());
    sessionScopedBean.increaseCount();
    Assert.assertEquals(1, sessionScopedBean.getCount());

    UIViewRoot uiViewRoot = new UIViewRoot();
    uiViewRoot.setViewId("/viewId");
    FacesContext.getCurrentInstance().setViewRoot(uiViewRoot);
    Assert.assertNotNull(FacesContext.getCurrentInstance().getViewRoot());
    Assert.assertEquals("/viewId", FacesContext.getCurrentInstance().getViewRoot().getViewId());

    uiViewRoot.setViewId("/test1.xhtml");
    uiViewRoot.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
    FacesContext.getCurrentInstance().setViewRoot(uiViewRoot);
    Assert.assertEquals("/test1.xhtml", FacesContext.getCurrentInstance().getViewRoot().getViewId());

    Assert.assertNotNull(FacesContext.getCurrentInstance().getExternalContext());
    Assert.assertNotNull(FacesContext.getCurrentInstance().getApplication());
    Assert.assertNotNull(FacesContext.getCurrentInstance().getELContext());
    Assert.assertNotNull(FacesContext.getCurrentInstance().getPartialViewContext());
    Assert.assertNotNull(FacesContext.getCurrentInstance().getRenderKit());
    Assert.assertNotNull(FacesContext.getCurrentInstance().getExceptionHandler());

    Assert.assertNull(FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("test"));
    FacesContext.getCurrentInstance().getExternalContext().getRequestMap().put("test", "1");
    Assert.assertEquals("1", FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("test"));

    Map applicationMap = FacesContext.getCurrentInstance().getExternalContext().getApplicationMap();
    if (identityHashCode == null)
    {
        identityHashCode = System.identityHashCode(applicationMap);
    }
    else
    {
        Assert.assertSame(identityHashCode, System.identityHashCode(applicationMap));
    }
}
 
Example #10
Source File: JsfContainerTest.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
@Test
public void secondTest()
{
    Assert.assertEquals(0, requestScopedBean.getCount());
    requestScopedBean.increaseCount();
    Assert.assertEquals(1, requestScopedBean.getCount());

    Assert.assertEquals(0, sessionScopedBean.getCount());
    sessionScopedBean.increaseCount();
    Assert.assertEquals(1, sessionScopedBean.getCount());

    UIViewRoot uiViewRoot = new UIViewRoot();
    uiViewRoot.setViewId("/viewId");
    FacesContext.getCurrentInstance().setViewRoot(uiViewRoot);
    Assert.assertNotNull(FacesContext.getCurrentInstance().getViewRoot());
    Assert.assertEquals("/viewId", FacesContext.getCurrentInstance().getViewRoot().getViewId());

    uiViewRoot.setViewId("/test2.xhtml");
    uiViewRoot.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
    FacesContext.getCurrentInstance().setViewRoot(uiViewRoot);

    FacesContext.getCurrentInstance().setViewRoot(uiViewRoot);
    Assert.assertEquals("/test2.xhtml", FacesContext.getCurrentInstance().getViewRoot().getViewId());

    Assert.assertNotNull(FacesContext.getCurrentInstance().getExternalContext());
    Assert.assertNotNull(FacesContext.getCurrentInstance().getApplication());
    Assert.assertNotNull(FacesContext.getCurrentInstance().getELContext());
    Assert.assertNotNull(FacesContext.getCurrentInstance().getPartialViewContext());
    Assert.assertNotNull(FacesContext.getCurrentInstance().getRenderKit());
    Assert.assertNotNull(FacesContext.getCurrentInstance().getExceptionHandler());

    Assert.assertNull(FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("test"));
    FacesContext.getCurrentInstance().getExternalContext().getRequestMap().put("test", "2");
    Assert.assertEquals("2", FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("test"));

    Map applicationMap = FacesContext.getCurrentInstance().getExternalContext().getApplicationMap();
    if (identityHashCode == null)
    {
        identityHashCode = System.identityHashCode(applicationMap);
    }
    else
    {
        Assert.assertSame(identityHashCode, System.identityHashCode(applicationMap));
    }
}