├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── jsf-login-servlet-filter ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── codenotfound │ │ │ └── primefaces │ │ │ ├── SpringPrimeFacesApplication.java │ │ │ ├── config │ │ │ └── FilterConfig.java │ │ │ ├── controller │ │ │ └── UserManager.java │ │ │ ├── filter │ │ │ └── LoginFilter.java │ │ │ └── model │ │ │ └── User.java │ └── resources │ │ ├── META-INF │ │ └── resources │ │ │ ├── WEB-INF │ │ │ └── template │ │ │ │ └── links.xhtml │ │ │ ├── login.xhtml │ │ │ ├── logout.xhtml │ │ │ ├── secured │ │ │ └── home.xhtml │ │ │ └── unsecured.xhtml │ │ ├── application.yml │ │ └── logback.xml │ └── test │ └── java │ └── com │ └── codenotfound │ └── primefaces │ └── view │ ├── LoginFilterPage.java │ ├── LoginFilterTest.java │ ├── PageObject.java │ └── WebDriverTest.java ├── jsf-primefaces-apache-tomcat ├── README.md ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── codenotfound │ │ └── primefaces │ │ └── HelloWorld.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ └── helloworld.xhtml ├── jsf-primefaces-datatable-mysql ├── README.md ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── codenotfound │ │ └── primefaces │ │ ├── SpringPrimeFacesApplication.java │ │ ├── model │ │ └── Car.java │ │ ├── repository │ │ └── CarRepository.java │ │ └── view │ │ └── CarsView.java │ └── resources │ ├── META-INF │ └── resources │ │ └── cars.xhtml │ ├── application.yml │ └── data.sql ├── jsf-primefaces-datatable ├── README.md ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── codenotfound │ │ ├── SpringPrimeFacesApplication.java │ │ └── primefaces │ │ ├── Car.java │ │ ├── CarRepository.java │ │ └── CarsView.java │ └── resources │ ├── META-INF │ └── resources │ │ └── cars.xhtml │ └── data.sql ├── jsf-primefaces-hello-world ├── README.md ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── codenotfound │ │ ├── SpringPrimeFacesApplication.java │ │ └── primefaces │ │ └── HelloWorld.java │ └── resources │ └── META-INF │ └── resources │ └── helloworld.xhtml ├── jsf-primefaces-jetty ├── README.md ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── codenotfound │ │ └── primefaces │ │ └── HelloWorld.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ └── helloworld.xhtml ├── jsf-primefaces-spring-security ├── README.md ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── codenotfound │ │ ├── SpringPrimeFacesApplication.java │ │ └── primefaces │ │ ├── HelloWorld.java │ │ ├── SecurityConfig.java │ │ └── WelcomePageRedirect.java │ └── resources │ ├── META-INF │ └── resources │ │ ├── css │ │ ├── login.css │ │ └── main.css │ │ ├── helloworld.xhtml │ │ └── login.xhtml │ └── logback.xml ├── jsf-primefaces-standalone-tomcat ├── README.md ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── codenotfound │ │ ├── SpringPrimeFacesApplication.java │ │ └── primefaces │ │ └── HelloWorld.java │ └── webapp │ └── helloworld.xhtml ├── jsf-primefaces-themes ├── README.md ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── codenotfound │ │ ├── SpringPrimeFacesApplication.java │ │ └── primefaces │ │ └── HelloWorld.java │ └── resources │ ├── META-INF │ └── resources │ │ └── helloworld.xhtml │ └── application.yml ├── jsf-primefaces-unit-testing-selenium ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── codenotfound │ │ │ ├── SpringPrimeFacesApplication.java │ │ │ └── primefaces │ │ │ └── HelloWorld.java │ └── resources │ │ └── META-INF │ │ └── resources │ │ └── helloworld.xhtml │ └── test │ ├── java │ └── com │ │ └── codenotfound │ │ ├── PageObject.java │ │ ├── WebDriverUtil.java │ │ └── primefaces │ │ ├── HelloWorldPage.java │ │ └── HelloWorldTest.java │ └── resources │ └── logback-test.xml ├── jsf-primefaces-websphere-application-server ├── README.md ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── codenotfound │ │ └── primefaces │ │ └── HelloWorld.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ └── helloworld.xhtml ├── jsf-primefaces-welcome-page-redirect ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── codenotfound │ │ │ ├── SpringPrimeFacesApplication.java │ │ │ └── primefaces │ │ │ ├── HelloWorld.java │ │ │ └── WelcomePageRedirect.java │ └── resources │ │ └── META-INF │ │ └── resources │ │ └── helloworld.xhtml │ └── test │ ├── java │ └── com │ │ └── codenotfound │ │ ├── WebDriverUtil.java │ │ └── primefaces │ │ └── HelloWorldTest.java │ └── resources │ └── logback-test.xml └── jsf-primefaces-wildfly ├── README.md ├── pom.xml └── src └── main ├── java └── com │ └── codenotfound │ └── primefaces │ └── HelloWorld.java └── webapp ├── WEB-INF ├── jboss-web.xml └── web.xml └── helloworld.xhtml /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | 3 | # Mobile Tools for Java (J2ME) 4 | .mtj.tmp/ 5 | 6 | # Package Files # 7 | *.jar 8 | *.war 9 | *.ear 10 | 11 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 12 | hs_err_pid* 13 | 14 | # Maven # 15 | target/ 16 | pom.xml.tag 17 | pom.xml.releaseBackup 18 | pom.xml.next 19 | release.properties 20 | 21 | # Eclipse # 22 | .classpath 23 | .project 24 | .settings/ 25 | 26 | # Logs # 27 | *.log 28 | *.log.* 29 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | sudo: false 3 | install: true 4 | 5 | jdk: 6 | - oraclejdk8 7 | 8 | addons: 9 | sonarqube: 10 | organization: code-not-found-jsf-primefaces 11 | token: 12 | secure: $SONAR_TOKEN 13 | 14 | env: 15 | - PROJECT_DIR=jsf-login-servlet-filter 16 | - PROJECT_DIR=jsf-primefaces-unit-testing-selenium 17 | - PROJECT_DIR=jsf-primefaces-welcome-page-redirect 18 | 19 | script: 20 | - cd $PROJECT_DIR 21 | - mvn test -B 22 | - mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install sonar:sonar 23 | 24 | cache: 25 | directories: 26 | - $HOME/.m2/repository 27 | - $HOME/.sonar/cache 28 | 29 | notifications: 30 | email: false 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 code-not-found 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JSF Primefaces Tutorials 2 | 3 | [![Build Status](https://travis-ci.org/code-not-found/jsf-primefaces.svg?branch=master)](https://travis-ci.org/code-not-found/jsf-primefaces) 4 | [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE) 5 | 6 | This repository contains all the source code for the JSF Primefaces examples posted on [https://codenotfound.com/jsf-primefaces-tutorials](https://codenotfound.com/jsf-primefaces-tutorials) 7 | 8 | In case of questions or remarks please leave a comment in the respective blog post or open a GitHub issue. Thanks! 9 | -------------------------------------------------------------------------------- /jsf-login-servlet-filter/README.md: -------------------------------------------------------------------------------- 1 | # jsf-login-servlet-filter 2 | 3 | [![Quality Gate](https://sonarcloud.io/api/badges/gate?key=com.codenotfound:jsf-login-servlet-filter)](https://sonarcloud.io/dashboard/index/com.codenotfound:jsf-login-servlet-filter) 4 | 5 | A detailed step-by-step tutorial on how to implement a JSF login servlet filter example using PrimeFaces, Spring Boot, and Maven. 6 | 7 | [https://www.codenotfound.com/jsf-login-servlet-filter-example.html](https://www.codenotfound.com/jsf-login-servlet-filter-example.html) 8 | -------------------------------------------------------------------------------- /jsf-login-servlet-filter/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.codenotfound 7 | jsf-login-servlet-filter 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | jsf-login-servlet-filter 12 | JSF - Login Servlet Filter Example 13 | https://www.codenotfound.com/jsf-login-servlet-filter-example.html 14 | 15 | 16 | org.joinfaces 17 | jsf-spring-boot-parent 18 | 2.4.1 19 | 20 | 21 | 22 | 23 | 1.8 24 | 25 | 3.8.1 26 | 2.52.0 27 | 28 | 29 | 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-starter 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-starter-test 38 | test 39 | 40 | 41 | 42 | org.joinfaces 43 | jsf-spring-boot-starter 44 | 45 | 46 | 47 | org.seleniumhq.selenium 48 | selenium-java 49 | ${selenium-java.version} 50 | test 51 | 52 | 53 | org.seleniumhq.selenium 54 | selenium-htmlunit-driver 55 | ${selenium-htmlunit-driver.version} 56 | test 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | org.springframework.boot 65 | spring-boot-maven-plugin 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /jsf-login-servlet-filter/src/main/java/com/codenotfound/primefaces/SpringPrimeFacesApplication.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound.primefaces; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringPrimeFacesApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringPrimeFacesApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /jsf-login-servlet-filter/src/main/java/com/codenotfound/primefaces/config/FilterConfig.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound.primefaces.config; 2 | 3 | import org.springframework.boot.web.servlet.FilterRegistrationBean; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | import com.codenotfound.primefaces.filter.LoginFilter; 8 | 9 | @Configuration 10 | public class FilterConfig { 11 | 12 | @Bean 13 | public FilterRegistrationBean loginFilter() { 14 | FilterRegistrationBean registration = 15 | new FilterRegistrationBean(); 16 | registration.setFilter(new LoginFilter()); 17 | registration.addUrlPatterns("/secured/*"); 18 | return registration; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /jsf-login-servlet-filter/src/main/java/com/codenotfound/primefaces/controller/UserManager.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound.primefaces.controller; 2 | 3 | import java.io.Serializable; 4 | 5 | import javax.faces.application.FacesMessage; 6 | import javax.faces.bean.ManagedBean; 7 | import javax.faces.bean.SessionScoped; 8 | import javax.faces.context.FacesContext; 9 | 10 | import org.slf4j.Logger; 11 | import org.slf4j.LoggerFactory; 12 | 13 | import com.codenotfound.primefaces.model.User; 14 | 15 | @ManagedBean 16 | @SessionScoped 17 | public class UserManager implements Serializable { 18 | 19 | private static final long serialVersionUID = -9107952969237527819L; 20 | 21 | private static final Logger LOGGER = 22 | LoggerFactory.getLogger(UserManager.class); 23 | 24 | public static final String HOME_PAGE_REDIRECT = 25 | "/secured/home.xhtml?faces-redirect=true"; 26 | public static final String LOGOUT_PAGE_REDIRECT = 27 | "/logout.xhtml?faces-redirect=true"; 28 | 29 | private String userId; 30 | private String userPassword; 31 | 32 | private User currentUser; 33 | 34 | public String login() { 35 | // lookup the user based on user name and user password 36 | currentUser = find(userId, userPassword); 37 | 38 | if (currentUser != null) { 39 | LOGGER.info("login successful for '{}'", userId); 40 | 41 | return HOME_PAGE_REDIRECT; 42 | } else { 43 | LOGGER.info("login failed for '{}'", userId); 44 | FacesContext.getCurrentInstance().addMessage(null, 45 | new FacesMessage(FacesMessage.SEVERITY_WARN, "Login failed", 46 | "Invalid or unknown credentials.")); 47 | 48 | return null; 49 | } 50 | } 51 | 52 | public String logout() { 53 | String identifier = userId; 54 | 55 | // invalidate the session 56 | LOGGER.debug("invalidating session for '{}'", identifier); 57 | FacesContext.getCurrentInstance().getExternalContext() 58 | .invalidateSession(); 59 | 60 | LOGGER.info("logout successful for '{}'", identifier); 61 | return LOGOUT_PAGE_REDIRECT; 62 | } 63 | 64 | public boolean isLoggedIn() { 65 | return currentUser != null; 66 | } 67 | 68 | public String isLoggedInForwardHome() { 69 | if (isLoggedIn()) { 70 | return HOME_PAGE_REDIRECT; 71 | } 72 | 73 | return null; 74 | } 75 | 76 | private User find(String userId, String password) { 77 | User result = null; 78 | 79 | // TODO to be replaced with actual retrieval of user 80 | if ("john.doe".equalsIgnoreCase(userId) 81 | && "1234".equals(password)) { 82 | result = new User(userId, "John", "Doe"); 83 | } 84 | 85 | return result; 86 | } 87 | 88 | public String getUserId() { 89 | return userId; 90 | } 91 | 92 | public void setUserId(String userId) { 93 | this.userId = userId; 94 | } 95 | 96 | public String getUserPassword() { 97 | return userPassword; 98 | } 99 | 100 | public void setUserPassword(String userPassword) { 101 | this.userPassword = userPassword; 102 | } 103 | 104 | public User getCurrentUser() { 105 | return currentUser; 106 | } 107 | 108 | // do not provide a setter for currentUser! 109 | } 110 | -------------------------------------------------------------------------------- /jsf-login-servlet-filter/src/main/java/com/codenotfound/primefaces/filter/LoginFilter.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound.primefaces.filter; 2 | 3 | import java.io.IOException; 4 | 5 | import javax.servlet.Filter; 6 | import javax.servlet.FilterChain; 7 | import javax.servlet.FilterConfig; 8 | import javax.servlet.ServletException; 9 | import javax.servlet.ServletRequest; 10 | import javax.servlet.ServletResponse; 11 | import javax.servlet.http.HttpServletRequest; 12 | import javax.servlet.http.HttpServletResponse; 13 | 14 | import org.slf4j.Logger; 15 | import org.slf4j.LoggerFactory; 16 | 17 | import com.codenotfound.primefaces.controller.UserManager; 18 | 19 | public class LoginFilter implements Filter { 20 | 21 | private static final Logger LOGGER = 22 | LoggerFactory.getLogger(LoginFilter.class); 23 | 24 | public static final String LOGIN_PAGE = "/login.xhtml"; 25 | 26 | @Override 27 | public void doFilter(ServletRequest servletRequest, 28 | ServletResponse servletResponse, FilterChain filterChain) 29 | throws IOException, ServletException { 30 | 31 | HttpServletRequest httpServletRequest = 32 | (HttpServletRequest) servletRequest; 33 | HttpServletResponse httpServletResponse = 34 | (HttpServletResponse) servletResponse; 35 | 36 | // managed bean name is exactly the session attribute name 37 | UserManager userManager = (UserManager) httpServletRequest 38 | .getSession().getAttribute("userManager"); 39 | 40 | if (userManager != null) { 41 | if (userManager.isLoggedIn()) { 42 | LOGGER.debug("user is logged in"); 43 | // user is logged in, continue request 44 | filterChain.doFilter(servletRequest, servletResponse); 45 | } else { 46 | LOGGER.debug("user is not logged in"); 47 | // user is not logged in, redirect to login page 48 | httpServletResponse.sendRedirect( 49 | httpServletRequest.getContextPath() + LOGIN_PAGE); 50 | } 51 | } else { 52 | LOGGER.debug("userManager not found"); 53 | // user is not logged in, redirect to login page 54 | httpServletResponse.sendRedirect( 55 | httpServletRequest.getContextPath() + LOGIN_PAGE); 56 | } 57 | } 58 | 59 | @Override 60 | public void init(FilterConfig arg0) throws ServletException { 61 | LOGGER.debug("loginFilter initialized"); 62 | } 63 | 64 | @Override 65 | public void destroy() { 66 | // close resources 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /jsf-login-servlet-filter/src/main/java/com/codenotfound/primefaces/model/User.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound.primefaces.model; 2 | 3 | import java.io.Serializable; 4 | 5 | public class User implements Serializable { 6 | 7 | private static final long serialVersionUID = -1389546558353914770L; 8 | 9 | private String userId; 10 | private String firstName; 11 | private String lastName; 12 | 13 | public User(String userId, String firstName, String lastName) { 14 | this.userId = userId; 15 | this.firstName = firstName; 16 | this.lastName = lastName; 17 | } 18 | 19 | public String getUserId() { 20 | return userId; 21 | } 22 | 23 | public void setUserId(String userId) { 24 | this.userId = userId; 25 | } 26 | 27 | public String getFirstName() { 28 | return firstName; 29 | } 30 | 31 | public void setFirstName(String firstName) { 32 | this.firstName = firstName; 33 | } 34 | 35 | public String getLastName() { 36 | return lastName; 37 | } 38 | 39 | public void setLastName(String lastName) { 40 | this.lastName = lastName; 41 | } 42 | 43 | public String getName() { 44 | return firstName + " " + lastName; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /jsf-login-servlet-filter/src/main/resources/META-INF/resources/WEB-INF/template/links.xhtml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 |

6 | Click following link to go to the login 8 | page. 9 |

10 |

11 | Click following link to go to the logout 13 | page. 14 |

15 |

16 | Click following link to go to the home 18 | page. 19 |

20 |

21 | Click following link to go to the unsecured 23 | page. 24 |

25 | 26 |
27 | -------------------------------------------------------------------------------- /jsf-login-servlet-filter/src/main/resources/META-INF/resources/login.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | Login 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 26 | 27 | 28 | 29 | 30 | 31 | 33 | 34 | 35 | 36 | 37 | 38 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /jsf-login-servlet-filter/src/main/resources/META-INF/resources/logout.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | Logout 10 | 11 | 12 | 13 | 14 | 15 | 16 |

You are logged out.

17 |
18 | 19 | 20 |

You are still logged in, click below button to log out!

21 | 22 |
23 |
24 | 25 | 26 | 27 |
28 | 29 | -------------------------------------------------------------------------------- /jsf-login-servlet-filter/src/main/resources/META-INF/resources/secured/home.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | Home 10 | 11 | 12 | 13 | 14 | 15 | 16 |

17 | 19 |

20 | 21 | 22 |
23 |
24 | 25 | 26 | 27 |
28 | 29 | -------------------------------------------------------------------------------- /jsf-login-servlet-filter/src/main/resources/META-INF/resources/unsecured.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | Unsecured 10 | 11 | 12 | 13 | 14 | 15 |

This page is not secured and can be used to display 16 | information to users that do not have login credentials.

