In this tutorial, we will show you how to create a JSF 2 + PrimeFaces wed project, the final output is display a hello world string in PrimeFaces
editor
component.- JSF 2.1.11
- Primefaces 3.3
- Eclipse 4.2
- Maven 3
- Tested on Tomcat 7
Note
PrimeFaces only requires a JAVA 5+ runtime and a JSF 2.x implementation as mandatory dependencies.
PrimeFaces only requires a JAVA 5+ runtime and a JSF 2.x implementation as mandatory dependencies.
1. Project Directory
File : pom.xml Add JSF 2 and Primefaces dependencies.
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0
3. Editor Bean
Create a simple bean, to provide data for PrimeFaces editor component later.
package com.mkyong.editor; import javax.faces.bean.ManagedBean; @ManagedBean(name = "editor")public class EditorBean { private String value = "This editor is provided by PrimeFaces"; public String getValue() { return value; } public void setValue(String value) { this.value = value; }}
4. Web Page
To use PrimeFaces components, just declares this namespace
xmlns:p="http://primefaces.org/ui"
, and start use it, simple.version="1.0" encoding="UTF-8"?>
5. Configuration
Note
PrimeFaces does not require any mandatory configuration
PrimeFaces does not require any mandatory configuration
See
web.xml
below, only for JSF configuration. version="1.0" encoding="UTF-8"?>xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> PrimeFaces Web Application
6. Demo
See final output. http://localhost:8080/primefaces/
Post a Comment