BAEL-1303 Intro to Primefaces (#3874)

* ivan.ljubicic.app.developer@gmail.com

* Added unit tests, configuration class and minor adjustments

* primefaces intro module added

* deleted primefaces old module

* deleted different bean injection types sample project

* deleted addition different bean injection types file

* Renaming archetype in web.xml

* Added primefaces in jsf module

* Primefaces improvements

* Added commandButton and dialog

* Added PFM

* Code formatting

* Update pom.xml

* Formatting changes
This commit is contained in:
IvanLjubicic 2018-05-01 16:59:17 +02:00 committed by daoire
parent a86f9de2cd
commit 13d226c97b
6 changed files with 259 additions and 1 deletions

View File

@ -73,6 +73,13 @@
<scope>provided</scope>
<version>${javax.servlet.version}</version>
</dependency>
<!-- Primefaces -->
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>6.2</version>
</dependency>
</dependencies>
<build>
@ -103,6 +110,6 @@
<!-- maven plugins -->
<maven-war-plugin.version>2.6</maven-war-plugin.version>
</properties>
</properties>
</project>

View File

@ -0,0 +1,120 @@
package com.baeldung.springintegration.controllers;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.el.ELContextEvent;
import javax.el.ELContextListener;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
@ManagedBean(name = "helloPFBean")
@ViewScoped
public class HelloPFBean {
private String firstName;
private String lastName;
private String componentSuite;
private List<Technology> technologies;
private String inputText;
private String outputText;
@PostConstruct
public void init() {
firstName = "Hello";
lastName = "Primefaces";
technologies = new ArrayList<Technology>();
Technology technology1 = new Technology();
technology1.setCurrentVersion("10");
technology1.setName("Java");
technologies.add(technology1);
Technology technology2 = new Technology();
technology2.setCurrentVersion("5.0");
technology2.setName("Spring");
technologies.add(technology2);
}
public void onBlurEvent() {
outputText = inputText.toUpperCase();
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getComponentSuite() {
return componentSuite;
}
public void setComponentSuite(String componentSuite) {
this.componentSuite = componentSuite;
}
public List<Technology> getTechnologies() {
return technologies;
}
public void setTechnologies(List<Technology> technologies) {
this.technologies = technologies;
}
public String getInputText() {
return inputText;
}
public void setInputText(String inputText) {
this.inputText = inputText;
}
public String getOutputText() {
return outputText;
}
public void setOutputText(String outputText) {
this.outputText = outputText;
}
public class Technology {
private String name;
private String currentVersion;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCurrentVersion() {
return currentVersion;
}
public void setCurrentVersion(String currentVersion) {
this.currentVersion = currentVersion;
}
}
}

View File

@ -0,0 +1,28 @@
package com.baeldung.springintegration.controllers;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
@ManagedBean(name = "helloPFMBean")
@SessionScoped
public class HelloPFMBean {
private String magicWord;
public String getMagicWord() {
return magicWord;
}
public void setMagicWord(String magicWord) {
this.magicWord = magicWord;
}
public String go() {
if (this.magicWord != null && this.magicWord.toUpperCase()
.equals("BAELDUNG")) {
return "pm:success";
}
return "pm:failure";
}
}

View File

@ -25,6 +25,12 @@
</var>
</resource-bundle>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
<navigation-handler>
org.primefaces.mobile.application.MobileNavigationHandler
</navigation-handler>
<!-- <default-render-kit-id>PRIMEFACES_MOBILE</default-render-kit-id> -->
</application>
<navigation-rule>

View File

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title>Hello Primefaces</title>
</h:head>
<h:body>
<h:form id="primeForm">
<p:panelGrid columns="2">
<h:outputText value="#{helloPFBean.firstName}" />
<h:outputText value="#{helloPFBean.lastName}" />
</p:panelGrid>
<h:panelGrid columns="2">
<p:outputLabel for="jsfCompSuite" value="Component Suite" />
<p:selectOneRadio id="jsfCompSuite"
value="#{helloPFBean.componentSuite}">
<f:selectItem itemLabel="ICEfaces" itemValue="ICEfaces" />
<f:selectItem itemLabel="RichFaces" itemValue="RichFaces" />
</p:selectOneRadio>
</h:panelGrid>
<p:dataTable var="technology" value="#{helloPFBean.technologies}">
<p:column headerText="Name">
<h:outputText value="#{technology.name}" />
</p:column>
<p:column headerText="Version">
<h:outputText value="#{technology.currentVersion}" />
</p:column>
</p:dataTable>
<h:panelGrid columns="3">
<h:outputText value="Blur event " />
<p:inputText id="inputTextId" value="#{helloPFBean.inputText}">
<p:ajax event="blur" update="outputTextId"
listener="#{helloPFBean.onBlurEvent}" />
</p:inputText>
<h:outputText id="outputTextId" value="#{helloPFBean.outputText}" />
<p:commandButton value="Open Dialog" icon="ui-icon-note"
onclick="PF('exDialog').show();">
</p:commandButton>
</h:panelGrid>
<p:dialog header="Example dialog" widgetVar="exDialog" minHeight="40">
<h:outputText value="Hello Baeldung!" />
</p:dialog>
</h:form>
</h:body>
</html>

View File

@ -0,0 +1,38 @@
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:pm="http://primefaces.org/mobile">
<f:view renderKitId="PRIMEFACES_MOBILE" />
<h:head>
</h:head>
<h:body>
<pm:page id="enter">
<pm:header>
<p:outputLabel value="Introduction to PFM"></p:outputLabel>
</pm:header>
<pm:content>
<h:form id="enterForm">
<pm:field>
<p:outputLabel value="Enter Magic Word"></p:outputLabel>
<p:inputText id="magicWord" value="#{helloPFMBean.magicWord}"></p:inputText>
</pm:field>
<p:commandButton value="Go!" action="#{helloPFMBean.go}"></p:commandButton>
</h:form>
</pm:content>
</pm:page>
<pm:page id="success">
<pm:content>
<p:outputLabel value="Correct!"></p:outputLabel>
<p:button value="Back" outcome="pm:enter?transition=flow"></p:button>
</pm:content>
</pm:page>
<pm:page id="failure">
<pm:content>
<p:outputLabel value="That is not the magic word"></p:outputLabel>
<p:button value="Back" outcome="pm:enter?transition=flow"></p:button>
</pm:content>
</pm:page>
</h:body>
</html>