17 |
18 | 19 | 20 | 21 |
22 | 23 | -------------------------------------------------------------------------------- /jsf-login-servlet-filter/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | context-path: /codenotfound 3 | port: 9090 4 | -------------------------------------------------------------------------------- /jsf-login-servlet-filter/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /jsf-login-servlet-filter/src/test/java/com/codenotfound/primefaces/view/LoginFilterPage.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound.primefaces.view; 2 | 3 | import org.openqa.selenium.WebDriver; 4 | import org.openqa.selenium.WebElement; 5 | import org.openqa.selenium.support.FindBy; 6 | import org.openqa.selenium.support.How; 7 | import org.openqa.selenium.support.PageFactory; 8 | 9 | public class LoginFilterPage extends PageObject { 10 | 11 | @FindBy(id = "login-form:user-name") 12 | private WebElement userNameInput; 13 | 14 | @FindBy(id = "login-form:password") 15 | private WebElement passwordInput; 16 | 17 | @FindBy(id = "login-form:login") 18 | private WebElement loginButton; 19 | 20 | @FindBy(id = "home-form:welcome-message") 21 | private WebElement welcomeMessage; 22 | 23 | @FindBy(how = How.CLASS_NAME, using = "ui-messages-warn-summary") 24 | private WebElement warning; 25 | 26 | @FindBy(id = "unsecured-message_content") 27 | private WebElement unsecuredMessage; 28 | 29 | public LoginFilterPage(WebDriver driver) { 30 | super(driver); 31 | } 32 | 33 | public void login(String userName, String password) { 34 | userNameInput.sendKeys(userName); 35 | passwordInput.sendKeys(password); 36 | 37 | loginButton.submit(); 38 | 39 | PageFactory.initElements(driver, this); 40 | } 41 | 42 | public String getWelcomeMessage() { 43 | return welcomeMessage.getText(); 44 | } 45 | 46 | public String getWarning() { 47 | return warning.getText(); 48 | } 49 | 50 | public String getUnsecuredMessage() { 51 | return unsecuredMessage.getText(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /jsf-login-servlet-filter/src/test/java/com/codenotfound/primefaces/view/LoginFilterTest.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound.primefaces.view; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.boot.test.context.SpringBootTest; 8 | import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; 9 | import org.springframework.test.annotation.DirtiesContext; 10 | import org.springframework.test.context.junit4.SpringRunner; 11 | 12 | @RunWith(SpringRunner.class) 13 | @SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT) 14 | @DirtiesContext 15 | public class LoginFilterTest extends WebDriverTest { 16 | 17 | @Test 18 | public void testLogin() { 19 | driver.get("http://localhost:9090/codenotfound/login.xhtml"); 20 | 21 | LoginFilterPage page = new LoginFilterPage(driver); 22 | page.login("john.doe", "1234"); 23 | 24 | assertThat(page.getWelcomeMessage()) 25 | .isEqualTo("Welcome, John Doe!"); 26 | } 27 | 28 | @Test 29 | public void testLoginFailed() { 30 | driver.get("http://localhost:9090/codenotfound/login.xhtml"); 31 | 32 | LoginFilterPage page = new LoginFilterPage(driver); 33 | page.login("jane.doe", "1234"); 34 | 35 | assertThat(page.getWarning()).isEqualTo("Login failed"); 36 | } 37 | 38 | @Test 39 | public void testUnsecured() { 40 | driver.get("http://localhost:9090/codenotfound/unsecured.xhtml"); 41 | 42 | LoginFilterPage page = new LoginFilterPage(driver); 43 | 44 | assertThat(page.getUnsecuredMessage()).isEqualTo( 45 | "This page is not secured and can be used to display information to users that do not have login credentials."); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /jsf-login-servlet-filter/src/test/java/com/codenotfound/primefaces/view/PageObject.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound.primefaces.view; 2 | 3 | import org.openqa.selenium.WebDriver; 4 | import org.openqa.selenium.support.PageFactory; 5 | 6 | public class PageObject { 7 | protected WebDriver driver; 8 | 9 | public PageObject(WebDriver driver) { 10 | this.driver = driver; 11 | PageFactory.initElements(driver, this); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /jsf-login-servlet-filter/src/test/java/com/codenotfound/primefaces/view/WebDriverTest.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound.primefaces.view; 2 | 3 | import java.util.concurrent.TimeUnit; 4 | 5 | import org.junit.After; 6 | import org.junit.AfterClass; 7 | import org.junit.BeforeClass; 8 | import org.openqa.selenium.WebDriver; 9 | import org.openqa.selenium.htmlunit.HtmlUnitDriver; 10 | 11 | public class WebDriverTest { 12 | 13 | protected static WebDriver driver; 14 | 15 | @BeforeClass 16 | public static void setUp() { 17 | driver = new HtmlUnitDriver(); 18 | driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); 19 | } 20 | 21 | @After 22 | public void cleanUp() { 23 | driver.manage().deleteAllCookies(); 24 | } 25 | 26 | @AfterClass 27 | public static void tearDown() { 28 | driver.close(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /jsf-primefaces-apache-tomcat/README.md: -------------------------------------------------------------------------------- 1 | # jsf-primefaces-apache-tomcat 2 | 3 | A detailed step-by-step tutorial in which we build and run a Hello World PrimeFaces example using Apache Tomcat and Maven. 4 | 5 | [https://www.codenotfound.com/jsf-primefaces-hello-world-example-apache-tomcat.html](https://www.codenotfound.com/jsf-primefaces-hello-world-example-apache-tomcat.html) 6 | -------------------------------------------------------------------------------- /jsf-primefaces-apache-tomcat/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | com.codenotfound 6 | jsf-primefaces-apache-tomcat 7 | 0.0.1-SNAPSHOT 8 | war 9 | 10 | JSF - PrimeFaces Hello World Example using Apache Tomcat and Maven 11 | https://www.codenotfound.com/jsf-primefaces-hello-world-example-apache-tomcat.html 12 | 13 | 14 | UTF-8 15 | 1.8 16 | 17 | 3.1.0 18 | 2.2.15 19 | 6.1 20 | 21 | 3.7.0 22 | 2.2 23 | 24 | 25 | 26 | 27 | 28 | javax.servlet 29 | javax.servlet-api 30 | ${servlet.version} 31 | provided 32 | 33 | 34 | 35 | com.sun.faces 36 | jsf-api 37 | ${jsf.version} 38 | compile 39 | 40 | 41 | com.sun.faces 42 | jsf-impl 43 | ${jsf.version} 44 | compile 45 | 46 | 47 | 48 | org.primefaces 49 | primefaces 50 | ${primefaces.version} 51 | 52 | 53 | 54 | 55 | 56 | 57 | org.apache.maven.plugins 58 | maven-compiler-plugin 59 | ${maven-compiler-plugin.version} 60 | 61 | ${java.version} 62 | ${java.version} 63 | 64 | 65 | 66 | 67 | org.apache.tomcat.maven 68 | tomcat7-maven-plugin 69 | ${tomcat7-maven-plugin.version} 70 | 71 | 9090 72 | /codenotfound 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /jsf-primefaces-apache-tomcat/src/main/java/com/codenotfound/primefaces/HelloWorld.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound.primefaces; 2 | 3 | import javax.faces.bean.ManagedBean; 4 | 5 | @ManagedBean 6 | public class HelloWorld { 7 | 8 | private String firstName = "John"; 9 | private String lastName = "Doe"; 10 | 11 | public String getFirstName() { 12 | return firstName; 13 | } 14 | 15 | public void setFirstName(String firstName) { 16 | this.firstName = firstName; 17 | } 18 | 19 | public String getLastName() { 20 | return lastName; 21 | } 22 | 23 | public void setLastName(String lastName) { 24 | this.lastName = lastName; 25 | } 26 | 27 | public String showGreeting() { 28 | return "Hello " + firstName + " " + lastName + "!"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /jsf-primefaces-apache-tomcat/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | helloworld.xhtml 8 | 9 | 10 | 11 | 12 | faces-servlet 13 | javax.faces.webapp.FacesServlet 14 | 1 15 | 16 | 17 | 18 | 19 | faces-servlet 20 | *.xhtml 21 | 22 | 23 | -------------------------------------------------------------------------------- /jsf-primefaces-apache-tomcat/src/main/webapp/helloworld.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | PrimeFaces Hello World Example 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 24 | 25 | 26 | 27 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /jsf-primefaces-datatable-mysql/README.md: -------------------------------------------------------------------------------- 1 | # jsf-primefaces-datatable-mysql 2 | 3 | A detailed step-by-step tutorial on how to implement a PrimeFaces DataTable using MySQL, Spring Data JPA, Spring Boot, and Maven. 4 | 5 | [https://www.codenotfound.com/jsf-primefaces/](https://www.codenotfound.com/jsf-primefaces/) 6 | -------------------------------------------------------------------------------- /jsf-primefaces-datatable-mysql/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.codenotfound 7 | jsf-primefaces-datatable-mysql 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | jsf-primefaces-datatable-mysql 12 | JSF - PrimeFaces MySQL DataTable Example 13 | https://www.codenotfound.com/jsf-primefaces/ 14 | 15 | 16 | org.joinfaces 17 | jsf-spring-boot-parent 18 | 2.4.1 19 | 20 | 21 | 22 | 23 | 1.8 24 | 25 | 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-starter-data-jpa 35 | 36 | 37 | 38 | mysql 39 | mysql-connector-java 40 | 41 | 42 | 43 | org.joinfaces 44 | jsf-spring-boot-starter 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | org.springframework.boot 53 | spring-boot-maven-plugin 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /jsf-primefaces-datatable-mysql/src/main/java/com/codenotfound/primefaces/SpringPrimeFacesApplication.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound.primefaces; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringPrimeFacesApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringPrimeFacesApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /jsf-primefaces-datatable-mysql/src/main/java/com/codenotfound/primefaces/model/Car.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound.primefaces.model; 2 | 3 | import javax.persistence.Entity; 4 | import javax.persistence.GeneratedValue; 5 | import javax.persistence.Id; 6 | 7 | @Entity(name = "Car") 8 | public class Car { 9 | 10 | @Id 11 | @GeneratedValue 12 | private Long id; 13 | 14 | private String brand; 15 | private int year; 16 | private String color; 17 | 18 | public Car() {} 19 | 20 | public Car(Long id, String brand, int year, String color) { 21 | this.id = id; 22 | this.brand = brand; 23 | this.year = year; 24 | this.color = color; 25 | } 26 | 27 | public Long getId() { 28 | return id; 29 | } 30 | 31 | public void setId(Long id) { 32 | this.id = id; 33 | } 34 | 35 | public String getBrand() { 36 | return brand; 37 | } 38 | 39 | public void setBrand(String brand) { 40 | this.brand = brand; 41 | } 42 | 43 | public int getYear() { 44 | return year; 45 | } 46 | 47 | public void setYear(int year) { 48 | this.year = year; 49 | } 50 | 51 | public String getColor() { 52 | return color; 53 | } 54 | 55 | public void setColor(String color) { 56 | this.color = color; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /jsf-primefaces-datatable-mysql/src/main/java/com/codenotfound/primefaces/repository/CarRepository.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound.primefaces.repository; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import org.springframework.stereotype.Repository; 5 | 6 | import com.codenotfound.primefaces.model.Car; 7 | 8 | @Repository 9 | public interface CarRepository extends JpaRepository { 10 | } 11 | -------------------------------------------------------------------------------- /jsf-primefaces-datatable-mysql/src/main/java/com/codenotfound/primefaces/view/CarsView.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound.primefaces.view; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | import javax.annotation.PostConstruct; 7 | import javax.faces.bean.ViewScoped; 8 | import javax.inject.Named; 9 | 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | 12 | import com.codenotfound.primefaces.model.Car; 13 | import com.codenotfound.primefaces.repository.CarRepository; 14 | 15 | @Named 16 | @ViewScoped 17 | public class CarsView implements Serializable { 18 | 19 | private static final long serialVersionUID = 1L; 20 | 21 | @Autowired 22 | private CarRepository carRepository; 23 | 24 | private List cars; 25 | 26 | @PostConstruct 27 | public void init() { 28 | cars = carRepository.findAll(); 29 | } 30 | 31 | public List getCars() { 32 | return cars; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /jsf-primefaces-datatable-mysql/src/main/resources/META-INF/resources/cars.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | PrimeFaces DataTable Example 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /jsf-primefaces-datatable-mysql/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | context-path: /codenotfound 3 | port: 9090 4 | 5 | spring: 6 | datasource: 7 | url: jdbc:mysql://localhost:3306/cnf 8 | username: codenotfound 9 | password: p455w0rd 10 | jpa: 11 | hibernate: 12 | ddl-auto: create-drop 13 | -------------------------------------------------------------------------------- /jsf-primefaces-datatable-mysql/src/main/resources/data.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO car (brand, year, color) VALUES 2 | ('Audi', 1992, 'Red'), 3 | ('Fiat', 2001, 'Red'), 4 | ('Mercedes', 1991, 'Brown'), 5 | ('Fiat', 1962, 'Black'), 6 | ('Renault', 1997, 'Brown'), 7 | ('Renault', 1967, 'Maroon'), 8 | ('Renault', 1986, 'Yellow'), 9 | ('BMW', 1970, 'Maroon'), 10 | ('Fiat', 1990, 'Silver'), 11 | ('Renault', 1972, 'Black'); 12 | -------------------------------------------------------------------------------- /jsf-primefaces-datatable/README.md: -------------------------------------------------------------------------------- 1 | # jsf-primefaces-datatable 2 | 3 | A detailed step-by-step tutorial on how to implement a PrimeFaces DataTable using Spring Data JPA, Spring Boot, and Maven. 4 | 5 | [https://codenotfound.com/jsf-primefaces-datatable-example.html](https://codenotfound.com/jsf-primefaces-datatable-example.html) 6 | -------------------------------------------------------------------------------- /jsf-primefaces-datatable/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.codenotfound 7 | jsf-primefaces-datatable 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | jsf-primefaces-datatable 12 | JSF PrimeFaces DataTable Example 13 | https://codenotfound.com/jsf-primefaces-datatable-example.html 14 | 15 | 16 | org.springframework.boot 17 | spring-boot-starter-parent 18 | 2.1.0.RELEASE 19 | 20 | 21 | 22 | 23 | UTF-8 24 | UTF-8 25 | 1.8 26 | 3.3.0-rc2 27 | 28 | 29 | 30 | 31 | 32 | org.joinfaces 33 | joinfaces-dependencies 34 | ${joinfaces.version} 35 | pom 36 | import 37 | 38 | 39 | 40 | 41 | 42 | 43 | org.joinfaces 44 | primefaces-spring-boot-starter 45 | 46 | 47 | javax.enterprise 48 | cdi-api 49 | 50 | 51 | org.springframework.boot 52 | spring-boot-starter-data-jpa 53 | 54 | 55 | com.h2database 56 | h2 57 | 58 | 59 | 60 | 61 | 62 | 63 | org.springframework.boot 64 | spring-boot-maven-plugin 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /jsf-primefaces-datatable/src/main/java/com/codenotfound/SpringPrimeFacesApplication.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringPrimeFacesApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringPrimeFacesApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /jsf-primefaces-datatable/src/main/java/com/codenotfound/primefaces/Car.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound.primefaces; 2 | 3 | import java.io.Serializable; 4 | import javax.persistence.Entity; 5 | import javax.persistence.GeneratedValue; 6 | import javax.persistence.GenerationType; 7 | import javax.persistence.Id; 8 | 9 | @Entity(name = "Car") 10 | public class Car implements Serializable { 11 | 12 | private static final long serialVersionUID = 1L; 13 | 14 | @Id 15 | @GeneratedValue(strategy = GenerationType.IDENTITY) 16 | private Long id; 17 | 18 | private String brand; 19 | 20 | private int year; 21 | 22 | private String color; 23 | 24 | public Car() {} 25 | 26 | public Car(Long id, String brand, int year, String color) { 27 | this.id = id; 28 | this.brand = brand; 29 | this.year = year; 30 | this.color = color; 31 | } 32 | 33 | public Long getId() { 34 | return id; 35 | } 36 | 37 | public void setId(Long id) { 38 | this.id = id; 39 | } 40 | 41 | public String getBrand() { 42 | return brand; 43 | } 44 | 45 | public void setBrand(String brand) { 46 | this.brand = brand; 47 | } 48 | 49 | public int getYear() { 50 | return year; 51 | } 52 | 53 | public void setYear(int year) { 54 | this.year = year; 55 | } 56 | 57 | public String getColor() { 58 | return color; 59 | } 60 | 61 | public void setColor(String color) { 62 | this.color = color; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /jsf-primefaces-datatable/src/main/java/com/codenotfound/primefaces/CarRepository.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound.primefaces; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import org.springframework.stereotype.Repository; 5 | 6 | @Repository 7 | public interface CarRepository extends JpaRepository { 8 | } 9 | -------------------------------------------------------------------------------- /jsf-primefaces-datatable/src/main/java/com/codenotfound/primefaces/CarsView.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound.primefaces; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | import javax.annotation.PostConstruct; 6 | import javax.faces.view.ViewScoped; 7 | import javax.inject.Inject; 8 | import javax.inject.Named; 9 | 10 | @Named 11 | @ViewScoped 12 | public class CarsView implements Serializable { 13 | 14 | private static final long serialVersionUID = 1L; 15 | 16 | @Inject 17 | private CarRepository carRepository; 18 | 19 | private List cars; 20 | 21 | @PostConstruct 22 | public void init() { 23 | cars = carRepository.findAll(); 24 | } 25 | 26 | public List getCars() { 27 | return cars; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /jsf-primefaces-datatable/src/main/resources/META-INF/resources/cars.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | PrimeFaces DataTable Example 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /jsf-primefaces-datatable/src/main/resources/data.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO car (brand, year, color) VALUES 2 | ('Audi', 1992, 'Red'), 3 | ('Fiat', 2001, 'Red'), 4 | ('Mercedes', 1991, 'Brown'), 5 | ('Fiat', 1962, 'Black'), 6 | ('Renault', 1997, 'Brown'), 7 | ('Renault', 1967, 'Maroon'), 8 | ('Renault', 1986, 'Yellow'), 9 | ('BMW', 1970, 'Maroon'), 10 | ('Fiat', 1990, 'Silver'), 11 | ('Renault', 1972, 'Black'); 12 | -------------------------------------------------------------------------------- /jsf-primefaces-hello-world/README.md: -------------------------------------------------------------------------------- 1 | # jsf-primefaces-hello-world 2 | 3 | A detailed step-by-step tutorial on how to implement a Hello World PrimeFaces for JSF example using Spring Boot and Maven. 4 | 5 | [https://codenotfound.com/jsf-primefaces-example.html](https://codenotfound.com/jsf-primefaces-example.html) 6 | -------------------------------------------------------------------------------- /jsf-primefaces-hello-world/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.codenotfound 7 | jsf-primefaces-hello-world 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | jsf-primefaces-hello-world 12 | JSF PrimeFaces Hello World Example 13 | https://codenotfound.com/jsf-primefaces-example.html 14 | 15 | 16 | org.springframework.boot 17 | spring-boot-starter-parent 18 | 2.1.0.RELEASE 19 | 20 | 21 | 22 | 23 | UTF-8 24 | UTF-8 25 | 1.8 26 | 3.3.0-rc2 27 | 28 | 29 | 30 | 31 | 32 | org.joinfaces 33 | joinfaces-dependencies 34 | ${joinfaces.version} 35 | pom 36 | import 37 | 38 | 39 | 40 | 41 | 42 | 43 | org.joinfaces 44 | primefaces-spring-boot-starter 45 | 46 | 47 | javax.enterprise 48 | cdi-api 49 | 50 | 51 | 52 | 53 | 54 | 55 | org.springframework.boot 56 | spring-boot-maven-plugin 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /jsf-primefaces-hello-world/src/main/java/com/codenotfound/SpringPrimeFacesApplication.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringPrimeFacesApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringPrimeFacesApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /jsf-primefaces-hello-world/src/main/java/com/codenotfound/primefaces/HelloWorld.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound.primefaces; 2 | 3 | import javax.inject.Named; 4 | 5 | @Named 6 | public class HelloWorld { 7 | 8 | private String firstName = "John"; 9 | private String lastName = "Doe"; 10 | 11 | public String getFirstName() { 12 | return firstName; 13 | } 14 | 15 | public void setFirstName(String firstName) { 16 | this.firstName = firstName; 17 | } 18 | 19 | public String getLastName() { 20 | return lastName; 21 | } 22 | 23 | public void setLastName(String lastName) { 24 | this.lastName = lastName; 25 | } 26 | 27 | public String showGreeting() { 28 | return "Hello " + firstName + " " + lastName + "!"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /jsf-primefaces-hello-world/src/main/resources/META-INF/resources/helloworld.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | PrimeFaces Hello World Example 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 25 | 26 | 27 | 28 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /jsf-primefaces-jetty/README.md: -------------------------------------------------------------------------------- 1 | # jsf-primefaces-jetty 2 | 3 | A detailed step-by-step tutorial in which we build and run a Hello World PrimeFaces example using Jetty and Maven. 4 | 5 | [https://www.codenotfound.com/jsf-primefaces-hello-world-example-jetty-maven.html](https://www.codenotfound.com/jsf-primefaces-hello-world-example-jetty-maven.html) 6 | -------------------------------------------------------------------------------- /jsf-primefaces-jetty/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | com.codenotfound 6 | jsf-primefaces-jetty 7 | 0.0.1-SNAPSHOT 8 | war 9 | 10 | JSF - PrimeFaces Hello World Example using Jetty and Maven 11 | https://www.codenotfound.com/jsf-primefaces-hello-world-example-jetty-maven.html 12 | 13 | 14 | UTF-8 15 | 1.8 16 | 17 | 3.1.0 18 | 2.2.15 19 | 6.1 20 | 21 | 3.7.0 22 | 9.4.8.v20171121 23 | 24 | 25 | 26 | 27 | 28 | javax.servlet 29 | javax.servlet-api 30 | ${servlet.version} 31 | provided 32 | 33 | 34 | 35 | com.sun.faces 36 | jsf-api 37 | ${jsf.version} 38 | compile 39 | 40 | 41 | com.sun.faces 42 | jsf-impl 43 | ${jsf.version} 44 | compile 45 | 46 | 47 | 48 | org.primefaces 49 | primefaces 50 | ${primefaces.version} 51 | 52 | 53 | 54 | 55 | 56 | 57 | org.apache.maven.plugins 58 | maven-compiler-plugin 59 | ${maven-compiler-plugin.version} 60 | 61 | ${java.version} 62 | ${java.version} 63 | 64 | 65 | 66 | 67 | org.eclipse.jetty 68 | jetty-maven-plugin 69 | ${jetty-maven-plugin.version} 70 | 71 | 72 | 9090 73 | 74 | 75 | /codenotfound 76 | 77 | 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /jsf-primefaces-jetty/src/main/java/com/codenotfound/primefaces/HelloWorld.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound.primefaces; 2 | 3 | import javax.faces.bean.ManagedBean; 4 | 5 | @ManagedBean 6 | public class HelloWorld { 7 | 8 | private String firstName = "John"; 9 | private String lastName = "Doe"; 10 | 11 | public String getFirstName() { 12 | return firstName; 13 | } 14 | 15 | public void setFirstName(String firstName) { 16 | this.firstName = firstName; 17 | } 18 | 19 | public String getLastName() { 20 | return lastName; 21 | } 22 | 23 | public void setLastName(String lastName) { 24 | this.lastName = lastName; 25 | } 26 | 27 | public String showGreeting() { 28 | return "Hello " + firstName + " " + lastName + "!"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /jsf-primefaces-jetty/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 9 | helloworld.xhtml 10 | 11 | 12 | 14 | 15 | faces-servlet 16 | javax.faces.webapp.FacesServlet 17 | 1 18 | 19 | 20 | 21 | 22 | faces-servlet 23 | *.xhtml 24 | 25 | 26 | -------------------------------------------------------------------------------- /jsf-primefaces-jetty/src/main/webapp/helloworld.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | PrimeFaces Hello World Example 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 24 | 25 | 26 | 27 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /jsf-primefaces-spring-security/README.md: -------------------------------------------------------------------------------- 1 | # jsf-primefaces-spring-security 2 | 3 | A detailed step-by-step tutorial on how to implement a PrimeFaces login page using Spring Security, Spring Boot, and Maven. 4 | 5 | [https://codenotfound.com/jsf-primefaces-spring-security-example.html](https://codenotfound.com/jsf-primefaces-spring-security-example.html) 6 | -------------------------------------------------------------------------------- /jsf-primefaces-spring-security/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.codenotfound 7 | jsf-primefaces-spring-security 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | jsf-primefaces-spring-security 12 | JSF PrimeFaces Spring Security Example 13 | https://codenotfound.com/jsf-primefaces-spring-security-example.html 14 | 15 | 16 | org.springframework.boot 17 | spring-boot-starter-parent 18 | 2.1.0.RELEASE 19 | 20 | 21 | 22 | 23 | UTF-8 24 | UTF-8 25 | 1.8 26 | 3.3.0-rc2 27 | 28 | 29 | 30 | 31 | 32 | org.joinfaces 33 | joinfaces-dependencies 34 | ${joinfaces.version} 35 | pom 36 | import 37 | 38 | 39 | 40 | 41 | 42 | 43 | org.joinfaces 44 | primefaces-spring-boot-starter 45 | 46 | 47 | javax.enterprise 48 | cdi-api 49 | 50 | 51 | org.springframework.boot 52 | spring-boot-starter-web 53 | 54 | 55 | org.springframework.boot 56 | spring-boot-starter-security 57 | 58 | 59 | 60 | 61 | 62 | 63 | org.springframework.boot 64 | spring-boot-maven-plugin 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /jsf-primefaces-spring-security/src/main/java/com/codenotfound/SpringPrimeFacesApplication.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringPrimeFacesApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringPrimeFacesApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /jsf-primefaces-spring-security/src/main/java/com/codenotfound/primefaces/HelloWorld.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound.primefaces; 2 | 3 | import javax.inject.Named; 4 | import org.springframework.security.core.Authentication; 5 | import org.springframework.security.core.context.SecurityContextHolder; 6 | 7 | @Named 8 | public class HelloWorld { 9 | 10 | private String firstName = ""; 11 | private String lastName = ""; 12 | 13 | public String getFirstName() { 14 | return firstName; 15 | } 16 | 17 | public void setFirstName(String firstName) { 18 | this.firstName = firstName; 19 | } 20 | 21 | public String getLastName() { 22 | return lastName; 23 | } 24 | 25 | public void setLastName(String lastName) { 26 | this.lastName = lastName; 27 | } 28 | 29 | public String showGreeting() { 30 | Authentication authentication = 31 | SecurityContextHolder.getContext().getAuthentication(); 32 | 33 | return "Hello " + authentication.getName() + "!"; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /jsf-primefaces-spring-security/src/main/java/com/codenotfound/primefaces/SecurityConfig.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound.primefaces; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; 5 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 6 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 7 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 8 | 9 | @EnableWebSecurity 10 | public class SecurityConfig extends WebSecurityConfigurerAdapter { 11 | 12 | @Override 13 | protected void configure(HttpSecurity http) throws Exception { 14 | // require all requests to be authenticated except for the resources 15 | http.authorizeRequests().antMatchers("/javax.faces.resource/**") 16 | .permitAll().anyRequest().authenticated(); 17 | // login 18 | http.formLogin().loginPage("/login.xhtml").permitAll() 19 | .failureUrl("/login.xhtml?error=true"); 20 | // logout 21 | http.logout().logoutSuccessUrl("/login.xhtml"); 22 | // not needed as JSF 2.2 is implicitly protected against CSRF 23 | http.csrf().disable(); 24 | } 25 | 26 | @Autowired 27 | public void configureGlobal(AuthenticationManagerBuilder auth) 28 | throws Exception { 29 | auth.inMemoryAuthentication().withUser("john.doe") 30 | .password("{noop}1234").roles("USER").and() 31 | .withUser("jane.doe").password("{noop}5678").roles("ADMIN"); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /jsf-primefaces-spring-security/src/main/java/com/codenotfound/primefaces/WelcomePageRedirect.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound.primefaces; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.core.Ordered; 5 | import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; 6 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 7 | 8 | 9 | @Configuration 10 | public class WelcomePageRedirect implements WebMvcConfigurer { 11 | 12 | @Override 13 | public void addViewControllers(ViewControllerRegistry registry) { 14 | registry.addViewController("/") 15 | .setViewName("forward:/helloworld.xhtml"); 16 | registry.setOrder(Ordered.HIGHEST_PRECEDENCE); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /jsf-primefaces-spring-security/src/main/resources/META-INF/resources/css/login.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: #E0E0E0; 3 | } 4 | 5 | .ui-widget-content { 6 | background-color: #E0E0E0; 7 | } 8 | 9 | h2 { 10 | margin-bottom: 10px 11 | } 12 | 13 | .center { 14 | margin: 0 auto; 15 | } 16 | 17 | .red { 18 | color: #F44336; 19 | } -------------------------------------------------------------------------------- /jsf-primefaces-spring-security/src/main/resources/META-INF/resources/css/main.css: -------------------------------------------------------------------------------- 1 | .authorization-div { 2 | margin-top: 10px; 3 | margin-bottom: 10px; 4 | } 5 | 6 | .logout-form { 7 | margin-top: 10px; 8 | } -------------------------------------------------------------------------------- /jsf-primefaces-spring-security/src/main/resources/META-INF/resources/helloworld.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | PrimeFaces Hello World Example 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 36 | 37 | 38 | 39 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 49 | 50 | 51 | 52 |
53 | 54 | -------------------------------------------------------------------------------- /jsf-primefaces-spring-security/src/main/resources/META-INF/resources/login.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | Login 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |

Please login

19 | 20 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 |
30 |
31 | 32 | -------------------------------------------------------------------------------- /jsf-primefaces-spring-security/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /jsf-primefaces-standalone-tomcat/README.md: -------------------------------------------------------------------------------- 1 | # jsf-primefaces-standalone-tomcat 2 | 3 | An example project on how to deploy PrimeFaces on a standalone Tomcat instance. 4 | 5 | * [https://github.com/joinfaces/joinfaces/issues/77](https://github.com/joinfaces/joinfaces/issues/77) 6 | * [https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-create-a-deployable-war-file](https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-create-a-deployable-war-file) 7 | 8 | Create the WAR file using: `mvn clean install` 9 | 10 | Copy the WAR file in the `webapps` directory. 11 | 12 | Access the application at: [http://localhost:8080/jsf-primefaces-standalone-tomcat-0.0.1-SNAPSHOT/helloworld.xhtml](http://localhost:8080/jsf-primefaces-standalone-tomcat-0.0.1-SNAPSHOT/helloworld.xhtml) 13 | -------------------------------------------------------------------------------- /jsf-primefaces-standalone-tomcat/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.codenotfound 7 | jsf-primefaces-standalone-tomcat 8 | 0.0.1-SNAPSHOT 9 | war 10 | 11 | jsf-primefaces-standalone-tomcat 12 | JSF PrimeFaces Hello World Example 13 | https://codenotfound.com/jsf-primefaces-standalone-tomcat-example.html 14 | 15 | 16 | org.springframework.boot 17 | spring-boot-starter-parent 18 | 2.1.0.RELEASE 19 | 20 | 21 | 22 | 23 | UTF-8 24 | UTF-8 25 | 1.8 26 | 3.3.0-rc2 27 | 28 | 29 | 30 | 31 | 32 | org.joinfaces 33 | joinfaces-dependencies 34 | ${joinfaces.version} 35 | pom 36 | import 37 | 38 | 39 | 40 | 41 | 42 | 43 | org.joinfaces 44 | primefaces-spring-boot-starter 45 | 46 | 47 | javax.enterprise 48 | cdi-api 49 | 50 | 51 | org.springframework.boot 52 | spring-boot-starter-tomcat 53 | provided 54 | 55 | 56 | 57 | 58 | 59 | 60 | org.springframework.boot 61 | spring-boot-maven-plugin 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /jsf-primefaces-standalone-tomcat/src/main/java/com/codenotfound/SpringPrimeFacesApplication.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; 6 | 7 | @SpringBootApplication 8 | public class SpringPrimeFacesApplication 9 | extends SpringBootServletInitializer { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(SpringPrimeFacesApplication.class, args); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /jsf-primefaces-standalone-tomcat/src/main/java/com/codenotfound/primefaces/HelloWorld.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound.primefaces; 2 | 3 | import javax.inject.Named; 4 | 5 | @Named 6 | public class HelloWorld { 7 | 8 | private String firstName = "John"; 9 | private String lastName = "Doe"; 10 | 11 | public String getFirstName() { 12 | return firstName; 13 | } 14 | 15 | public void setFirstName(String firstName) { 16 | this.firstName = firstName; 17 | } 18 | 19 | public String getLastName() { 20 | return lastName; 21 | } 22 | 23 | public void setLastName(String lastName) { 24 | this.lastName = lastName; 25 | } 26 | 27 | public String showGreeting() { 28 | return "Hello " + firstName + " " + lastName + "!"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /jsf-primefaces-standalone-tomcat/src/main/webapp/helloworld.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | PrimeFaces Hello World Example 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 25 | 26 | 27 | 28 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /jsf-primefaces-themes/README.md: -------------------------------------------------------------------------------- 1 | # jsf-primefaces-themes 2 | 3 | A code sample on how to configure the Primefaces Bootstrap theme using Spring Boot. 4 | 5 | [https://codenotfound.com/jsf-primefaces-themes-example.html](https://codenotfound.com/jsf-primefaces-themes-example.html) 6 | -------------------------------------------------------------------------------- /jsf-primefaces-themes/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.codenotfound 7 | jsf-primefaces-themes 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | jsf-primefaces-themes 12 | JSF Primefaces Themes Example 13 | https://codenotfound.com/jsf-primefaces-themes-example.html 14 | 15 | 16 | org.springframework.boot 17 | spring-boot-starter-parent 18 | 2.1.0.RELEASE 19 | 20 | 21 | 22 | 23 | UTF-8 24 | UTF-8 25 | 1.8 26 | 3.3.0-rc2 27 | 28 | 29 | 30 | 31 | 32 | org.joinfaces 33 | joinfaces-dependencies 34 | ${joinfaces.version} 35 | pom 36 | import 37 | 38 | 39 | 40 | 41 | 42 | 43 | org.joinfaces 44 | primefaces-spring-boot-starter 45 | 46 | 47 | javax.enterprise 48 | cdi-api 49 | 50 | 51 | org.primefaces.themes 52 | all-themes 53 | 1.0.10 54 | 55 | 56 | 57 | 58 | 59 | primefaces-maven-repository 60 | PrimeFaces Maven Repository 61 | http://repository.primefaces.org 62 | 63 | 64 | 65 | 66 | 67 | 68 | org.springframework.boot 69 | spring-boot-maven-plugin 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /jsf-primefaces-themes/src/main/java/com/codenotfound/SpringPrimeFacesApplication.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringPrimeFacesApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringPrimeFacesApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /jsf-primefaces-themes/src/main/java/com/codenotfound/primefaces/HelloWorld.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound.primefaces; 2 | 3 | import javax.inject.Named; 4 | 5 | @Named 6 | public class HelloWorld { 7 | 8 | private String firstName = "John"; 9 | private String lastName = "Doe"; 10 | 11 | public String getFirstName() { 12 | return firstName; 13 | } 14 | 15 | public void setFirstName(String firstName) { 16 | this.firstName = firstName; 17 | } 18 | 19 | public String getLastName() { 20 | return lastName; 21 | } 22 | 23 | public void setLastName(String lastName) { 24 | this.lastName = lastName; 25 | } 26 | 27 | public String showGreeting() { 28 | return "Hello " + firstName + " " + lastName + "!"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /jsf-primefaces-themes/src/main/resources/META-INF/resources/helloworld.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | PrimeFaces Hello World Example 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 25 | 26 | 27 | 28 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /jsf-primefaces-themes/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | jsf: 2 | primefaces: 3 | theme: bootstrap 4 | -------------------------------------------------------------------------------- /jsf-primefaces-unit-testing-selenium/README.md: -------------------------------------------------------------------------------- 1 | # jsf-primefaces-unit-testing-selenium 2 | 3 | [![Sonarcloud Status](https://sonarcloud.io/api/project_badges/measure?project=com.codenotfound%3Ajsf-primefaces-unit-testing-selenium&metric=alert_status)](https://sonarcloud.io/dashboard?id=com.codenotfound%3Ajsf-primefaces-unit-testing-selenium) 4 | 5 | A detailed step-by-step tutorial on how to implement an automated unit test for PrimeFaces using Selenium. 6 | 7 | [https://codenotfound.com/jsf-primefaces-automated-unit-testing-selenium.html](https://codenotfound.com/jsf-primefaces-automated-unit-testing-selenium.html) 8 | -------------------------------------------------------------------------------- /jsf-primefaces-unit-testing-selenium/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.codenotfound 7 | jsf-primefaces-unit-testing-selenium 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | jsf-primefaces-unit-testing-selenium 12 | JSF Primefaces Automated Unit Testing using Selenium 13 | https://codenotfound.com/jsf-primefaces-automated-unit-testing-selenium.html 14 | 15 | 16 | org.springframework.boot 17 | spring-boot-starter-parent 18 | 2.1.0.RELEASE 19 | 20 | 21 | 22 | 23 | UTF-8 24 | UTF-8 25 | 1.8 26 | 3.3.0-rc2 27 | 2.52.0 28 | 29 | 30 | 31 | 32 | 33 | org.joinfaces 34 | joinfaces-dependencies 35 | ${joinfaces.version} 36 | pom 37 | import 38 | 39 | 40 | 41 | 42 | 43 | 44 | org.joinfaces 45 | primefaces-spring-boot-starter 46 | 47 | 48 | javax.enterprise 49 | cdi-api 50 | 51 | 52 | org.springframework.boot 53 | spring-boot-starter-web 54 | 55 | 56 | org.springframework.boot 57 | spring-boot-starter-test 58 | test 59 | 60 | 61 | org.seleniumhq.selenium 62 | selenium-java 63 | test 64 | 65 | 66 | org.seleniumhq.selenium 67 | htmlunit-driver 68 | test 69 | 70 | 71 | 72 | 73 | 74 | 75 | org.springframework.boot 76 | spring-boot-maven-plugin 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /jsf-primefaces-unit-testing-selenium/src/main/java/com/codenotfound/SpringPrimeFacesApplication.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringPrimeFacesApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringPrimeFacesApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /jsf-primefaces-unit-testing-selenium/src/main/java/com/codenotfound/primefaces/HelloWorld.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound.primefaces; 2 | 3 | import javax.inject.Named; 4 | 5 | @Named 6 | public class HelloWorld { 7 | 8 | private String firstName; 9 | private String lastName; 10 | 11 | public String getFirstName() { 12 | return firstName; 13 | } 14 | 15 | public void setFirstName(String firstName) { 16 | this.firstName = firstName; 17 | } 18 | 19 | public String getLastName() { 20 | return lastName; 21 | } 22 | 23 | public void setLastName(String lastName) { 24 | this.lastName = lastName; 25 | } 26 | 27 | public String showGreeting() { 28 | return "Hello " + firstName + " " + lastName + "!"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /jsf-primefaces-unit-testing-selenium/src/main/resources/META-INF/resources/helloworld.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | PrimeFaces Hello World Example 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 24 | 25 | 26 | 27 | 29 | 30 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /jsf-primefaces-unit-testing-selenium/src/test/java/com/codenotfound/PageObject.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound; 2 | 3 | import org.openqa.selenium.WebDriver; 4 | import org.openqa.selenium.support.PageFactory; 5 | 6 | public class PageObject { 7 | protected WebDriver driver; 8 | 9 | public PageObject(WebDriver driver) { 10 | this.driver = driver; 11 | PageFactory.initElements(driver, this); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /jsf-primefaces-unit-testing-selenium/src/test/java/com/codenotfound/WebDriverUtil.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound; 2 | 3 | import java.util.concurrent.TimeUnit; 4 | import org.junit.After; 5 | import org.junit.AfterClass; 6 | import org.junit.BeforeClass; 7 | import org.openqa.selenium.WebDriver; 8 | import org.openqa.selenium.htmlunit.HtmlUnitDriver; 9 | 10 | public class WebDriverUtil { 11 | 12 | protected static WebDriver driver; 13 | 14 | @BeforeClass 15 | public static void setUp() { 16 | driver = new HtmlUnitDriver(); 17 | driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); 18 | } 19 | 20 | @After 21 | public void cleanUp() { 22 | driver.manage().deleteAllCookies(); 23 | } 24 | 25 | @AfterClass 26 | public static void tearDown() { 27 | driver.close(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /jsf-primefaces-unit-testing-selenium/src/test/java/com/codenotfound/primefaces/HelloWorldPage.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound.primefaces; 2 | 3 | import org.openqa.selenium.WebDriver; 4 | import org.openqa.selenium.WebElement; 5 | import org.openqa.selenium.support.FindBy; 6 | import org.openqa.selenium.support.PageFactory; 7 | import com.codenotfound.PageObject; 8 | 9 | public class HelloWorldPage extends PageObject { 10 | 11 | @FindBy(id = "hello-world-form:first-name") 12 | private WebElement firstNameInput; 13 | 14 | @FindBy(id = "hello-world-form:last-name") 15 | private WebElement lastNameInput; 16 | 17 | @FindBy(id = "hello-world-form:submit") 18 | private WebElement submitButton; 19 | 20 | @FindBy(id = "hello-world-form:greeting") 21 | private WebElement greetingOutput; 22 | 23 | public HelloWorldPage(WebDriver driver) { 24 | super(driver); 25 | } 26 | 27 | public void submit(String firstName, String lastName) { 28 | // set the input fields 29 | firstNameInput.sendKeys(firstName); 30 | lastNameInput.sendKeys(lastName); 31 | // submit the form 32 | submitButton.submit(); 33 | // refresh the output field 34 | PageFactory.initElements(driver, this); 35 | } 36 | 37 | public String getGreeting() { 38 | return greetingOutput.getAttribute("textContent"); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /jsf-primefaces-unit-testing-selenium/src/test/java/com/codenotfound/primefaces/HelloWorldTest.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound.primefaces; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; 8 | import org.springframework.test.context.junit4.SpringRunner; 9 | import com.codenotfound.WebDriverUtil; 10 | 11 | @RunWith(SpringRunner.class) 12 | @SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT) 13 | public class HelloWorldTest extends WebDriverUtil { 14 | 15 | @Test 16 | public void testSubmit() { 17 | driver.get("http://localhost:8080/helloworld.xhtml"); 18 | 19 | HelloWorldPage page = new HelloWorldPage(driver); 20 | page.submit("Jane", "Doe"); 21 | 22 | assertThat(page.getGreeting()).isEqualTo("Hello Jane Doe!"); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /jsf-primefaces-unit-testing-selenium/src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /jsf-primefaces-websphere-application-server/README.md: -------------------------------------------------------------------------------- 1 | # jsf-primefaces-websphere-application-server 2 | 3 | A detailed step-by-step tutorial in which we build and run a Hello World PrimeFaces example using WebSphere Application Server and Maven. 4 | 5 | [https://www.codenotfound.com/jsf-primefaces-hello-world-example-websphere-application-server-maven.html](https://www.codenotfound.com/jsf-primefaces-hello-world-example-websphere-application-server-maven.html) 6 | -------------------------------------------------------------------------------- /jsf-primefaces-websphere-application-server/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | com.codenotfound 6 | jsf-primefaces-websphere-application-server 7 | 0.0.1-SNAPSHOT 8 | war 9 | 10 | JSF - PrimeFaces Hello World Example using WebSphere Application Server and Maven 11 | http://www.codenotfound.com/jsf-primefaces-hello-world-example-websphere-application-server-maven.html 12 | 13 | 14 | UTF-8 15 | 1.6 16 | 17 | 3.1.0 18 | 2.2.15 19 | 6.1 20 | 21 | C:\Program Files (x86)\IBM\WebSphere\AppServer 22 | 23 | 3.7.0 24 | 1.1.2 25 | 26 | 27 | 28 | 29 | 30 | javax.servlet 31 | javax.servlet-api 32 | ${servlet.version} 33 | provided 34 | 35 | 36 | 37 | com.sun.faces 38 | jsf-api 39 | ${jsf.version} 40 | provided 41 | 42 | 43 | com.sun.faces 44 | jsf-impl 45 | ${jsf.version} 46 | provided 47 | 48 | 49 | 50 | org.primefaces 51 | primefaces 52 | ${primefaces.version} 53 | 54 | 55 | 56 | 57 | 58 | 59 | org.apache.maven.plugins 60 | maven-compiler-plugin 61 | ${maven-compiler-plugin.version} 62 | 63 | ${java.version} 64 | ${java.version} 65 | 66 | 67 | 68 | 69 | com.orctom.mojo 70 | was-maven-plugin 71 | ${was-maven-plugin.version} 72 | 73 | 74 | deploy 75 | install 76 | 77 | deploy 78 | 79 | 80 | ${was.home} 81 | admin 82 | admin 83 | localhost 84 | server1 85 | codenotfoundNode01 86 | default_host 87 | ${project.build.finalName} 88 | codenotfound 89 | true 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /jsf-primefaces-websphere-application-server/src/main/java/com/codenotfound/primefaces/HelloWorld.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound.primefaces; 2 | 3 | import javax.faces.bean.ManagedBean; 4 | 5 | @ManagedBean 6 | public class HelloWorld { 7 | 8 | private String firstName = "John"; 9 | private String lastName = "Doe"; 10 | 11 | public String getFirstName() { 12 | return firstName; 13 | } 14 | 15 | public void setFirstName(String firstName) { 16 | this.firstName = firstName; 17 | } 18 | 19 | public String getLastName() { 20 | return lastName; 21 | } 22 | 23 | public void setLastName(String lastName) { 24 | this.lastName = lastName; 25 | } 26 | 27 | public String showGreeting() { 28 | return "Hello " + firstName + " " + lastName + "!"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /jsf-primefaces-websphere-application-server/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | helloworld.xhtml 8 | 9 | 10 | 11 | 12 | faces-servlet 13 | javax.faces.webapp.FacesServlet 14 | 1 15 | 16 | 17 | 18 | 19 | faces-servlet 20 | *.xhtml 21 | 22 | 23 | -------------------------------------------------------------------------------- /jsf-primefaces-websphere-application-server/src/main/webapp/helloworld.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | PrimeFaces Hello World Example 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 24 | 25 | 26 | 27 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /jsf-primefaces-welcome-page-redirect/README.md: -------------------------------------------------------------------------------- 1 | # jsf-primefaces-welcome-page-redirect 2 | 3 | [![Sonarcloud Status](https://sonarcloud.io/api/project_badges/measure?project=com.codenotfound%3Ajsf-primefaces-welcome-page-redirect&metric=alert_status)](https://sonarcloud.io/dashboard?id=com.codenotfound%3Ajsf-primefaces-welcome-page-redirect) 4 | 5 | A code sample on how to implement a PrimeFaces for JSF welcome page redirect using Spring Boot. 6 | 7 | [https://codenotfound.com/jsf-primefaces-welcome-page-redirect-example.html](https://codenotfound.com/jsf-primefaces-welcome-page-redirect-example.html) 8 | -------------------------------------------------------------------------------- /jsf-primefaces-welcome-page-redirect/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.codenotfound 7 | jsf-primefaces-welcome-page-redirect 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | jsf-primefaces-welcome-page-redirect 12 | JSF PrimeFaces Welcome Page Redirect Example 13 | https://codenotfound.com/jsf-primefaces-welcome-page-redirect-example.html 14 | 15 | 16 | org.springframework.boot 17 | spring-boot-starter-parent 18 | 2.1.0.RELEASE 19 | 20 | 21 | 22 | 23 | UTF-8 24 | UTF-8 25 | 1.8 26 | 3.3.0-rc2 27 | 2.52.0 28 | 29 | 30 | 31 | 32 | 33 | org.joinfaces 34 | joinfaces-dependencies 35 | ${joinfaces.version} 36 | pom 37 | import 38 | 39 | 40 | 41 | 42 | 43 | 44 | org.joinfaces 45 | primefaces-spring-boot-starter 46 | 47 | 48 | javax.enterprise 49 | cdi-api 50 | 51 | 52 | org.springframework.boot 53 | spring-boot-starter-web 54 | 55 | 56 | org.springframework.boot 57 | spring-boot-starter-test 58 | test 59 | 60 | 61 | org.seleniumhq.selenium 62 | selenium-java 63 | test 64 | 65 | 66 | org.seleniumhq.selenium 67 | htmlunit-driver 68 | test 69 | 70 | 71 | 72 | 73 | 74 | 75 | org.springframework.boot 76 | spring-boot-maven-plugin 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /jsf-primefaces-welcome-page-redirect/src/main/java/com/codenotfound/SpringPrimeFacesApplication.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringPrimeFacesApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringPrimeFacesApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /jsf-primefaces-welcome-page-redirect/src/main/java/com/codenotfound/primefaces/HelloWorld.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound.primefaces; 2 | 3 | import javax.inject.Named; 4 | 5 | @Named 6 | public class HelloWorld { 7 | 8 | private String firstName = "John"; 9 | private String lastName = "Doe"; 10 | 11 | public String getFirstName() { 12 | return firstName; 13 | } 14 | 15 | public void setFirstName(String firstName) { 16 | this.firstName = firstName; 17 | } 18 | 19 | public String getLastName() { 20 | return lastName; 21 | } 22 | 23 | public void setLastName(String lastName) { 24 | this.lastName = lastName; 25 | } 26 | 27 | public String showGreeting() { 28 | return "Hello " + firstName + " " + lastName + "!"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /jsf-primefaces-welcome-page-redirect/src/main/java/com/codenotfound/primefaces/WelcomePageRedirect.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound.primefaces; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.core.Ordered; 5 | import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; 6 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 7 | 8 | @Configuration 9 | public class WelcomePageRedirect implements WebMvcConfigurer { 10 | 11 | @Override 12 | public void addViewControllers(ViewControllerRegistry registry) { 13 | registry.addViewController("/") 14 | .setViewName("forward:/helloworld.xhtml"); 15 | registry.setOrder(Ordered.HIGHEST_PRECEDENCE); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /jsf-primefaces-welcome-page-redirect/src/main/resources/META-INF/resources/helloworld.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | PrimeFaces Hello World Example 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 24 | 25 | 26 | 27 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /jsf-primefaces-welcome-page-redirect/src/test/java/com/codenotfound/WebDriverUtil.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound; 2 | 3 | import java.util.concurrent.TimeUnit; 4 | import org.junit.After; 5 | import org.junit.AfterClass; 6 | import org.junit.BeforeClass; 7 | import org.openqa.selenium.WebDriver; 8 | import org.openqa.selenium.htmlunit.HtmlUnitDriver; 9 | 10 | public class WebDriverUtil { 11 | 12 | protected static WebDriver driver; 13 | 14 | @BeforeClass 15 | public static void setUp() { 16 | driver = new HtmlUnitDriver(); 17 | driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); 18 | } 19 | 20 | @After 21 | public void cleanUp() { 22 | driver.manage().deleteAllCookies(); 23 | } 24 | 25 | @AfterClass 26 | public static void tearDown() { 27 | driver.close(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /jsf-primefaces-welcome-page-redirect/src/test/java/com/codenotfound/primefaces/HelloWorldTest.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound.primefaces; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; 8 | import org.springframework.test.context.junit4.SpringRunner; 9 | import com.codenotfound.WebDriverUtil; 10 | 11 | @RunWith(SpringRunner.class) 12 | @SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT) 13 | public class HelloWorldTest extends WebDriverUtil { 14 | 15 | @Test 16 | public void testWelcomePageRedirect() { 17 | driver.get("http://localhost:8080/"); 18 | 19 | assertThat(driver.getTitle()) 20 | .isEqualTo("PrimeFaces Hello World Example"); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /jsf-primefaces-welcome-page-redirect/src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /jsf-primefaces-wildfly/README.md: -------------------------------------------------------------------------------- 1 | # jsf-primefaces-wildfly 2 | 3 | A detailed step-by-step tutorial in which we build and run a Hello World PrimeFaces example using WildFly and Maven. 4 | 5 | [https://www.codenotfound.com/jsf-primefaces-hello-world-example-wildfly-maven.html](https://www.codenotfound.com/jsf-primefaces-hello-world-example-wildfly-maven.html) 6 | -------------------------------------------------------------------------------- /jsf-primefaces-wildfly/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | com.codenotfound 6 | jsf-primefaces-wildfly 7 | 0.0.1-SNAPSHOT 8 | war 9 | 10 | JSF - PrimeFaces Hello World Example using WildFly and Maven 11 | https://www.codenotfound.com/jsf-primefaces-hello-world-example-wildfly-maven.html 12 | 13 | 14 | UTF-8 15 | 1.8 16 | 17 | 3.1.0 18 | 2.2.15 19 | 6.1 20 | 21 | 3.7.0 22 | 1.2.1.Final 23 | 24 | 25 | 26 | 27 | 28 | javax.servlet 29 | javax.servlet-api 30 | ${servlet.version} 31 | provided 32 | 33 | 34 | 35 | com.sun.faces 36 | jsf-api 37 | ${jsf.version} 38 | provided 39 | 40 | 41 | com.sun.faces 42 | jsf-impl 43 | ${jsf.version} 44 | provided 45 | 46 | 47 | 48 | org.primefaces 49 | primefaces 50 | ${primefaces.version} 51 | 52 | 53 | 54 | 55 | 56 | 57 | org.apache.maven.plugins 58 | maven-compiler-plugin 59 | ${maven-compiler-plugin.version} 60 | 61 | ${java.version} 62 | ${java.version} 63 | 64 | 65 | 66 | 67 | org.wildfly.plugins 68 | wildfly-maven-plugin 69 | ${wildfly-maven-plugin.version} 70 | 71 | 72 | -Djboss.http.port=9090 73 | 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /jsf-primefaces-wildfly/src/main/java/com/codenotfound/primefaces/HelloWorld.java: -------------------------------------------------------------------------------- 1 | package com.codenotfound.primefaces; 2 | 3 | import javax.faces.bean.ManagedBean; 4 | 5 | @ManagedBean 6 | public class HelloWorld { 7 | 8 | private String firstName = "John"; 9 | private String lastName = "Doe"; 10 | 11 | public String getFirstName() { 12 | return firstName; 13 | } 14 | 15 | public void setFirstName(String firstName) { 16 | this.firstName = firstName; 17 | } 18 | 19 | public String getLastName() { 20 | return lastName; 21 | } 22 | 23 | public void setLastName(String lastName) { 24 | this.lastName = lastName; 25 | } 26 | 27 | public String showGreeting() { 28 | return "Hello " + firstName + " " + lastName + "!"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /jsf-primefaces-wildfly/src/main/webapp/WEB-INF/jboss-web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | /codenotfound 4 | -------------------------------------------------------------------------------- /jsf-primefaces-wildfly/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | helloworld.xhtml 8 | 9 | 10 | 11 | 12 | faces-servlet 13 | javax.faces.webapp.FacesServlet 14 | 1 15 | 16 | 17 | 18 | 19 | faces-servlet 20 | *.xhtml 21 | 22 | 23 | -------------------------------------------------------------------------------- /jsf-primefaces-wildfly/src/main/webapp/helloworld.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | PrimeFaces Hello World Example 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 24 | 25 | 26 | 27 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | --------------------------------------------------------------------------------