Aggiunto l'esempio del capitolo su Java Server Faces
This commit is contained in:
9
.idea/artifacts/jsfdemo_ejb_exploded.xml
generated
Normal file
9
.idea/artifacts/jsfdemo_ejb_exploded.xml
generated
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<component name="ArtifactManager">
|
||||||
|
<artifact type="exploded-ejb" name="jsfdemo:ejb exploded">
|
||||||
|
<output-path>$PROJECT_DIR$/out/artifacts/jsfdemo_ejb_exploded</output-path>
|
||||||
|
<root id="root">
|
||||||
|
<element id="javaee-facet-resources" facet="jsfdemo/ejb/EJB" />
|
||||||
|
<element id="module-output" name="jsfdemo" />
|
||||||
|
</root>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
23
.idea/artifacts/jsfdemo_war_exploded.xml
generated
Normal file
23
.idea/artifacts/jsfdemo_war_exploded.xml
generated
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<component name="ArtifactManager">
|
||||||
|
<artifact type="exploded-war" name="jsfdemo:war exploded">
|
||||||
|
<output-path>$PROJECT_DIR$/jsfdemo/target/jsfdemo-1.0-SNAPSHOT</output-path>
|
||||||
|
<properties id="maven-jee-properties">
|
||||||
|
<options>
|
||||||
|
<exploded>true</exploded>
|
||||||
|
<module>jsfdemo</module>
|
||||||
|
<packaging>war</packaging>
|
||||||
|
</options>
|
||||||
|
</properties>
|
||||||
|
<root id="root">
|
||||||
|
<element id="directory" name="WEB-INF">
|
||||||
|
<element id="directory" name="classes">
|
||||||
|
<element id="module-output" name="jsfdemo" />
|
||||||
|
</element>
|
||||||
|
</element>
|
||||||
|
<element id="directory" name="META-INF">
|
||||||
|
<element id="file-copy" path="$PROJECT_DIR$/jsfdemo/target/jsfdemo-1.0-SNAPSHOT/META-INF/MANIFEST.MF" />
|
||||||
|
</element>
|
||||||
|
<element id="javaee-facet-resources" facet="jsfdemo/web/Web" />
|
||||||
|
</root>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
1
.idea/compiler.xml
generated
1
.idea/compiler.xml
generated
@@ -9,6 +9,7 @@
|
|||||||
<outputRelativeToContentRoot value="true" />
|
<outputRelativeToContentRoot value="true" />
|
||||||
<module name="cdidemo" />
|
<module name="cdidemo" />
|
||||||
<module name="jpademo" />
|
<module name="jpademo" />
|
||||||
|
<module name="jsfdemo" />
|
||||||
<module name="beanvalidationdemo" />
|
<module name="beanvalidationdemo" />
|
||||||
<module name="jmsdemo" />
|
<module name="jmsdemo" />
|
||||||
<module name="jaxwsdemo-client" />
|
<module name="jaxwsdemo-client" />
|
||||||
|
|||||||
1
.idea/encodings.xml
generated
1
.idea/encodings.xml
generated
@@ -9,6 +9,7 @@
|
|||||||
<file url="file://$PROJECT_DIR$/jaxwsdemo-service" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/jaxwsdemo-service" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/jmsdemo" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/jmsdemo" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/jpademo" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/jpademo" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/jsfdemo" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/xmlandjsondemo" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/xmlandjsondemo" charset="UTF-8" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
1
.idea/misc.xml
generated
1
.idea/misc.xml
generated
@@ -4,6 +4,7 @@
|
|||||||
<component name="FrameworkDetectionExcludesConfiguration">
|
<component name="FrameworkDetectionExcludesConfiguration">
|
||||||
<file type="web" url="file://$PROJECT_DIR$/jaxrsdemo" />
|
<file type="web" url="file://$PROJECT_DIR$/jaxrsdemo" />
|
||||||
<file type="web" url="file://$PROJECT_DIR$/jaxwsdemo-service" />
|
<file type="web" url="file://$PROJECT_DIR$/jaxwsdemo-service" />
|
||||||
|
<file type="web" url="file://$PROJECT_DIR$/jsfdemo" />
|
||||||
</component>
|
</component>
|
||||||
<component name="GOROOT" path="/usr/lib/go" />
|
<component name="GOROOT" path="/usr/lib/go" />
|
||||||
<component name="Kotlin2JsCompilerArguments">
|
<component name="Kotlin2JsCompilerArguments">
|
||||||
|
|||||||
@@ -4,7 +4,9 @@
|
|||||||
<facet type="jpa" name="JPA">
|
<facet type="jpa" name="JPA">
|
||||||
<configuration>
|
<configuration>
|
||||||
<setting name="validation-enabled" value="true" />
|
<setting name="validation-enabled" value="true" />
|
||||||
<datasource-mapping />
|
<datasource-mapping>
|
||||||
|
<factory-entry name="jaxrsoPU" />
|
||||||
|
</datasource-mapping>
|
||||||
<naming-strategy-map />
|
<naming-strategy-map />
|
||||||
<deploymentDescriptor name="persistence.xml" url="file://$MODULE_DIR$/src/main/resources/META-INF/persistence.xml" />
|
<deploymentDescriptor name="persistence.xml" url="file://$MODULE_DIR$/src/main/resources/META-INF/persistence.xml" />
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|||||||
35
jsfdemo/jsfdemo.iml
Normal file
35
jsfdemo/jsfdemo.iml
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module version="4">
|
||||||
|
<component name="FacetManager">
|
||||||
|
<facet type="jpa" name="JPA">
|
||||||
|
<configuration>
|
||||||
|
<setting name="validation-enabled" value="true" />
|
||||||
|
<datasource-mapping />
|
||||||
|
<naming-strategy-map />
|
||||||
|
<deploymentDescriptor name="persistence.xml" url="file://$MODULE_DIR$/src/main/resources/META-INF/persistence.xml" />
|
||||||
|
</configuration>
|
||||||
|
</facet>
|
||||||
|
<facet type="ejb" name="EJB">
|
||||||
|
<configuration>
|
||||||
|
<ejbRoots>
|
||||||
|
<root url="file://$MODULE_DIR$/src/main/java" />
|
||||||
|
</ejbRoots>
|
||||||
|
</configuration>
|
||||||
|
</facet>
|
||||||
|
<facet type="web" name="Web">
|
||||||
|
<configuration>
|
||||||
|
<descriptors>
|
||||||
|
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/src/main/webapp/WEB-INF/web.xml" />
|
||||||
|
</descriptors>
|
||||||
|
<webroots>
|
||||||
|
<root url="file://$MODULE_DIR$/src/main/webapp" relative="/" />
|
||||||
|
</webroots>
|
||||||
|
<sourceRoots>
|
||||||
|
<root url="file://$MODULE_DIR$/src/main/java" />
|
||||||
|
<root url="file://$MODULE_DIR$/src/main/resources" />
|
||||||
|
<root url="file://$MODULE_DIR$/target/generated-sources/annotations" />
|
||||||
|
</sourceRoots>
|
||||||
|
</configuration>
|
||||||
|
</facet>
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
61
jsfdemo/pom.xml
Normal file
61
jsfdemo/pom.xml
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project 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/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>jsfdemo</artifactId>
|
||||||
|
<packaging>war</packaging>
|
||||||
|
<name>jsfdemo</name>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<artifactId>jeedemo</artifactId>
|
||||||
|
<groupId>it.plague.jeedemo</groupId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<maven.compiler.source>1.7</maven.compiler.source>
|
||||||
|
<maven.compiler.target>1.7</maven.compiler.target>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.glassfish.main.extras</groupId>
|
||||||
|
<artifactId>glassfish-embedded-all</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.8.0</version>
|
||||||
|
<configuration>
|
||||||
|
<source>1.7</source>
|
||||||
|
<target>1.7</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-war-plugin</artifactId>
|
||||||
|
<version>3.2.2</version>
|
||||||
|
<configuration>
|
||||||
|
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
47
jsfdemo/src/main/java/it/plague/jeedemo/Book.java
Normal file
47
jsfdemo/src/main/java/it/plague/jeedemo/Book.java
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
package it.plague.jeedemo;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.NamedQuery;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@XmlRootElement
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Builder
|
||||||
|
@NamedQuery(name = Book.FIND_ALL, query = "select b from Book b")
|
||||||
|
public class Book {
|
||||||
|
|
||||||
|
public static final String FIND_ALL = "FIND_ALL";
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Size(min = 4, max = 50)
|
||||||
|
@Column(nullable = false)
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
private Float price;
|
||||||
|
|
||||||
|
@Column(length = 2000)
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
private String isbn;
|
||||||
|
|
||||||
|
private Integer nbOfPage;
|
||||||
|
|
||||||
|
private Boolean illustrations;
|
||||||
|
|
||||||
|
}
|
||||||
35
jsfdemo/src/main/java/it/plague/jeedemo/BookEJB.java
Normal file
35
jsfdemo/src/main/java/it/plague/jeedemo/BookEJB.java
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
package it.plague.jeedemo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import javax.annotation.sql.DataSourceDefinition;
|
||||||
|
import javax.ejb.Stateless;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
import javax.persistence.EntityManager;
|
||||||
|
|
||||||
|
@Named
|
||||||
|
@Stateless
|
||||||
|
@DataSourceDefinition(
|
||||||
|
name = "java:global/jdbc/lab11DS",
|
||||||
|
className = "org.apache.derby.jdbc.EmbeddedDriver",
|
||||||
|
url = "jdbc:derby:memory:lab11DB;create=true;user=app;password=app"
|
||||||
|
)
|
||||||
|
public class BookEJB {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private EntityManager em;
|
||||||
|
|
||||||
|
public Book createBook(Book book) {
|
||||||
|
em.persist(book);
|
||||||
|
return book;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Book> findAllBooks() {
|
||||||
|
return em.createNamedQuery(Book.FIND_ALL, Book.class).getResultList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Book findBookById(Long id) {
|
||||||
|
return em.find(Book.class, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
36
jsfdemo/src/main/java/it/plague/jeedemo/BookView.java
Normal file
36
jsfdemo/src/main/java/it/plague/jeedemo/BookView.java
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
package it.plague.jeedemo;
|
||||||
|
|
||||||
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
import javax.faces.application.FacesMessage;
|
||||||
|
import javax.faces.context.FacesContext;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Named
|
||||||
|
@RequestScoped
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class BookView {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private BookEJB bookEJB;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private Book book = new Book();
|
||||||
|
|
||||||
|
public void doFindBookById() {
|
||||||
|
book = bookEJB.findBookById(book.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String doCreateBook() {
|
||||||
|
bookEJB.createBook(book);
|
||||||
|
FacesContext.getCurrentInstance().addMessage(null,
|
||||||
|
new FacesMessage(FacesMessage.SEVERITY_INFO, "Book created",
|
||||||
|
"The book " + book.getTitle() + " has been created with id = " + book.getId()));
|
||||||
|
return "newBook.xhtml";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package it.plague.jeedemo;
|
||||||
|
|
||||||
|
import javax.enterprise.inject.Produces;
|
||||||
|
import javax.persistence.EntityManager;
|
||||||
|
import javax.persistence.PersistenceContext;
|
||||||
|
|
||||||
|
public class DatabaseProducer {
|
||||||
|
|
||||||
|
@Produces
|
||||||
|
@PersistenceContext(unitName = "jsfdemoPU")
|
||||||
|
private EntityManager em;
|
||||||
|
}
|
||||||
16
jsfdemo/src/main/resources/META-INF/persistence.xml
Normal file
16
jsfdemo/src/main/resources/META-INF/persistence.xml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<persistence version="2.1"
|
||||||
|
xmlns="http://xmlns.jcp.org/xml/ns/persistence"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
|
||||||
|
|
||||||
|
<persistence-unit name="jsfdemoPU" transaction-type="JTA">
|
||||||
|
<jta-data-source>java:global/jdbc/lab11DS</jta-data-source>
|
||||||
|
<properties>
|
||||||
|
<property name="eclipselink.target-database" value="DERBY"/>
|
||||||
|
<property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
|
||||||
|
<property name="eclipselink.logging.level" value="ALL"/>
|
||||||
|
</properties>
|
||||||
|
</persistence-unit>
|
||||||
|
|
||||||
|
</persistence>
|
||||||
8
jsfdemo/src/main/webapp/WEB-INF/beans.xml
Normal file
8
jsfdemo/src/main/webapp/WEB-INF/beans.xml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<beans
|
||||||
|
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
|
||||||
|
http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
|
||||||
|
bean-discovery-mode="all">
|
||||||
|
</beans>
|
||||||
7
jsfdemo/src/main/webapp/WEB-INF/faces-config.xml
Normal file
7
jsfdemo/src/main/webapp/WEB-INF/faces-config.xml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<faces-config version="2.2" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
|
||||||
|
http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd">
|
||||||
|
|
||||||
|
</faces-config>
|
||||||
15
jsfdemo/src/main/webapp/WEB-INF/web.xml
Normal file
15
jsfdemo/src/main/webapp/WEB-INF/web.xml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
|
||||||
|
version="4.0">
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>Faces Servlet</servlet-name>
|
||||||
|
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
|
||||||
|
<load-on-startup>1</load-on-startup>
|
||||||
|
</servlet>
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>Faces Servlet</servlet-name>
|
||||||
|
<url-pattern>*.xhtml</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
</web-app>
|
||||||
22
jsfdemo/src/main/webapp/layout.xhtml
Normal file
22
jsfdemo/src/main/webapp/layout.xhtml
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?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://xmlns.jcp.org/jsf/html"
|
||||||
|
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
|
||||||
|
|
||||||
|
<h:head>
|
||||||
|
<title><ui:insert name="title">Defautl title</ui:insert></title>
|
||||||
|
</h:head>
|
||||||
|
<h:body>
|
||||||
|
<h:link value="Create a book" outcome="newBook.xhtml"/>
|
||||||
|
|
||||||
|
<h1><ui:insert name="title">Default title</ui:insert></h1>
|
||||||
|
<hr/>
|
||||||
|
<h:messages id="errors" infoStyle="color: blue" warnStyle="color: orange"
|
||||||
|
errorStyle="color: red"/>
|
||||||
|
<ui:insert name="content">Default content</ui:insert>
|
||||||
|
<hr/>
|
||||||
|
<h:outputText value="APress - Beginning Java EE 7" style="font-style: italic"/>
|
||||||
|
</h:body>
|
||||||
|
</html>
|
||||||
47
jsfdemo/src/main/webapp/newBook.xhtml
Normal file
47
jsfdemo/src/main/webapp/newBook.xhtml
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<?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://xmlns.jcp.org/jsf/html"
|
||||||
|
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
|
||||||
|
xmlns:f="http://xmlns.jcp.org/jsf/core">
|
||||||
|
|
||||||
|
<ui:composition template="layout.xhtml">
|
||||||
|
<ui:define name="title">Create new book</ui:define>
|
||||||
|
<ui:define name="content">
|
||||||
|
<h:form id="bookForm">
|
||||||
|
<h:panelGrid columns="2">
|
||||||
|
<h:outputLabel value="Title: "/>
|
||||||
|
<h:inputText value="#{bookView.book.title}"/>
|
||||||
|
<h:outputLabel value="Price: "/>
|
||||||
|
<h:inputText value="#{bookView.book.price}"/>
|
||||||
|
<h:outputLabel value="Description: "/>
|
||||||
|
<h:inputTextarea value="#{bookView.book.description}" cols="16" rows="3"/>
|
||||||
|
<h:outputLabel value="Number of pages: "/>
|
||||||
|
<h:inputText value="#{bookView.book.nbOfPage}"/>
|
||||||
|
<h:outputLabel value="Illustrations: "/>
|
||||||
|
<h:selectBooleanCheckbox value="#{bookView.book.illustrations}"/>
|
||||||
|
</h:panelGrid>
|
||||||
|
<h:commandButton value="Create a book" action="#{bookView.doCreateBook}">
|
||||||
|
<f:ajax execute="@form" render=":booklist :errors"/>
|
||||||
|
</h:commandButton>
|
||||||
|
</h:form>
|
||||||
|
<hr/>
|
||||||
|
<h1>List of books</h1>
|
||||||
|
<h:dataTable id="booklist" value="#{bookEJB.findAllBooks()}" var="bk" border="1">
|
||||||
|
<h:column>
|
||||||
|
<f:facet name="header">
|
||||||
|
<h:outputText value="Title"/>
|
||||||
|
</f:facet>
|
||||||
|
<h:link outcome="viewBook.xhtml?id=#{bk.id}" value="#{bk.title}"/>
|
||||||
|
</h:column>
|
||||||
|
<h:column>
|
||||||
|
<f:facet name="header">
|
||||||
|
<h:outputText value="Price"/>
|
||||||
|
</f:facet>
|
||||||
|
<h:outputText value="#{bk.price}"/>
|
||||||
|
</h:column>
|
||||||
|
</h:dataTable>
|
||||||
|
</ui:define>
|
||||||
|
</ui:composition>
|
||||||
|
</html>
|
||||||
30
jsfdemo/src/main/webapp/viewBook.xhtml
Normal file
30
jsfdemo/src/main/webapp/viewBook.xhtml
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?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://xmlns.jcp.org/jsf/html"
|
||||||
|
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
|
||||||
|
xmlns:f="http://xmlns.jcp.org/jsf/core">
|
||||||
|
|
||||||
|
<ui:composition template="layout.xhtml">
|
||||||
|
<f:metadata>
|
||||||
|
<f:viewParam name="id" value="#{bookView.book.id}"/>
|
||||||
|
<f:viewAction action="#{bookView.doFindBookById}"/>
|
||||||
|
</f:metadata>
|
||||||
|
<ui:define name="title">View a book</ui:define>
|
||||||
|
<ui:define name="content">
|
||||||
|
<h:panelGrid columns="2">
|
||||||
|
<h:outputLabel value="Title: "/>
|
||||||
|
<h:outputText value="#{bookView.book.title}"/>
|
||||||
|
<h:outputLabel value="Price: "/>
|
||||||
|
<h:outputText value="#{bookView.book.price}"/>
|
||||||
|
<h:outputLabel value="Description: "/>
|
||||||
|
<h:outputText value="#{bookView.book.description}"/>
|
||||||
|
<h:outputLabel value="Number of pages: "/>
|
||||||
|
<h:outputText value="#{bookView.book.nbOfPage}"/>
|
||||||
|
<h:outputLabel value="Illustrations: "/>
|
||||||
|
<h:selectBooleanCheckbox value="#{bookView.book.illustrations}"/>
|
||||||
|
</h:panelGrid>
|
||||||
|
</ui:define>
|
||||||
|
</ui:composition>
|
||||||
|
</html>
|
||||||
20
jsfdemo/src/test/java/it/plague/jeedemo/AppTest.java
Normal file
20
jsfdemo/src/test/java/it/plague/jeedemo/AppTest.java
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
package it.plague.jeedemo;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unit test for simple App.
|
||||||
|
*/
|
||||||
|
public class AppTest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Rigorous Test :-)
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void shouldAnswerWithTrue()
|
||||||
|
{
|
||||||
|
assertTrue( true );
|
||||||
|
}
|
||||||
|
}
|
||||||
1
pom.xml
1
pom.xml
@@ -17,6 +17,7 @@
|
|||||||
<module>jmsdemo</module>
|
<module>jmsdemo</module>
|
||||||
<module>jaxwsdemo-service</module>
|
<module>jaxwsdemo-service</module>
|
||||||
<module>jaxrsdemo</module>
|
<module>jaxrsdemo</module>
|
||||||
|
<module>jsfdemo</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
|
|||||||
Reference in New Issue
Block a user