0

I am trying to use full java based configuration in my spring environment with primefaces 5.2. I also want to use the spark theme and layout. I nearly achieved all configurations but I'm stuck with two problems.

First (the most important one :)), I need to define the render kit aso in java config. This is the XML defintion.

<faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">

    <name>primefaces-spark</name>

    <component>
        <component-type>org.primefaces.component.SparkMenu</component-type>
        <component-class>org.primefaces.spark.component.menu.SparkMenu</component-class>
    </component>

    <render-kit>
        <renderer>
            <component-family>org.primefaces.component</component-family>
            <renderer-type>org.primefaces.component.SparkMenuRenderer</renderer-type>
            <renderer-class>org.primefaces.spark.component.menu.SparkMenuRenderer</renderer-class>
        </renderer>
    </render-kit>

</faces-config>

Has anyone an idea how I can set these values in pure java based config? I also tried to find a reference list of possible java based configuration properties but didn't find one :(. I also could live with an solution where I can mix my java based configuration with an XML based faces-config.xml as a workaround. But by only putting in an additional faces-config.xml with the information above into the WEB-INF does not work. It seems I need to do a little more than that :).

Second, I need to define Mime types which are defined in XML like this:

<mime-mapping>
        <extension>ttf</extension>
        <mime-type>application/font-sfnt</mime-type>
</mime-mapping>

This is not the most urgent thing as I can use a workaround by putting them into the web.xml (but I would prefer doing this in pure java config).

I also tried to use a class from spring boot (but I'm not programming a spring boot environment).

@Configuration
public class MimeMapper implements EmbeddedServletContainerCustomizer {
  @Override
  public void customize(ConfigurableEmbeddedServletContainer container) {
    MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
    mappings.add("ttf", "application/font-sfnt");
    mappings.add("svg#fontawesomeregular", "image/svg+xml");
    container.setMimeMappings(mappings);
  }
}

But this is not working, as it does not get loaded by the application (I tried it by referencing the configuration class in my AbstractAnnotationConfigDispatcherServletInitializer by adding it to the getRootConfigClasses() definition).

Thx for any suggestions,

BR,

  • Before you continue, read this: http://stackoverflow.com/questions/18744910/using-jsf-as-view-technology-of-spring-mvc – Kukeltje May 15 '15 at 10:50
  • You are right, this is no Spring MVC issue. I just removed the tag from the list. I only use the pure java config and no Spring MVC as this is handled by primefaces. – Gustav Hovards May 15 '15 at 11:56
  • Why would you want to do this programmatically? Do you do this for **all** PrimeFaces components to? All these are already configured **for you** in the PrimeFaces jar and spark jar. Why duplicate the effort, maintain it and what more – Kukeltje May 15 '15 at 12:02
  • I just try to convert the given theme and layout (with the demo app) into my existing infrastructure (with spring security, for example). And all other components are defined programmatically like this servletContext.setInitParameter("javax.faces.FACELETS_LIBRARIES", "/WEB-INF/primefaces-spark.taglib.xml"); – Gustav Hovards May 15 '15 at 12:06
  • Lucky me.... (never had to do this) – Kukeltje May 15 '15 at 12:08

0 Answers0