jsfspring-bootintegrationomnifaces

How to integrate OmniFaces with Spring Boot


I've found some tutorials about integrating JSF technology with Spring Boot, but it seems a rather involved work to get OmniFaces working with Spring Boot. Is it a good idea to integrate these two together at all?


Solution

  • OmniFaces is provided via JoinFaces.

    <dependency>
        <groupId>org.joinfaces</groupId>
        <artifactId>omnifaces-spring-boot-starter</artifactId>
        <version>5.x.x</version>
    </dependency>
    

    Or when you're still on Spring Boot 2.x:

    <dependency>
        <groupId>org.joinfaces</groupId>
        <artifactId>omnifaces3-spring-boot-starter</artifactId>
        <version>4.x.x</version>
    </dependency>
    

    In case you're primarily intertested in OmniFaces @ViewScoped, then you really need @Named instead of @Component in order to fully utilize its powers. And in order to be able to inject existing Spring managed beans via @Autowired into those @Named beans without any additional fuzz, you might want to install a CDI extension as described in this blog Using OmniFaces CDI @ViewScoped with unload/destroy in a Spring Boot project.

    See also: