项目作者: joinfaces

项目描述 :
JoinFaces Maven Jar Example
高级语言: Java
项目地址: git://github.com/joinfaces/joinfaces-maven-jar-example.git
创建时间: 2016-05-12T12:02:29Z
项目社区:https://github.com/joinfaces/joinfaces-maven-jar-example

开源协议:

下载


JoinFaces Example

Build Status
Codecov
Bugs
License

This SAP (Single Page Application) illustrates Jakarta Faces usage inside JAR packaged Spring Boot Application.

JoinFaces autoconfigures
PrimeFaces,
PrimeFaces Extensions,
Apache MyFaces Tobago,
OmniFaces,
AdminFaces,
Mojarra and
MyFaces libraries to run at embedded
Tomcat,
Jetty or
Undertow.
It autoconfigures Weld,
Apache OpenWebBeans and
Rewrite too.

Run Example Application locally

1- Clone this project

  1. git clone https://github.com/joinfaces/joinfaces-maven-jar-example.git

2- Build

  1. mvn clean install

3- Run

  1. java -jar target/joinfaces-example-5.5.x.jar

4- Access starter page at http://localhost:8080/ This page can help you to choose the JoinFaces Starter that fits your needs. You may log in with credentials

User Password Roles
persapiens 123 ROLE_ADMIN
nyilmaz qwe ROLE_USER

Optional: If your IDE is showing build errors install Lombok

Key Files

pom.xml

Includes joinfaces starter dependency. All other jsf dependencies are included transitively.

  1. <properties>
  2. <joinfaces.version>5.5.0-m3</joinfaces.version>
  3. </properties>
  4. <dependencyManagement>
  5. <dependencies>
  6. <dependency>
  7. <groupId>org.joinfaces</groupId>
  8. <artifactId>joinfaces-bom</artifactId>
  9. <version>${joinfaces.version}</version>
  10. <type>pom</type>
  11. <scope>import</scope>
  12. </dependency>
  13. </dependencies>
  14. </dependencyManagement>
  15. <dependencies>
  16. <dependency>
  17. <groupId>org.joinfaces</groupId>
  18. <artifactId>faces-spring-boot-starter</artifactId>
  19. </dependency>
  20. </dependencies>

Note that security-spring-boot-starter is included to secure the application.

  1. <dependencies>
  2. <dependency>
  3. <groupId>org.joinfaces</groupId>
  4. <artifactId>security-spring-boot-starter</artifactId>
  5. </dependency>
  6. </dependencies>

src/main/resources/application.yml

Configure faces.PROJECT_STATE and faces.primefaces.THEME properties.

  1. joinfaces:
  2. faces:
  3. PROJECT_STAGE: Development
  4. primefaces:
  5. theme: overcast

src/main/resources/META-INF/resources/content/starter.xhtml

Example page to help you choose the right JoinFaces Starter for you.

Note that xhtml, js, css and images files should be located at src/main/resources/META-INF/resources directory to JSF use them.

Look at authorize and anonymous jsf spring security facelet tags in action to secure page information.

  1. <sec:authorize access="hasRole('ROLE_ADMIN')">
  2. <p:panelGrid columns="1" rendered="#{sec:isFullyAuthenticated()}">
  3. <p:link title="Logout" href="/logout">
  4. <p:outputLabel value="You are logged in as an ADMIN" ></p:outputLabel>
  5. </p:link>
  6. </p:panelGrid>
  7. </sec:authorize>

src/main/java/org/joinfaces/example/JoinFacesExampleApplication.java

Very simple spring main application. Only SpringBootApplication annotation is required.

  1. @SpringBootApplication
  2. public class JoinFacesExampleApplication {

src/main/java/org/joinfaces/example/SecurityConfig.java

Spring Security configuration class to secure authentication with credentials to persapiens and nyilmaz users.

src/main/java/org/joinfaces/example/view/StarterMBean.java

Managed bean using ViewScoped CDI annotation. The equivalent spring scope of ViewScoped annotation is configured automatically by JoinFaces Starter.

  1. @Named
  2. @ViewScoped
  3. public class StarterMBean {

Getting Help

Contributing