[seam-commits] Seam SVN: r12833 - in examples/trunk: booking-simplified and 26 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Wed May 26 18:31:24 EDT 2010
Author: dan.j.allen
Date: 2010-05-26 18:31:21 -0400 (Wed, 26 May 2010)
New Revision: 12833
Added:
examples/trunk/booking-simplified/
examples/trunk/booking-simplified/pom.xml
examples/trunk/booking-simplified/src/
examples/trunk/booking-simplified/src/main/
examples/trunk/booking-simplified/src/main/java/
examples/trunk/booking-simplified/src/main/java/org/
examples/trunk/booking-simplified/src/main/java/org/jboss/
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/AccountProducer.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/AccountProducerBean.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManager.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManagerBean.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Registered.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Registrar.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/RegistrarBean.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgent.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgentBean.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingEvent.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistory.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistoryBean.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/Confirmed.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/controls/
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/controls/BookingFormControls.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/controls/RegistrationFormControls.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearch.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearchBean.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/SearchCriteria.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/Booking.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/CreditCardType.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/Hotel.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/User.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/CalendarReferenceProducer.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/CreditCardExpiryYears.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/CreditCardReferenceProducer.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/Month.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/AuthenticationEventListener.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Authenticator.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/AuthenticatorBean.java
examples/trunk/booking-simplified/src/main/resources/
examples/trunk/booking-simplified/src/main/resources/META-INF/
examples/trunk/booking-simplified/src/main/resources/META-INF/beans.xml
examples/trunk/booking-simplified/src/main/resources/META-INF/persistence.xml
examples/trunk/booking-simplified/src/main/resources/import.sql
examples/trunk/booking-simplified/src/main/resources/messages.properties
examples/trunk/booking-simplified/src/main/webapp/
examples/trunk/booking-simplified/src/main/webapp/WEB-INF/
examples/trunk/booking-simplified/src/main/webapp/WEB-INF/faces-config.xml
examples/trunk/booking-simplified/src/main/webapp/WEB-INF/fragments/
examples/trunk/booking-simplified/src/main/webapp/WEB-INF/fragments/account.xhtml
examples/trunk/booking-simplified/src/main/webapp/WEB-INF/fragments/hotel.xhtml
examples/trunk/booking-simplified/src/main/webapp/WEB-INF/layout/
examples/trunk/booking-simplified/src/main/webapp/WEB-INF/layout/template.xhtml
examples/trunk/booking-simplified/src/main/webapp/WEB-INF/web.xml
examples/trunk/booking-simplified/src/main/webapp/account.xhtml
examples/trunk/booking-simplified/src/main/webapp/book.xhtml
examples/trunk/booking-simplified/src/main/webapp/confirm.xhtml
examples/trunk/booking-simplified/src/main/webapp/css/
examples/trunk/booking-simplified/src/main/webapp/css/screen.css
examples/trunk/booking-simplified/src/main/webapp/denied.xhtml
examples/trunk/booking-simplified/src/main/webapp/error.xhtml
examples/trunk/booking-simplified/src/main/webapp/favicon.ico
examples/trunk/booking-simplified/src/main/webapp/home.xhtml
examples/trunk/booking-simplified/src/main/webapp/hotel.xhtml
examples/trunk/booking-simplified/src/main/webapp/img/
examples/trunk/booking-simplified/src/main/webapp/img/1-star.gif
examples/trunk/booking-simplified/src/main/webapp/img/2-star.gif
examples/trunk/booking-simplified/src/main/webapp/img/3-star.gif
examples/trunk/booking-simplified/src/main/webapp/img/4-star.gif
examples/trunk/booking-simplified/src/main/webapp/img/5-star.gif
examples/trunk/booking-simplified/src/main/webapp/img/bg.gif
examples/trunk/booking-simplified/src/main/webapp/img/btn.bg.gif
examples/trunk/booking-simplified/src/main/webapp/img/cal-next.png
examples/trunk/booking-simplified/src/main/webapp/img/cal-prev.png
examples/trunk/booking-simplified/src/main/webapp/img/cnt.bg.gif
examples/trunk/booking-simplified/src/main/webapp/img/dtpick.gif
examples/trunk/booking-simplified/src/main/webapp/img/hdr.ad.jpg
examples/trunk/booking-simplified/src/main/webapp/img/hdr.bar.jpg
examples/trunk/booking-simplified/src/main/webapp/img/hdr.bg.gif
examples/trunk/booking-simplified/src/main/webapp/img/hdr.title.gif
examples/trunk/booking-simplified/src/main/webapp/img/header_line.gif
examples/trunk/booking-simplified/src/main/webapp/img/input.bg.gif
examples/trunk/booking-simplified/src/main/webapp/img/sdb.bg.gif
examples/trunk/booking-simplified/src/main/webapp/img/spinner.gif
examples/trunk/booking-simplified/src/main/webapp/img/th.bg.gif
examples/trunk/booking-simplified/src/main/webapp/index.html
examples/trunk/booking-simplified/src/main/webapp/main.xhtml
examples/trunk/booking-simplified/src/main/webapp/password.xhtml
examples/trunk/booking-simplified/src/main/webapp/register.xhtml
examples/trunk/booking-simplified/src/main/webapp/resources/
examples/trunk/booking-simplified/src/main/webapp/resources/components/
examples/trunk/booking-simplified/src/main/webapp/resources/components/property/
examples/trunk/booking-simplified/src/main/webapp/resources/components/property/display.xhtml
examples/trunk/booking-simplified/src/main/webapp/resources/components/property/edit.xhtml
Log:
restructure booking example as a simplified war
still requires work to run
Property changes on: examples/trunk/booking-simplified
___________________________________________________________________
Name: svn:ignore
+ target
Added: examples/trunk/booking-simplified/pom.xml
===================================================================
--- examples/trunk/booking-simplified/pom.xml (rev 0)
+++ examples/trunk/booking-simplified/pom.xml 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,570 @@
+<?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/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.jboss.weld.examples</groupId>
+ <artifactId>weld-examples-parent</artifactId>
+ <version>1.0.1-Final</version>
+ </parent>
+
+ <groupId>org.jboss.seam.examples</groupId>
+ <artifactId>seam-booking-simplified</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ <packaging>war</packaging>
+ <name>Seam Booking Example (Simplified packaging)</name>
+ <description>The Seam booking example packaged using the simplified Java EE packaging</description>
+ <url>http://www.seamframework.org/Seam3</url>
+ <licenses>
+ <license>
+ <name>Apache License, Version 2.0</name>
+ <distribution>repo</distribution>
+ <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
+ </license>
+ </licenses>
+
+ <properties>
+ <jetty.http.port>9090</jetty.http.port>
+ <jetty.stop.port>9091</jetty.stop.port>
+ <jetty.debug.port>9190</jetty.debug.port>
+ <jetty.daemon>false</jetty.daemon>
+ <tomcat.http.port>6060</tomcat.http.port>
+ <embedded-tomcat.http.port>9090</embedded-tomcat.http.port>
+ <embedded-tomcat.debug.port>9190</embedded-tomcat.debug.port>
+ <webapp.directory>src/main/webapp</webapp.directory>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.jboss.spec</groupId>
+ <artifactId>jboss-javaee-6.0</artifactId>
+ <version>1.0.0.Beta4</version>
+ <type>pom</type>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.seam.faces</groupId>
+ <artifactId>seam-faces-api</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.seam.faces</groupId>
+ <artifactId>seam-faces</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.seam.security</groupId>
+ <artifactId>seam-security-api</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.seam.security</groupId>
+ <artifactId>seam-security-impl</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.seam.xml</groupId>
+ <artifactId>seam-xml-config</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.5.10</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <scope>test</scope>
+ <classifier>jdk15</classifier>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <defaultGoal>package</defaultGoal>
+ <finalName>weld-permalink</finalName>
+ <!--
+ <finalName>${project.artifactId}</finalName>
+ -->
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-clean-plugin</artifactId>
+ <configuration>
+ <failOnError>false</failOnError>
+ <filesets>
+ <fileset>
+ <!-- clean up files from war:inplace -->
+ <directory>${webapp.directory}</directory>
+ <includes>
+ <include>META-INF/**</include>
+ <include>WEB-INF/classes/**</include>
+ <include>WEB-INF/lib/**</include>
+ </includes>
+ <followSymlinks>false</followSymlinks>
+ </fileset>
+ </filesets>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-eclipse-plugin</artifactId>
+ <configuration>
+ <additionalBuildcommands>
+ <!--
+ annoyingly creates a bin directory <buildCommand>
+ <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
+ </buildCommand>
+ -->
+ <buildCommand>
+ <name>org.jboss.tools.common.verification.verifybuilder</name>
+ </buildCommand>
+ </additionalBuildcommands>
+ <additionalConfig>
+ <file>
+ <name>.settings/org.maven.ide.eclipse.prefs</name>
+ <content>activeProfiles=jdk5
+ eclipse.preferences.version=1
+ fullBuildGoals=process-test-resources
+ includeModules=false
+ resolveWorkspaceProjects=true
+ resourceFilterGoals=process-resources
+ resources\:testResources
+ skipCompilerPlugin=true
+ version=1</content>
+ </file>
+ </additionalConfig>
+ <additionalProjectFacets>
+ <jst.jsf>1.2</jst.jsf> <!-- 2.0 is not yet supported -->
+ </additionalProjectFacets>
+ <additionalProjectnatures>
+ <projectnature>org.eclipse.wst.jsdt.core.jsNature</projectnature>
+ <projectnature>org.jboss.tools.jsf.jsfnature</projectnature>
+ </additionalProjectnatures>
+ <workspace>${user.home}/.eclipse/workspace</workspace>
+ <wtpdefaultserver>JBoss</wtpdefaultserver>
+ <wtpversion>1.5</wtpversion>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-war-plugin</artifactId>
+ <configuration>
+ <!--
+ don't stage or package files added to
+ ${webapp.directory} by war:inplace
+ -->
+ <warSourceExcludes>WEB-INF/classes/**,WEB-INF/lib/**</warSourceExcludes>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.twdata.maven</groupId>
+ <artifactId>maven-cli-plugin</artifactId>
+ <configuration>
+ <prompt>${project.artifactId}</prompt>
+ <!-- userAliases are for cli:execute-phase -->
+ <userAliases>
+ <runjetty>compile
+ org.mortbay.jetty:maven-jetty-plugin:run -Pjetty</runjetty>
+ <stopjetty>org.mortbay.jetty:maven-jetty-plugin:stop
+ -Pjetty</stopjetty>
+ <runtomcat>compile
+ org.apache.maven.plugins:maven-war-plugin:inplace
+ org.codehaus.mojo:tomcat-maven-plugin:run -Ptomcat</runtomcat>
+ <explode>compile -o</explode>
+ <!-- tomcat requires use of war:inplace -->
+ <tcexplode>compile
+ org.apache.maven.plugins:maven-war-plugin:inplace
+ -Ptomcat -o</tcexplode>
+ <restart>org.apache.maven.plugins:maven-antrun-plugin:run
+ -Prestart-embedded</restart>
+ <profiles>org.apache.maven.plugins:maven-help-plugin:active-profiles
+ -o</profiles>
+ <pom>org.apache.maven.plugins:maven-help-plugin:effective-pom
+ -o</pom>
+ </userAliases>
+ <!-- commands are for cli:execute -->
+ <commands>
+ </commands>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>tomcat</id>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-impl</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jstl</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.transaction</groupId>
+ <artifactId>jta</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.validation</groupId>
+ <artifactId>validation-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-validator</artifactId>
+ <version>4.0.0.GA</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.weld.servlet</groupId>
+ <artifactId>weld-servlet</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.glassfish.web</groupId>
+ <artifactId>el-impl</artifactId>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.el</groupId>
+ <artifactId>el-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>src/log/resources</directory>
+ </resource>
+ <resource>
+ <directory>src/main/resources</directory>
+ </resource>
+ </resources>
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <configuration>
+ <webResources>
+ <resource>
+ <directory>src/main/webapp-tomcat</directory>
+ <filtering>false</filtering>
+ </resource>
+ </webResources>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>tomcat-maven-plugin</artifactId>
+ <configuration>
+ <path>/${project.build.finalName}</path>
+ <!--
+ uncomment to use server configuration override;
+ see readme.txt for details
+ -->
+ <!--<server>tomcatserver</server>-->
+ <url>http://localhost:${tomcat.http.port}/manager</url>
+ <port>${embedded-tomcat.http.port}</port>
+ <!--
+ port for embedded Tomcat only (putting this
+ configuration in the execution for the run goal
+ doesn't work)
+ -->
+ <!--
+ this isn't useful to us because we also need an
+ web.xml override
+ -->
+ <!--
+ <contextFile>src/main/webapp-tomcat/META-INF/context.xml</contextFile>
+ -->
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+
+ </profile>
+
+ <profile>
+ <id>jetty</id>
+
+ <dependencies>
+ <!-- (same dependencies as tomcat except for javax.servlet:jstl) -->
+
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-impl</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.transaction</groupId>
+ <artifactId>jta</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.validation</groupId>
+ <artifactId>validation-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-validator</artifactId>
+ <version>4.0.0.GA</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-jdk14</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.weld.servlet</groupId>
+ <artifactId>weld-servlet</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.glassfish.web</groupId>
+ <artifactId>el-impl</artifactId>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.el</groupId>
+ <artifactId>el-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>src/log/resources</directory>
+ </resource>
+ <resource>
+ <directory>src/main/resources</directory>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <configuration>
+ <connectors>
+ <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
+ <port>${jetty.http.port}</port>
+ <maxIdleTime>3600000</maxIdleTime>
+ </connector>
+ </connectors>
+ <daemon>${jetty.daemon}</daemon>
+ <stopPort>${jetty.stop.port}</stopPort>
+ <stopKey>HASTA_LA_VISTA</stopKey>
+ <scanIntervalSeconds>10</scanIntervalSeconds>
+ <contextPath>/${project.build.finalName}</contextPath>
+ <overrideWebXml>src/main/webapp-jetty/WEB-INF/override-web.xml</overrideWebXml>
+ <jettyEnvXml>src/main/webapp-jetty/WEB-INF/jetty-env.xml</jettyEnvXml>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ </profile>
+ <profile>
+ <id>ftest-jboss-remote-51</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+
+ <properties>
+ <ftest.artifact>ftest-permalink</ftest.artifact>
+ <ftest.version>0.1${ftest.version.discriminator}</ftest.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.weld.examples.ftest</groupId>
+ <artifactId>${ftest.artifact}</artifactId>
+ <version>${ftest.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.cargo</groupId>
+ <artifactId>cargo-maven2-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>selenium-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>failsafe-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>ftest-jboss-remote-60</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+
+ <properties>
+ <ftest.artifact>ftest-permalink</ftest.artifact>
+ <ftest.version>0.1${ftest.version.discriminator}</ftest.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.weld.examples.ftest</groupId>
+ <artifactId>${ftest.artifact}</artifactId>
+ <version>${ftest.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.cargo</groupId>
+ <artifactId>cargo-maven2-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>selenium-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>failsafe-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>restart-embedded</id>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <configuration>
+ <tasks>
+ <touch file="${webapp.directory}/WEB-INF/web.xml" />
+ </tasks>
+ </configuration>
+ <!-- Hooking an execution to a phase is more correct, but slower -->
+ <!--
+ <executions> <execution> <id>touch-web-inf</id>
+ <phase>validate</phase> <configuration> <tasks>
+ <touch file="${webapp.directory}/WEB-INF/web.xml" /> </tasks> </configuration> <goals>
+ <goal>run</goal> </goals> </execution>
+ </executions>
+ -->
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+ <scm>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/weld/examples/trunk/jsf/permalink</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/weld/examples/trunk/jsf/permalink</developerConnection>
+ <url>http://fisheye.jboss.org/browse/weld/examples/trunk/jsf/permalink</url>
+ </scm>
+
+</project>
Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/AccountProducer.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/AccountProducer.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/AccountProducer.java 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,17 @@
+package org.jboss.seam.examples.booking.account;
+
+import javax.ejb.Local;
+import org.jboss.seam.examples.booking.model.User;
+
+/**
+ * The <strong>AccountProducer</strong> produces the object that
+ * represents the current user's account information. The account
+ * information is represented by the {@link User} entity.
+ *
+ * @author Dan Allen
+ */
+ at Local
+public interface AccountProducer
+{
+ User getCurrentAccount();
+}
Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/AccountProducerBean.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/AccountProducerBean.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/AccountProducerBean.java 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,51 @@
+package org.jboss.seam.examples.booking.account;
+
+import javax.ejb.Stateless;
+import javax.enterprise.context.SessionScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.enterprise.inject.Produces;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.jboss.seam.examples.booking.model.User;
+import org.jboss.seam.security.Credentials;
+import org.jboss.seam.security.Identity;
+import org.slf4j.Logger;
+
+/**
+ * @author Dan Allen
+ */
+ at Stateless
+public class AccountProducerBean implements AccountProducer
+{
+ @Inject private Logger log;
+
+ @PersistenceContext private EntityManager em;
+
+ @Inject private Identity identity;
+
+ @Inject private Credentials credentials;
+
+ public
+ @Produces
+ @Registered
+ @Named("user")
+ @SessionScoped
+ User getCurrentAccount()
+ {
+ if (identity.isLoggedIn())
+ {
+ log.info("Producing user from username {0}", credentials.getUsername());
+ User candidate = em.find(User.class, credentials.getUsername());
+ if (candidate != null)
+ {
+ return new User(candidate.getName(), candidate.getUsername());
+ }
+ }
+
+ log.info("Producing dummy User");
+ // TODO can't return null because this is a scoped producer, but then we are not honoring the semantics of our binding type
+ return new User();
+ }
+}
Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManager.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManager.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManager.java 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,25 @@
+package org.jboss.seam.examples.booking.account;
+
+import javax.ejb.Local;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+/**
+ *
+ * @author Dan Allen
+ */
+ at Local
+public interface PasswordManager
+{
+ void changePassword();
+
+ boolean isChanged();
+
+ void setConfirmPassword(String password);
+
+ @NotNull
+ @Size(min = 5, max = 15)
+ String getConfirmPassword();
+
+ void destroy();
+}
Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManagerBean.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManagerBean.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManagerBean.java 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,74 @@
+package org.jboss.seam.examples.booking.account;
+
+import javax.annotation.PreDestroy;
+import javax.ejb.Stateful;
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.jboss.seam.examples.booking.controls.RegistrationFormControls;
+import org.jboss.seam.examples.booking.model.User;
+import org.jboss.seam.international.StatusMessages;
+
+/**
+ * @author Dan Allen
+ */
+ at Named("passwordManager")
+ at Stateful
+ at RequestScoped
+public class PasswordManagerBean implements PasswordManager
+{
+ @PersistenceContext private EntityManager em;
+
+ @Inject private StatusMessages statusMessages;
+
+ @Inject private RegistrationFormControls formControls;
+
+ @Inject @Registered private User user;
+
+ private String confirmPassword;
+
+ private boolean changed;
+
+ public void changePassword()
+ {
+ if (user.getPassword().equals(confirmPassword))
+ {
+ // FIXME: dirty hack, can't merge a managed bean
+ em.merge(new User(user.getName(), user.getUsername(), user.getPassword()));
+ user.setPassword(null);
+ statusMessages.addFromResourceBundleOrDefault("account.passwordChanged", "Password successfully updated.");
+ changed = true;
+ }
+ else
+ {
+ // FIME reverting isn't going to work here
+ //revertUser();
+ confirmPassword = null;
+ statusMessages.addToControlFromResourceBundleOrDefault(formControls.getConfirmPasswordControlId(),
+ "account.passwordsDoNotMatch", "Passwords do not match. Please re-type the new password.");
+ }
+ }
+
+ public boolean isChanged()
+ {
+ return changed;
+ }
+
+ public void setConfirmPassword(String password)
+ {
+ this.confirmPassword = password;
+ }
+
+ public String getConfirmPassword()
+ {
+ return this.confirmPassword;
+ }
+
+ @PreDestroy
+ public void destroy()
+ {
+ }
+}
Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Registered.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Registered.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Registered.java 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,31 @@
+package org.jboss.seam.examples.booking.account;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+import org.jboss.seam.examples.booking.model.User;
+
+/**
+ * A binding type representing something that is registererd.
+ * In this simple application the only thing that can be
+ * registered is a {@link User}.
+ *
+ * @author Dan Allen
+ */
+ at Target({TYPE, METHOD, PARAMETER, FIELD})
+ at Retention(RUNTIME)
+ at Documented
+ at Qualifier
+public @interface Registered
+{
+}
Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Registrar.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Registrar.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Registrar.java 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,31 @@
+package org.jboss.seam.examples.booking.account;
+
+import javax.ejb.Local;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import org.jboss.seam.examples.booking.model.User;
+
+/**
+ * @author Dan Allen
+ */
+ at Local
+public interface Registrar
+{
+ void register();
+
+ boolean isRegistrationInvalid();
+
+ void notifyIfRegistrationIsInvalid(boolean validationFailed);
+
+ User getNewUser();
+
+ boolean isRegistered();
+
+ @NotNull
+ @Size(min = 5, max = 15)
+ String getConfirmPassword();
+
+ void setConfirmPassword(String password);
+
+ void destroy();
+}
Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/RegistrarBean.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/RegistrarBean.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/RegistrarBean.java 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,134 @@
+package org.jboss.seam.examples.booking.account;
+
+import javax.annotation.PreDestroy;
+import javax.ejb.Stateful;
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.enterprise.inject.Produces;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.jboss.seam.examples.booking.controls.RegistrationFormControls;
+import org.jboss.seam.examples.booking.model.User;
+import org.jboss.seam.international.StatusMessage;
+import org.jboss.seam.international.StatusMessages;
+import org.jboss.seam.security.Credentials;
+import org.jboss.seam.security.Identity;
+
+/**
+ * @author Dan Allen
+ */
+ at Named("registrar")
+ at Stateful
+ at RequestScoped
+public class RegistrarBean implements Registrar
+{
+ @PersistenceContext private EntityManager em;
+
+ @Inject private StatusMessages statusMessages;
+
+ @Inject private RegistrationFormControls formControls;
+
+ @Inject private Credentials credentials;
+
+ @Inject private Identity identity;
+
+ private User newUser;
+
+ private String confirmPassword;
+
+ private boolean registered;
+
+ private boolean registrationInvalid;
+
+ public void register()
+ {
+ if (verifyPasswordsMatch() && verifyUsernameIsAvailable())
+ {
+ em.persist(newUser);
+ credentials.setUsername(newUser.getUsername());
+ credentials.setPassword(newUser.getPassword());
+ identity.quietLogin();
+ registered = true;
+ statusMessages.addFromResourceBundleOrDefault("registration.registered", "You have been successfully registered as the user {0}!", newUser.getUsername());
+ }
+ else
+ {
+ registrationInvalid = true;
+ }
+ }
+
+ public boolean isRegistrationInvalid()
+ {
+ return registrationInvalid;
+ }
+
+ // TODO it would be nice to move the conditional to the UI but <f:event> doesn't support if=""
+ public void notifyIfRegistrationIsInvalid(boolean validationFailed)
+ {
+ if (validationFailed || registrationInvalid)
+ {
+ statusMessages.addFromResourceBundleOrDefault(StatusMessage.Severity.WARN, "registration.invalid", "Invalid registration. Please correct the errors and try again.");
+ }
+ }
+
+ public
+ @Produces
+ @Named
+ @RequestScoped
+ User getNewUser()
+ {
+ newUser = new User();
+ return newUser;
+ }
+
+ public boolean isRegistered()
+ {
+ return registered;
+ }
+
+ public String getConfirmPassword()
+ {
+ return confirmPassword;
+ }
+
+ public void setConfirmPassword(String password)
+ {
+ this.confirmPassword = password;
+ }
+
+ /**
+ * Verify that the same password is entered twice.
+ */
+ private boolean verifyPasswordsMatch()
+ {
+ if (!newUser.getPassword().equals(confirmPassword))
+ {
+ statusMessages.addToControlFromResourceBundleOrDefault(formControls.getConfirmPasswordControlId(),
+ "account.passwordsDoNotMatch", "Passwords do not match. Please re-type your password.");
+ confirmPassword = null;
+ return false;
+ }
+
+ return true;
+ }
+
+ private boolean verifyUsernameIsAvailable()
+ {
+ User existing = em.find(User.class, newUser.getUsername());
+ if (existing != null)
+ {
+ statusMessages.addToControlFromResourceBundleOrDefault(formControls.getUsernameControlId(),
+ "account.usernameTaken", "The username '{0}' is already taken. Please choose another username.", newUser.getUsername());
+ return false;
+ }
+
+ return true;
+ }
+
+ @PreDestroy
+ public void destroy()
+ {
+ }
+}
Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgent.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgent.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgent.java 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * $Id$
+ */
+package org.jboss.seam.examples.booking.booking;
+
+import javax.ejb.Local;
+import org.jboss.seam.examples.booking.model.Booking;
+import org.jboss.seam.examples.booking.model.Hotel;
+
+/**
+ * @author Dan Allen
+ */
+ at Local
+public interface BookingAgent
+{
+ void selectHotel(Hotel hotel);
+
+ void bookHotel();
+
+ void validateBooking();
+
+ void cancel();
+
+ void confirm();
+
+ Hotel getHotelSelection();
+
+ Booking getBooking();
+
+ boolean isBookingValid();
+
+ void destroy();
+}
Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgentBean.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgentBean.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgentBean.java 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,162 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * $Id$
+ */
+package org.jboss.seam.examples.booking.booking;
+
+import static javax.persistence.PersistenceContextType.EXTENDED;
+
+import java.util.Calendar;
+
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+import javax.enterprise.context.Conversation;
+import javax.enterprise.context.ConversationScoped;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.AnnotationLiteral;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.jboss.seam.examples.booking.account.Registered;
+import org.jboss.seam.examples.booking.controls.BookingFormControls;
+import org.jboss.seam.examples.booking.model.Booking;
+import org.jboss.seam.examples.booking.model.Hotel;
+import org.jboss.seam.examples.booking.model.User;
+import org.jboss.seam.international.StatusMessages;
+import org.slf4j.Logger;
+
+ at Named("bookingAgent")
+ at Stateful
+ at ConversationScoped
+public class BookingAgentBean implements BookingAgent
+{
+ @Inject private Logger log;
+
+ @PersistenceContext(type = EXTENDED) private EntityManager em;
+
+ @Inject private Conversation conversation;
+
+ @Inject private StatusMessages statusMessages;
+
+ @Inject private BookingFormControls formControls;
+
+ @Inject @Registered private User user;
+
+ //@Inject @Fires @Confirmed Event<BookingEvent> bookingConfirmedEvent;
+ @Inject private BeanManager manager;
+
+ private Hotel hotelSelection;
+
+ private Booking booking;
+
+ private boolean bookingValid;
+
+ public void selectHotel(Hotel hotel)
+ {
+ // NOTE get a fresh reference that's managed by the conversational persistence context
+ hotelSelection = em.find(Hotel.class, hotel.getId());
+ log.info("Selected the {0} in {1}", hotelSelection.getName(), hotelSelection.getCity());
+ conversation.begin();
+ }
+
+ public void bookHotel()
+ {
+ booking = new Booking(hotelSelection, user);
+ // QUESTION push logic into Booking?
+ Calendar calendar = Calendar.getInstance();
+ booking.setCheckinDate(calendar.getTime());
+ calendar.add(Calendar.DAY_OF_MONTH, 1);
+ booking.setCheckoutDate(calendar.getTime());
+ hotelSelection = null;
+ statusMessages.addFromResourceBundleOrDefault("booking.initiated", "You've initiated a booking at {0}.", booking.getHotel().getName());
+ }
+
+ public void validateBooking()
+ {
+ Calendar calendar = Calendar.getInstance();
+ calendar.add(Calendar.DAY_OF_MONTH, -1);
+ if (booking.getCheckinDate().before(calendar.getTime()))
+ {
+ statusMessages.addToControlFromResourceBundleOrDefault(formControls.getCheckinDateControlId(), "booking.checkInNotFutureDate", "Check in date must be a future date");
+ bookingValid = false;
+ }
+ else if (!booking.getCheckinDate().before(booking.getCheckoutDate()))
+ {
+ statusMessages.addToControlFromResourceBundleOrDefault(formControls.getCheckoutDateControlId(), "booking.checkOutBeforeCheckIn", "Check out date must be after check in date");
+ bookingValid = false;
+ }
+ else
+ {
+ bookingValid = true;
+ }
+ }
+
+ public void confirm()
+ {
+ em.persist(booking);
+ // FIXME can't inject event object into bean with passivating scope
+ //bookingConfirmedEvent.fire(new BookingEvent(booking));
+ manager.fireEvent(new BookingEvent(booking), new AnnotationLiteral<Confirmed>() {});
+ log.info("New booking at the {0} confirmed for {1}", booking.getHotel().getName(), booking.getUser().getName());
+ statusMessages.addFromResourceBundleOrDefault("booking.confirmed", "Booking confirmed.");
+ conversation.end();
+ }
+
+ public void cancel()
+ {
+ booking = null;
+ hotelSelection = null;
+ conversation.end();
+ }
+
+ public
+ @Produces
+ @Named
+ @ConversationScoped
+ Booking getBooking()
+ {
+ return booking;
+ }
+
+ public
+ @Produces
+ @Named("hotel")
+ @RequestScoped
+ Hotel getHotelSelection()
+ {
+ return booking != null ? booking.getHotel() : hotelSelection;
+ }
+
+ public boolean isBookingValid()
+ {
+ return bookingValid;
+ }
+
+ @Remove
+ public void destroy()
+ {
+ }
+}
Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingEvent.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingEvent.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingEvent.java 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,25 @@
+package org.jboss.seam.examples.booking.booking;
+
+import org.jboss.seam.examples.booking.model.Booking;
+
+/**
+ * An event that is raised when a booking change occurs
+ * (either a new booking is confirmed or an existing
+ * booking is canceled).
+ *
+ * @author Dan Allen
+ */
+public class BookingEvent
+{
+ private Booking booking;
+
+ public BookingEvent(Booking booking)
+ {
+ this.booking = booking;
+ }
+
+ public Booking getBooking()
+ {
+ return booking;
+ }
+}
Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistory.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistory.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistory.java 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,19 @@
+package org.jboss.seam.examples.booking.booking;
+
+import java.util.List;
+import javax.ejb.Local;
+import org.jboss.seam.examples.booking.model.Booking;
+
+/**
+ * @author Dan Allen
+ */
+public interface BookingHistory
+{
+ List<Booking> getBookingsForCurrentUser();
+
+ void cancelBooking(Booking booking);
+
+ void destroy();
+
+ void afterBookingConfirmed(BookingEvent bookingEvent);
+}
Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistoryBean.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistoryBean.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistoryBean.java 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,82 @@
+package org.jboss.seam.examples.booking.booking;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.annotation.PreDestroy;
+import javax.ejb.Stateful;
+import javax.enterprise.context.SessionScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.enterprise.inject.Produces;
+import javax.enterprise.event.Observes;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.jboss.seam.examples.booking.account.Registered;
+import org.jboss.seam.examples.booking.model.Booking;
+import org.jboss.seam.examples.booking.model.User;
+import org.jboss.seam.international.StatusMessages;
+import org.slf4j.Logger;
+
+/**
+ * @author Dan Allen
+ */
+ at Named("bookingHistory")
+ at Stateful
+ at SessionScoped
+public class BookingHistoryBean implements BookingHistory {
+
+ @Inject private Logger log;
+
+ @PersistenceContext private EntityManager em;
+
+ @Inject private StatusMessages statusMessages;
+
+ @Inject @Registered private User user;
+
+ private List<Booking> bookingsForUser = new ArrayList<Booking>();
+
+ public
+ @Produces
+ @Registered
+ @Named("bookings")
+ @SessionScoped
+ List<Booking> getBookingsForCurrentUser()
+ {
+ bookingsForUser.clear();
+ bookingsForUser.addAll(em.createQuery("select b from Booking b join fetch b.hotel where b.user.username = :username order by b.checkinDate")
+ .setParameter("username", user.getUsername())
+ .getResultList());
+ return bookingsForUser;
+ }
+
+ // TODO should probably observe @AfterTransactionSuccess (but it is broken)
+ public void afterBookingConfirmed(@Observes @Confirmed BookingEvent bookingEvent)
+ {
+ getBookingsForCurrentUser();
+ }
+
+ public void cancelBooking(Booking selectedBooking)
+ {
+ log.info("Canceling booking {0} for {1}", selectedBooking.getId(), user.getName());
+ Booking booking = em.find(Booking.class, selectedBooking.getId());
+ if (booking != null)
+ {
+ em.remove(booking);
+ statusMessages.addFromResourceBundleOrDefault("booking.canceled", "The booking at the {0} on {1,date} has been canceled.", selectedBooking.getHotel().getName(), selectedBooking.getCheckinDate());
+ }
+ else
+ {
+ statusMessages.addFromResourceBundleOrDefault("booking.doesNotExist", "Our records indicate that the booking you selected has already been canceled.");
+ }
+
+ bookingsForUser.remove(selectedBooking);
+ }
+
+ @PreDestroy
+ public void destroy()
+ {
+ }
+
+}
Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/Confirmed.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/Confirmed.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/Confirmed.java 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,25 @@
+package org.jboss.seam.examples.booking.booking;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+/**
+ * @author Dan Allen
+ */
+ at Target({TYPE, METHOD, PARAMETER, FIELD})
+ at Retention(RUNTIME)
+ at Documented
+ at Qualifier
+public @interface Confirmed
+{
+}
Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/controls/BookingFormControls.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/controls/BookingFormControls.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/controls/BookingFormControls.java 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,52 @@
+package org.jboss.seam.examples.booking.controls;
+
+import java.io.Serializable;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Named;
+import javax.faces.component.UIComponent;
+
+/**
+ * A UI binding bean that can provide access to the local id and client id
+ * of selected input components in the booking form.
+ *
+ * @author Dan Allen
+ */
+ at Named
+ at RequestScoped
+public class BookingFormControls implements Serializable
+{
+ private UIComponent checkinDate;
+
+ private UIComponent checkoutDate;
+
+ public UIComponent getCheckinDate()
+ {
+ return checkinDate;
+ }
+
+ public String getCheckinDateControlId()
+ {
+ return checkinDate.getClientId();
+ }
+
+ public void setCheckinDate(UIComponent checkinDate)
+ {
+ this.checkinDate = checkinDate;
+ }
+
+ public UIComponent getCheckoutDate()
+ {
+ return checkoutDate;
+ }
+
+ public void setCheckoutDate(UIComponent checkoutDate)
+ {
+ this.checkoutDate = checkoutDate;
+ }
+
+ public String getCheckoutDateControlId()
+ {
+ return checkoutDate.getClientId();
+ }
+}
Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/controls/RegistrationFormControls.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/controls/RegistrationFormControls.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/controls/RegistrationFormControls.java 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,53 @@
+package org.jboss.seam.examples.booking.controls;
+
+import java.io.Serializable;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Named;
+import javax.faces.component.UIComponent;
+
+/**
+ * A UI binding bean that can provide access to the local id and client id
+ * of selected input components in the registration form.
+ *
+ * @author Dan Allen
+ */
+ at Named
+ at RequestScoped
+public class RegistrationFormControls implements Serializable
+{
+ private UIComponent username;
+
+ private UIComponent confirmPassword;
+
+ public UIComponent getConfirmPassword()
+ {
+ return confirmPassword;
+ }
+
+ public void setConfirmPassword(UIComponent confirmPassword)
+ {
+ this.confirmPassword = confirmPassword;
+ }
+
+ public String getConfirmPasswordControlId()
+ {
+ return confirmPassword.getClientId();
+ }
+
+ public UIComponent getUsername()
+ {
+ return username;
+ }
+
+ public void setUsername(UIComponent username)
+ {
+ this.username = username;
+ }
+
+ public String getUsernameControlId()
+ {
+ return username.getClientId();
+ }
+
+}
Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearch.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearch.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearch.java 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * $Id$
+ */
+package org.jboss.seam.examples.booking.inventory;
+
+import java.util.List;
+import javax.ejb.Local;
+import org.jboss.seam.examples.booking.model.Hotel;
+
+ at Local
+public interface HotelSearch
+{
+ public void find();
+
+ public void previousPage();
+
+ public void nextPage();
+
+ public List<Hotel> getHotels();
+
+ public boolean isNextPageAvailable();
+
+ public boolean isPreviousPageAvailable();
+
+ public void destroy();
+}
Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearchBean.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearchBean.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearchBean.java 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,116 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * $Id$
+ */
+package org.jboss.seam.examples.booking.inventory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+import javax.enterprise.context.SessionScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.enterprise.inject.Produces;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.jboss.seam.examples.booking.model.Hotel;
+import org.slf4j.Logger;
+
+ at Named("hotelSearch")
+ at Stateful
+ at SessionScoped
+public class HotelSearchBean implements HotelSearch
+{
+ @Inject private Logger log;
+
+ @PersistenceContext private EntityManager em;
+
+ @Inject private SearchCriteria criteria;
+
+ private boolean nextPageAvailable = false;
+
+ private List<Hotel> hotels = new ArrayList<Hotel>();
+
+ public void find()
+ {
+ criteria.firstPage();
+ queryHotels(criteria);
+ }
+
+ public void nextPage()
+ {
+ criteria.nextPage();
+ queryHotels(criteria);
+ }
+
+ public void previousPage()
+ {
+ criteria.previousPage();
+ queryHotels(criteria);
+ }
+
+ public
+ @Produces
+ @Named
+ //@RequestScoped // if enabled, variable doesn't get updated after the action is executed w/o a redirect
+ List<Hotel> getHotels()
+ {
+ return hotels;
+ }
+
+ public boolean isNextPageAvailable()
+ {
+ return nextPageAvailable;
+ }
+
+ public boolean isPreviousPageAvailable()
+ {
+ return criteria.getPage() > 0;
+ }
+
+ @Remove
+ public void destroy()
+ {
+ }
+
+ private void queryHotels(SearchCriteria criteria)
+ {
+ List<Hotel> results = em.createQuery(
+ "select h from Hotel h where lower(h.name) like :pattern or lower(h.city) like :pattern or lower(h.zip) like :pattern or lower(h.address) like :pattern").
+ setParameter("pattern", criteria.getSearchPattern()).setMaxResults(criteria.getPageSize() + 1).setFirstResult(criteria.getPage() * criteria.getPageSize()).
+ getResultList();
+
+ nextPageAvailable = results.size() > criteria.getPageSize();
+ if (nextPageAvailable)
+ {
+ hotels = new ArrayList<Hotel>(results.subList(0, criteria.getPageSize()));
+ }
+ else
+ {
+ hotels = results;
+ }
+ log.info("Found {0} hotel(s) matching search term ''{1}'' (limit {2})", new Object[] { hotels.size(), criteria.getQuery(), criteria.getPageSize()});
+ }
+}
Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/SearchCriteria.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/SearchCriteria.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/SearchCriteria.java 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * $Id$
+ */
+package org.jboss.seam.examples.booking.inventory;
+
+import java.io.Serializable;
+
+import javax.enterprise.context.SessionScoped;
+import javax.inject.Named;
+
+ at Named
+ at SessionScoped
+public class SearchCriteria implements Serializable
+{
+ private static final char SQL_WILDCARD_CHAR = '%';
+ private static final String SQL_WILDCARD_STR = String.valueOf(SQL_WILDCARD_CHAR);
+ private static final String REPEAT_SQL_WIDCARD_REGEX = SQL_WILDCARD_STR + "+";
+ private static final char HUMAN_WILDCARD_CHAR = '*';
+
+ private String query = "";
+ private int pageSize = 5;
+ private int page = 0;
+
+ public String getSearchPattern()
+ {
+ if (query == null || query.length() == 0)
+ {
+ return SQL_WILDCARD_STR;
+ }
+
+ StringBuilder pattern = new StringBuilder();
+ pattern.append(query.toLowerCase().replace(HUMAN_WILDCARD_CHAR, SQL_WILDCARD_CHAR).replaceAll(REPEAT_SQL_WIDCARD_REGEX, SQL_WILDCARD_STR));
+ if (pattern.length() == 0 || pattern.charAt(0) != SQL_WILDCARD_CHAR)
+ {
+ pattern.insert(0, SQL_WILDCARD_CHAR);
+ }
+ if (pattern.length() > 1 && pattern.charAt(pattern.length() - 1) != SQL_WILDCARD_CHAR)
+ {
+ pattern.append(SQL_WILDCARD_CHAR);
+ }
+ return pattern.toString();
+ }
+
+ public int getPage()
+ {
+ return page;
+ }
+
+ public void setPage(int page)
+ {
+ this.page = page;
+ }
+
+ public int getPageSize()
+ {
+ return pageSize;
+ }
+
+ public void setPageSize(int pageSize)
+ {
+ this.pageSize = pageSize;
+ }
+
+ public String getQuery()
+ {
+ return query;
+ }
+
+ public void setQuery(String query)
+ {
+ this.query = (query != null ? query.trim() : null);
+ }
+
+ public void nextPage()
+ {
+ page++;
+ }
+
+ public void previousPage()
+ {
+ if (page > 0)
+ {
+ page--;
+ }
+ }
+
+ public void firstPage()
+ {
+ page = 0;
+ }
+}
Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/Booking.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/Booking.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/Booking.java 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,244 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * $Id$
+ */
+package org.jboss.seam.examples.booking.model;
+
+import static javax.persistence.TemporalType.DATE;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.text.DateFormat;
+import java.util.Date;
+
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Transient;
+
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Pattern;
+import javax.validation.constraints.Size;
+
+/**
+ * <p><strong>Booking</strong> is the model/entity class that represents a hotel
+ * booking.</p>
+ *
+ * @author Gavin King
+ * @author Dan Allen
+ */
+ at Entity
+public class Booking implements Serializable
+{
+ private Long id;
+ private User user;
+ private Hotel hotel;
+ private Date checkinDate;
+ private Date checkoutDate;
+ private String creditCardNumber;
+ private CreditCardType creditCardType;
+ private String creditCardName;
+ private int creditCardExpiryMonth;
+ private int creditCardExpiryYear;
+ private boolean smoking;
+ private int beds;
+
+ public Booking()
+ {
+ }
+
+ public Booking(Hotel hotel, User user)
+ {
+ this.hotel = hotel;
+ this.user = user;
+ this.creditCardName = user.getName();
+ }
+
+ @Id
+ @GeneratedValue
+ public Long getId()
+ {
+ return id;
+ }
+
+ public void setId(Long id)
+ {
+ this.id = id;
+ }
+
+ @NotNull
+ @Temporal(DATE)
+ public Date getCheckinDate()
+ {
+ return checkinDate;
+ }
+
+ public void setCheckinDate(Date datetime)
+ {
+ this.checkinDate = datetime;
+ }
+
+ @NotNull
+ @ManyToOne
+ public Hotel getHotel()
+ {
+ return hotel;
+ }
+
+ public void setHotel(Hotel hotel)
+ {
+ this.hotel = hotel;
+ }
+
+ @NotNull
+ @ManyToOne
+ public User getUser()
+ {
+ return user;
+ }
+
+ public void setUser(User user)
+ {
+ this.user = user;
+ }
+
+ @NotNull
+ @Temporal(TemporalType.DATE)
+ public Date getCheckoutDate()
+ {
+ return checkoutDate;
+ }
+
+ public void setCheckoutDate(Date checkoutDate)
+ {
+ this.checkoutDate = checkoutDate;
+ }
+
+ public boolean isSmoking()
+ {
+ return smoking;
+ }
+
+ public void setSmoking(boolean smoking)
+ {
+ this.smoking = smoking;
+ }
+
+ public int getBeds()
+ {
+ return beds;
+ }
+
+ public void setBeds(int beds)
+ {
+ this.beds = beds;
+ }
+
+ @NotNull(message = "Credit card number is required")
+ @Size(min = 16, max = 16, message = "Credit card number must 16 digits long")
+ @Pattern(regexp = "^\\d*$", message = "Credit card number must be numeric")
+ public String getCreditCardNumber()
+ {
+ return creditCardNumber;
+ }
+
+ public void setCreditCardNumber(String creditCardNumber)
+ {
+ this.creditCardNumber = creditCardNumber;
+ }
+
+ @NotNull(message = "Credit card type is required")
+ @Enumerated(EnumType.STRING)
+ public CreditCardType getCreditCardType()
+ {
+ return creditCardType;
+ }
+
+ public void setCreditCardType(CreditCardType creditCardType)
+ {
+ this.creditCardType = creditCardType;
+ }
+
+ @NotNull(message = "Credit card name is required")
+ @Size(min = 3, max = 70, message = "Credit card name is required")
+ public String getCreditCardName()
+ {
+ return creditCardName;
+ }
+
+ public void setCreditCardName(String creditCardName)
+ {
+ this.creditCardName = creditCardName;
+ }
+
+ public int getCreditCardExpiryMonth()
+ {
+ return creditCardExpiryMonth;
+ }
+
+ public void setCreditCardExpiryMonth(int creditCardExpiryMonth)
+ {
+ this.creditCardExpiryMonth = creditCardExpiryMonth;
+ }
+
+ public int getCreditCardExpiryYear()
+ {
+ return creditCardExpiryYear;
+ }
+
+ public void setCreditCardExpiryYear(int creditCardExpiryYear)
+ {
+ this.creditCardExpiryYear = creditCardExpiryYear;
+ }
+
+ @Transient
+ public String getDescription()
+ {
+ DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM);
+ return hotel == null ? null : hotel.getName() +
+ ", " + df.format(getCheckinDate()) +
+ " to " + df.format(getCheckoutDate());
+ }
+
+ @Transient
+ public BigDecimal getTotal()
+ {
+ return hotel.getPrice().multiply(new BigDecimal(getNights()));
+ }
+
+ @Transient
+ public int getNights()
+ {
+ return (int) (checkoutDate.getTime() - checkinDate.getTime()) / 1000 / 60 / 60 / 24;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Booking(" + user + ", " + hotel + ")";
+ }
+}
Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/CreditCardType.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/CreditCardType.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/CreditCardType.java 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,9 @@
+package org.jboss.seam.examples.booking.model;
+
+public enum CreditCardType
+{
+ VISA,
+ MasterCard,
+ AMEX,
+ Discover
+}
\ No newline at end of file
Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/Hotel.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/Hotel.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/Hotel.java 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,179 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * $Id$
+ */
+package org.jboss.seam.examples.booking.model;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+/**
+ * <p><strong>Hotel</strong> is the model/entity class that represents a hotel.</p>
+ *
+ * @author Gavin King
+ * @author Dan Allen
+ */
+ at Entity
+ at Table(name = "hotel")
+public class Hotel implements Serializable
+{
+ private Long id;
+ private String name;
+ private String address;
+ private String city;
+ private String state;
+ private String zip;
+ private String country;
+ private Integer stars;
+ private BigDecimal price;
+
+ @Id
+ @GeneratedValue
+ public Long getId()
+ {
+ return id;
+ }
+
+ public void setId(Long id)
+ {
+ this.id = id;
+ }
+
+ @Size(max = 50)
+ @NotNull
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ @Size(max = 100)
+ @NotNull
+ public String getAddress()
+ {
+ return address;
+ }
+
+ public void setAddress(String address)
+ {
+ this.address = address;
+ }
+
+ @Size(max = 40)
+ @NotNull
+ public String getCity()
+ {
+ return city;
+ }
+
+ public void setCity(String city)
+ {
+ this.city = city;
+ }
+
+ @Size(min = 4, max = 6)
+ @NotNull
+ public String getZip()
+ {
+ return zip;
+ }
+
+ public void setZip(String zip)
+ {
+ this.zip = zip;
+ }
+
+ @Size(min = 2, max = 10)
+ @NotNull
+ public String getState()
+ {
+ return state;
+ }
+
+ public void setState(String state)
+ {
+ this.state = state;
+ }
+
+ @Size(min = 2, max = 40)
+ @NotNull
+ public String getCountry()
+ {
+ return country;
+ }
+
+ public void setCountry(String country)
+ {
+ this.country = country;
+ }
+
+ @Min(1)
+ @Max(5)
+ public Integer getStars()
+ {
+ return stars;
+ }
+
+ public void setStars(Integer stars)
+ {
+ this.stars = stars;
+ }
+
+ @Column(precision = 6, scale = 2)
+ public BigDecimal getPrice()
+ {
+ return price;
+ }
+
+ public void setPrice(BigDecimal price)
+ {
+ this.price = price;
+ }
+
+ @Transient
+ public String getLocation()
+ {
+ return city + ", " + state + ", " + country;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Hotel(" + name + "," + address + "," + city + "," + zip + ")";
+ }
+}
Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/User.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/User.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/User.java 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,110 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * $Id$
+ */
+package org.jboss.seam.examples.booking.model;
+
+import java.io.Serializable;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Pattern;
+import javax.validation.constraints.Size;
+
+/**
+ * <p><strong>User</strong> is the model/entity class that represents a customer
+ * who may book a hotel.</p>
+ *
+ * @author Gavin King
+ * @author Dan Allen
+ */
+ at Entity
+ at Table(name = "customer")
+public class User implements Serializable
+{
+ private String username;
+ private String password;
+ private String name;
+
+ public User()
+ {
+ }
+
+ public User(String name, String username)
+ {
+ this.name = name;
+ this.username = username;
+ }
+
+ public User(String name, String username, String password)
+ {
+ this(name, username);
+ this.password = password;
+ }
+
+ @NotNull
+ @Size(max = 100)
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ @NotNull
+ @Size(min = 5, max = 15)
+ public String getPassword()
+ {
+ return password;
+ }
+
+ public void setPassword(String password)
+ {
+ this.password = password;
+ }
+
+ @Id
+ @NotNull
+ @Size(min = 3, max = 15)
+ @Pattern(regexp = "^\\w*$", message = "not a valid username")
+ public String getUsername()
+ {
+ return username;
+ }
+
+ public void setUsername(String username)
+ {
+ this.username = username;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "User(" + username + ")";
+ }
+}
Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/CalendarReferenceProducer.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/CalendarReferenceProducer.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/CalendarReferenceProducer.java 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,43 @@
+package org.jboss.seam.examples.booking.reference;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.List;
+import java.util.Locale;
+
+import javax.enterprise.context.ConversationScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.enterprise.inject.Produces;
+
+/**
+ * Produces calendar-oriented reference data to be used in user-interface forms.
+ * The user's locale is honored when producing name-based data.
+ *
+ * @author Dan Allen
+ */
+public class CalendarReferenceProducer {
+
+ @Inject private Locale locale;
+
+ @Produces
+ @Named
+ @ConversationScoped
+ public List<Month> getMonths()
+ {
+ List<Month> months = new ArrayList<Month>(12);
+ DateFormat longNameFormat = new SimpleDateFormat("MMMM", locale);
+ DateFormat shortNameFormat = new SimpleDateFormat("MMM", locale);
+ Calendar cal = Calendar.getInstance();
+ for (int m = 0; m < 12; m++)
+ {
+ cal.set(Calendar.MONTH, m);
+ months.add(new Month(m, longNameFormat.format(cal.getTime()), shortNameFormat.format(cal.getTime())));
+ }
+
+ return months;
+ }
+
+}
Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/CreditCardExpiryYears.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/CreditCardExpiryYears.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/CreditCardExpiryYears.java 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,28 @@
+package org.jboss.seam.examples.booking.reference;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+/**
+ * A binding type attached to a collection of years
+ * indicating the set is limited to the possible
+ * values for a credit card expiry date.
+ *
+ * @author Dan Allen
+ */
+ at Target({METHOD, PARAMETER, FIELD})
+ at Retention(RUNTIME)
+ at Documented
+ at Qualifier
+public @interface CreditCardExpiryYears
+{
+}
Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/CreditCardReferenceProducer.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/CreditCardReferenceProducer.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/CreditCardReferenceProducer.java 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,45 @@
+package org.jboss.seam.examples.booking.reference;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.List;
+
+import javax.enterprise.context.ConversationScoped;
+import javax.inject.Named;
+import javax.enterprise.inject.Produces;
+
+import org.jboss.seam.examples.booking.model.CreditCardType;
+
+/**
+ * A bean that produces credit card reference data for
+ * user-interface forms.
+ *
+ * @author Dan Allen
+ */
+public class CreditCardReferenceProducer
+{
+ @Produces
+ @Named
+ @ConversationScoped
+ public List<CreditCardType> getCreditCardTypes()
+ {
+ return new ArrayList<CreditCardType>(Arrays.asList(CreditCardType.values()));
+ }
+
+ @Produces
+ @Named
+ @ConversationScoped
+ @CreditCardExpiryYears
+ public List<Integer> getCreditCardExpiryYears()
+ {
+ List<Integer> years = new ArrayList<Integer>(8);
+ int currentYear = Calendar.getInstance().get(Calendar.YEAR);
+ for (int y = currentYear; y <= (currentYear + 8); y++)
+ {
+ years.add(y);
+ }
+
+ return years;
+ }
+}
Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/Month.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/Month.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/Month.java 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,49 @@
+package org.jboss.seam.examples.booking.reference;
+
+/**
+ * A simple Java bean representing a month. This
+ * bean assumes that the names it is provided
+ * have already been localized.
+ *
+ * @author Dan Allen
+ */
+public class Month {
+
+ private int index;
+ private String name;
+ private String shortName;
+
+ public Month() {}
+
+ public Month(int index, String name, String shortName)
+ {
+ this.index = index;
+ this.name = name;
+ this.shortName = shortName;
+ }
+
+ public int getIndex()
+ {
+ return index;
+ }
+
+ public int getNumber()
+ {
+ return index + 1;
+ }
+
+ public String getLongName()
+ {
+ return name;
+ }
+
+ public String getShortName()
+ {
+ return shortName;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+}
Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/AuthenticationEventListener.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/AuthenticationEventListener.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/AuthenticationEventListener.java 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,56 @@
+package org.jboss.seam.examples.booking.security;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.context.spi.Context;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.AnnotationLiteral;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+
+import org.jboss.seam.examples.booking.account.Registered;
+import org.jboss.seam.examples.booking.model.User;
+import org.jboss.seam.security.events.LoggedInEvent;
+import org.jboss.seam.security.events.LoggedOutEvent;
+import org.jboss.seam.web.HttpSessionManager;
+import org.slf4j.Logger;
+
+/**
+ * An observer that monitors authentication events and performs
+ * initialization and cleanup.
+ *
+ * @author Dan Allen
+ */
+ at RequestScoped
+public class AuthenticationEventListener
+{
+ @Inject private Logger log;
+
+ /**
+ * Clear the dummy register user when a login event occurs. Temporary workaround
+ * for not being able to clear this out some other way.
+ */
+ public void onLogin(@Observes LoggedInEvent loggedInEvent, BeanManager manager)
+ {
+ log.info(loggedInEvent.getPrincipal().getName() + " has logged in; clearing instance of @Registered User");
+ Bean<User> registeredUserBean = (Bean<User>) manager.getBeans(User.class, new AnnotationLiteral<Registered>() {}).iterator().next();
+ Context sessionContext = manager.getContext(SessionScoped.class);
+
+ // TODO - the BeanStore.remove() method is no longer available - find a workaround
+ //((AbstractThreadLocalMapContext) sessionContext).getBeanStore().remove(registeredUserBean);
+ }
+
+ /**
+ * Observe the logout event and prepare the session to be terminated. We
+ * cannot terminate the session immediately or else it will cause any
+ * additional session-scoped observers to fail. It's necessary to delegate
+ * this task to the Seam HttpSessionManager, which can terminate (i.e.,
+ * invalidate) the session when the current request ends.
+ */
+ public void onLogout(@Observes LoggedOutEvent loggedOutEvent, HttpSessionManager sessionManager)
+ {
+ log.info(loggedOutEvent.getPrincipal().getName() + " has logged out");
+ sessionManager.invalidateAtEndOfRequest();
+ }
+
+}
Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Authenticator.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Authenticator.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Authenticator.java 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,15 @@
+package org.jboss.seam.examples.booking.security;
+
+import javax.ejb.Local;
+
+/**
+ * <strong>Authenticator</strong> is responsible for authenticating the current
+ * user. The sole method of this interface, authenticate(), is invoked as a
+ * callback method to Seam's security infrastructure during authentication.
+ *
+ * @author Dan Allen
+ */
+ at Local
+public interface Authenticator extends org.jboss.seam.security.Authenticator
+{
+}
Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/AuthenticatorBean.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/AuthenticatorBean.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/AuthenticatorBean.java 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,43 @@
+package org.jboss.seam.examples.booking.security;
+
+import javax.ejb.Stateless;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.jboss.seam.examples.booking.model.User;
+import org.jboss.seam.security.Credentials;
+import org.slf4j.Logger;
+
+/**
+ * This implementation of <strong>Authenticator</strong> cross references the
+ * values of the user's credentials against the database.
+ *
+ * @author Dan Allen
+ */
+ at Stateless
+public class AuthenticatorBean implements Authenticator
+{
+ @Inject private Logger log;
+
+ @PersistenceContext private EntityManager em;
+
+ @Inject private Credentials credentials;
+
+ public boolean authenticate()
+ {
+ if (credentials.getUsername() != null && credentials.getUsername().length() > 0)
+ {
+ log.info("Authenticating {0}...", credentials.getUsername());
+ User user = em.find(User.class, credentials.getUsername());
+ if (user != null && user.getPassword().equals(credentials.getPassword()))
+ {
+ credentials.setPassword(null);
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+}
Added: examples/trunk/booking-simplified/src/main/resources/META-INF/beans.xml
===================================================================
Added: examples/trunk/booking-simplified/src/main/resources/META-INF/persistence.xml
===================================================================
--- examples/trunk/booking-simplified/src/main/resources/META-INF/persistence.xml (rev 0)
+++ examples/trunk/booking-simplified/src/main/resources/META-INF/persistence.xml 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
+ version="1.0">
+ <persistence-unit name="booking">
+ <provider>org.hibernate.ejb.HibernatePersistence</provider>
+ <jta-data-source>bookingDatasource</jta-data-source>
+ <properties>
+ <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
+ <property name="hibernate.show_sql" value="true"/>
+ <!-- These are the default for JBoss EJB 3, but not for Hibernate EntityManager -->
+ <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
+ <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
+ </properties>
+ </persistence-unit>
+</persistence>
Added: examples/trunk/booking-simplified/src/main/resources/import.sql
===================================================================
--- examples/trunk/booking-simplified/src/main/resources/import.sql (rev 0)
+++ examples/trunk/booking-simplified/src/main/resources/import.sql 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,28 @@
+insert into customer (username, password, name) values ('gavin', 'mexico', 'Gavin King')
+insert into customer (username, password, name) values ('pete', 'edinburgh', 'Pete Muir')
+insert into customer (username, password, name) values ('shane', 'brisbane', 'Shane Bryzak')
+insert into customer (username, password, name) values ('dan', 'laurel', 'Dan Allen')
+insert into hotel (id, price, stars, name, address, city, state, zip, country) values (1, 129, 3, 'Marriott Courtyard', 'Tower Place, Buckhead', 'Atlanta', 'GA', '30305', 'USA')
+insert into hotel (id, price, stars, name, address, city, state, zip, country) values (2, 84, 4, 'Doubletree Atlanta-Buckhead', '3342 Peachtree Road NE', 'Atlanta', 'GA', '30326', 'USA')
+insert into hotel (id, price, stars, name, address, city, state, zip, country) values (3, 289, 4, 'W New York - Union Square', '201 Park Avenue South', 'New York', 'NY', '10003', 'USA')
+insert into hotel (id, price, stars, name, address, city, state, zip, country) values (4, 219, 3, 'W New York', '541 Lexington Avenue', 'New York', 'NY', '10022', 'USA')
+insert into hotel (id, price, stars, name, address, city, state, zip, country) values (5, 250, 3, 'Hotel Rouge', '1315 16th Street NW', 'Washington', 'DC', '20036', 'USA')
+insert into hotel (id, price, stars, name, address, city, state, zip, country) values (6, 159, 4, '70 Park Avenue Hotel', '70 Park Avenue, 38th St', 'New York', 'NY', '10016', 'USA')
+insert into hotel (id, price, stars, name, address, city, state, zip, country) values (7, 198, 4, 'Parc 55', '55 Cyril Magnin Street', 'San Francisco', 'CA', '94102', 'USA')
+insert into hotel (id, price, stars, name, address, city, state, zip, country) values (8, 189, 4, 'Conrad Miami', '1395 Brickell Ave', 'Miami', 'FL', '33131', 'USA')
+insert into hotel (id, price, stars, name, address, city, state, zip, country) values (9, 111, 4, 'Grand Hyatt', '345 Stockton Street', 'San Francisco', 'CA', '94108', 'USA')
+insert into hotel (id, price, stars, name, address, city, state, zip, country) values (10, 54, 1, 'Super 8 Eau Claire Campus Area', '1151 W MacArthur Ave', 'Eau Claire', 'WI', '54701', 'USA')
+insert into hotel (id, price, stars, name, address, city, state, zip, country) values (11, 199, 4, 'San Francisco Marriott', '55 Fourth Street', 'San Francisco', 'CA', '94103', 'USA')
+insert into hotel (id, price, stars, name, address, city, state, zip, country) values (12, 543, 4, 'Hilton Diagonal Mar', 'Passeig del Taulat 262-264', 'Barcelona', 'Catalunya', '08019', 'ES')
+insert into hotel (id, price, stars, name, address, city, state, zip, country) values (13, 335, 5, 'Hilton Tel Aviv', 'Independence Park', 'Tel Aviv', '', '63405', 'IL')
+insert into hotel (id, price, stars, name, address, city, state, zip, country) values (14, 242, 5, 'InterContinental Hotel Tokyo Bay', '1-15-2 Kaigan', 'Tokyo', 'Minato', '105', 'JP')
+insert into hotel (id, price, stars, name, address, city, state, zip, country) values (15, 130, 4, 'Hotel Beaulac', ' Esplanade Léopold-Robert 2', 'Neuchatel', '', '2000', 'CH')
+insert into hotel (id, price, stars, name, address, city, state, zip, country) values (16, 266, 5, 'Conrad Treasury Place', '130 William Street', 'Brisbane', 'QL', '4001', 'AU')
+insert into hotel (id, price, stars, name, address, city, state, zip, country) values (17, 170, 4, 'Ritz-Carlton Montreal', '1228 Sherbrooke St West', 'Montreal', 'Quebec', 'H3G1H6', 'CA')
+insert into hotel (id, price, stars, name, address, city, state, zip, country) values (18, 179, 4, 'Ritz-Carlton Atlanta', '181 Peachtree St NE', 'Atlanta', 'GA', '30303', 'USA')
+insert into hotel (id, price, stars, name, address, city, state, zip, country) values (19, 145, 4, 'Swissotel Sydney', '68 Market Street', 'Sydney', 'NSW', '2000', 'AU')
+insert into hotel (id, price, stars, name, address, city, state, zip, country) values (20, 178, 4, 'Meliá White House', 'Albany Street Regents Park', 'London', '', 'NW13UP', 'GB')
+insert into hotel (id, price, stars, name, address, city, state, zip, country) values (21, 159, 3, 'Hotel Allegro', '171 W Randolph Street', 'Chicago', 'IL', '60601', 'USA')
+insert into hotel (id, price, stars, name, address, city, state, zip, country) values (22, 296, 5, 'Caesars Palace', '3570 Las Vegas Blvd S', 'Las Vegas', 'NV', '89109', 'USA')
+insert into hotel (id, price, stars, name, address, city, state, zip, country) values (23, 300, 4, 'Mandalay Bay Resort & Casino', '3950 Las Vegas Blvd S', 'Las Vegas', 'NV', '89119', 'USA')
+insert into hotel (id, price, stars, name, address, city, state, zip, country) values (24, 100, 2, 'Hotel Cammerpoorte', 'Nationalestraat 38-40', 'Antwerp', '', '2000', 'BE')
Added: examples/trunk/booking-simplified/src/main/resources/messages.properties
===================================================================
--- examples/trunk/booking-simplified/src/main/resources/messages.properties (rev 0)
+++ examples/trunk/booking-simplified/src/main/resources/messages.properties 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,11 @@
+booking.initiated=You've initiated a booking at {0}.
+booking.checkInNotFutureDate=Check in date must be a future date.
+booking.checkOutBeforeCheckIn=Check out date must be after check in date.
+booking.confirmed=You're booked!
+booking.canceled=The booking at the {0} on {1,date} has been canceled.
+booking.doesNotExist=Our records indicate that the booking you selected has already been canceled.
+account.passwordChanged=Password successfully updated.
+account.passwordsDoNotMatch=Passwords do not match. Please re-type the new password.
+account.usernameTaken=The username '{0}' is already taken. Please choose another username.
+registration.registered=You have been successfully registered as the user {0}!
+registration.invalid=Invalid registration. Please correct the errors and try again.
Added: examples/trunk/booking-simplified/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/WEB-INF/faces-config.xml (rev 0)
+++ examples/trunk/booking-simplified/src/main/webapp/WEB-INF/faces-config.xml 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
+ version="2.0">
+
+ <navigation-rule>
+ <from-view-id>*</from-view-id>
+
+ <navigation-case>
+ <from-action>#{identity.logout}</from-action>
+ <if>#{true}</if>
+ <to-view-id>/home.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-action>#{bookingAgent.cancel}</from-action>
+ <if>#{true}</if>
+ <to-view-id>/main.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ </navigation-rule>
+
+ <navigation-rule>
+ <from-view-id>/home.xhtml</from-view-id>
+
+ <navigation-case>
+ <from-action>#{identity.login}</from-action>
+ <if>#{identity.loggedIn}</if>
+ <to-view-id>/main.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ </navigation-rule>
+
+ <navigation-rule>
+ <from-view-id>/main.xhtml</from-view-id>
+
+ <!-- navigation rules are required to reset request-scoped producer variables -->
+ <!--
+ <navigation-case>
+ <from-action>#{hotelSearch.find}</from-action>
+ <if>#{true}</if>
+ <to-view-id>/main.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+ <navigation-case>
+ <from-action>#{hotelSearch.nextPage}</from-action>
+ <if>#{true}</if>
+ <to-view-id>/main.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+ -->
+
+ <navigation-case>
+ <from-action>#{bookingAgent.selectHotel(_hotel)}</from-action>
+ <if>#{bookingAgent.hotelSelection != null}</if>
+ <to-view-id>/hotel.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ </navigation-rule>
+
+ <navigation-rule>
+ <from-view-id>/hotel.xhtml</from-view-id>
+
+ <navigation-case>
+ <from-action>#{bookingAgent.bookHotel}</from-action>
+ <if>#{bookingAgent.booking != null}</if>
+ <to-view-id>/book.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ </navigation-rule>
+
+ <navigation-rule>
+ <from-view-id>/book.xhtml</from-view-id>
+
+ <navigation-case>
+ <from-action>#{bookingAgent.validateBooking}</from-action>
+ <if>#{bookingAgent.bookingValid}</if>
+ <to-view-id>/confirm.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ </navigation-rule>
+
+ <navigation-rule>
+ <from-view-id>/confirm.xhtml</from-view-id>
+
+ <navigation-case>
+ <from-action>#{bookingAgent.confirm}</from-action>
+ <if>#{true}</if>
+ <to-view-id>/main.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ </navigation-rule>
+
+ <navigation-rule>
+ <from-view-id>/register.xhtml</from-view-id>
+
+ <navigation-case>
+ <from-action>#{registrar.register}</from-action>
+ <if>#{registrar.registered}</if>
+ <to-view-id>/account.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ </navigation-rule>
+
+ <navigation-rule>
+ <from-view-id>/password.xhtml</from-view-id>
+
+ <navigation-case>
+ <from-action>#{passwordManager.changePassword}</from-action>
+ <if>#{passwordManager.changed}</if>
+ <to-view-id>/account.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ </navigation-rule>
+
+</faces-config>
Added: examples/trunk/booking-simplified/src/main/webapp/WEB-INF/fragments/account.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/WEB-INF/fragments/account.xhtml (rev 0)
+++ examples/trunk/booking-simplified/src/main/webapp/WEB-INF/fragments/account.xhtml 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,12 @@
+<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:p="http://http://java.sun.com/jsf/composite/components/property">
+
+ <p:display label="Username" value="#{user.username}"/>
+ <p:display label="Real name" value="#{user.name}"/>
+
+</ui:composition>
Added: examples/trunk/booking-simplified/src/main/webapp/WEB-INF/fragments/hotel.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/WEB-INF/fragments/hotel.xhtml (rev 0)
+++ examples/trunk/booking-simplified/src/main/webapp/WEB-INF/fragments/hotel.xhtml 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,22 @@
+<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:p="http://http://java.sun.com/jsf/composite/components/property">
+
+ <p:display label="Name" value="#{hotel.name}"/>
+ <p:display label="Address" value="#{hotel.address}"/>
+ <p:display label="City" value="#{hotel.city}"/>
+ <p:display label="State" value="#{hotel.state}"/>
+ <p:display label="Zip" value="#{hotel.zip}"/>
+ <p:display label="Country" value="#{hotel.country}"/>
+ <p:display label="Class" override="true">
+ <h:graphicImage value="/img/#{hotel.stars}-star.gif" style="padding-top: 4px;"/>
+ </p:display>
+ <p:display label="Nightly rate" value="#{hotel.price}">
+ <f:convertNumber for="output" type="currency" currencySymbol="$"/>
+ </p:display>
+
+</ui:composition>
Added: examples/trunk/booking-simplified/src/main/webapp/WEB-INF/layout/template.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/WEB-INF/layout/template.xhtml (rev 0)
+++ examples/trunk/booking-simplified/src/main/webapp/WEB-INF/layout/template.xhtml 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,50 @@
+<!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:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"><f:view>
+ <ui:insert name="metadata"/>
+ <h:head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <title>JBoss Suites: Seam Framework</title>
+ <link rel="shortcut icon" href="#{request.contextPath}/favicon.ico"/>
+ <link href="#{request.contextPath}/css/screen.css" rel="stylesheet" type="text/css"/>
+ <ui:insert name="head"/>
+ </h:head>
+ <h:body styleClass="#{empty pageClass ? 'page' : 'home'}">
+ <div id="document">
+ <div id="header">
+ <div id="title"><h:graphicImage value="/img/hdr.title.gif" alt="JBoss Suites: seam framework demo"/></div>
+ <h:form id="menuForm">
+ <div id="status">
+ <h:outputText value="(#{user.name})" rendered="#{identity.loggedIn}" styleClass="user"/>
+ #{' '}
+ <h:link id="about" outcome="/home.xhtml" value="About"/>
+ #{' | '}
+ <h:link id="search" outcome="/main.xhtml" value="Search"/>
+ <h:panelGroup rendered="#{identity.loggedIn}">
+ #{' | '}
+ <h:link id="settings" outcome="/password.xhtml" value="Settings"/>
+ #{' | '}
+ <h:commandLink id="logout" action="#{identity.logout}" value="Logout"/>
+ </h:panelGroup>
+ </div>
+ </h:form>
+ </div>
+ <div id="container">
+ <div id="sidebar">
+ <ui:insert name="sidebar"/>
+ </div>
+ <div id="content">
+ <ui:insert name="content"/>
+ </div>
+ </div>
+ <div id="footer">
+ Created with Seam 3.0, Web Beans, EJB 3.0 and JSF 2.0
+ <br/>
+ #{javax.context.conversation}
+ </div>
+ </div>
+ </h:body>
+</f:view></html>
Added: examples/trunk/booking-simplified/src/main/webapp/WEB-INF/web.xml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/WEB-INF/web.xml (rev 0)
+++ examples/trunk/booking-simplified/src/main/webapp/WEB-INF/web.xml 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ version="3.0">
+
+ <display-name>Seam Booking Example (Java EE Environment)</display-name>
+
+ <context-param>
+ <param-name>facelets.DEVELOPMENT</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
+ <!--
+ <context-param>
+ <param-name>javax.faces.PROJECT_STAGE</param-name>
+ <param-value>Development</param-value>
+ </context-param>
+ -->
+
+ <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>*.seam</url-pattern>
+ </servlet-mapping>
+
+ <session-config>
+ <session-timeout>10</session-timeout>
+ </session-config>
+
+ <security-constraint>
+ <display-name>Restrict access to XHTML documents</display-name>
+ <web-resource-collection>
+ <web-resource-name>XHTML</web-resource-name>
+ <url-pattern>*.xhtml</url-pattern>
+ </web-resource-collection>
+ <auth-constraint/>
+ </security-constraint>
+
+ <error-page>
+ <exception-type>org.jboss.seam.security.NotLoggedInException</exception-type>
+ <location>/home.seam</location>
+ </error-page>
+
+ <error-page>
+ <exception-type>org.jboss.seam.security.AuthorizationException</exception-type>
+ <location>/denied.seam</location>
+ </error-page>
+
+ <error-page>
+ <error-code>500</error-code>
+ <location>/error.seam</location>
+ </error-page>
+
+</web-app>
Added: examples/trunk/booking-simplified/src/main/webapp/account.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/account.xhtml (rev 0)
+++ examples/trunk/booking-simplified/src/main/webapp/account.xhtml 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,49 @@
+<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ template="/WEB-INF/layout/template.xhtml">
+
+ <ui:define name="content">
+
+ <div class="section">
+ <h1>Your Account</h1>
+ </div>
+
+ <div class="section">
+
+ <div class="errors">
+ <h:messages id="messages" globalOnly="true"/>
+ </div>
+
+ <ui:include src="/WEB-INF/fragments/account.xhtml"/>
+
+ <div class="buttonBox">
+ <h:button id="changePassword" value="Change password" outcome="/password.xhtml"/>
+ </div>
+ </div>
+
+ </ui:define>
+
+ <ui:define name="sidebar">
+
+ <h1>Producing variables</h1>
+ <p>
+ You shouldn't need to write accessor methods (getters and setters) on a backing bean just to get at your data.
+ Rather, you should be able to expose data as a top-level variable. The logic necessary to load the data should
+ be produced on demand. That's the role of a @Producer method on a bean, which you can leverage in a Seam
+ application. Here, the user's account is loaded into the session as the variable 'user' when this page is
+ accessed. Once the variable has been produced, it doesn't need to happen again, another cycle-saving benefit of
+ this pattern.
+ </p>
+ <p>
+ <a href="#" onclick="window.open('exp/FIXME.html','exp','width=752,height=500,scrollbars=yes');">
+ What happens when this page loads?
+ </a>
+ </p>
+
+ </ui:define>
+
+</ui:composition>
Added: examples/trunk/booking-simplified/src/main/webapp/book.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/book.xhtml (rev 0)
+++ examples/trunk/booking-simplified/src/main/webapp/book.xhtml 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,111 @@
+<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:s="http://jboss.org/seam/faces"
+ xmlns:p="http://http://java.sun.com/jsf/composite/components/property"
+ template="/WEB-INF/layout/template.xhtml">
+ <ui:define name="metadata">
+ <f:metadata>
+ <s:restrictView require="#{identity.loggedIn}"/>
+ </f:metadata>
+ </ui:define>
+
+ <ui:define name="content">
+ <div class="section">
+ <h1>Book Hotel</h1>
+ </div>
+
+ <div class="section">
+ <div class="errors">
+ <h:messages id="messages" globalOnly="true"/>
+ </div>
+
+ <ui:include src="/WEB-INF/fragments/hotel.xhtml"/>
+
+ <div style="clear: both;"/>
+
+ <h:form id="bookingForm">
+ <fieldset>
+
+ <p:edit id="checkinDate" label="Check-in date">
+ <h:inputText id="input" value="#{booking.checkinDate}" binding="#{bookingFormControls.checkinDate}">
+ <f:convertDateTime type="date" pattern="MM/dd/yyyy"/>
+ </h:inputText>
+ </p:edit>
+
+ <p:edit id="checkoutDate" label="Check-out date">
+ <h:inputText id="input" value="#{booking.checkoutDate}" binding="#{bookingFormControls.checkoutDate}">
+ <f:convertDateTime type="date" pattern="MM/dd/yyyy"/>
+ </h:inputText>
+ </p:edit>
+
+ <p:edit id="beds" label="Room preference">
+ <h:selectOneMenu id="input" value="#{booking.beds}">
+ <f:selectItem itemLabel="One king-size bed" itemValue="1"/>
+ <f:selectItem itemLabel="Two double beds" itemValue="2"/>
+ <f:selectItem itemLabel="Three beds" itemValue="3"/>
+ </h:selectOneMenu>
+ </p:edit>
+
+ <p:edit id="smoking" label="Smoking preference">
+ <h:selectOneRadio id="input" value="#{booking.smoking}" layout="pageDirection" styleClass="radio">
+ <f:selectItem itemLabel="Smoking" itemValue="true"/>
+ <f:selectItem itemLabel="Non Smoking" itemValue="false"/>
+ </h:selectOneRadio>
+ </p:edit>
+
+ <p:edit id="creditCardName" label="Credit card name">
+ <h:inputText id="input" value="#{booking.creditCardName}"/>
+ </p:edit>
+
+ <p:edit id="creditCardNumber" label="Credit card #">
+ <h:inputText id="input" value="#{booking.creditCardNumber}"/>
+ #{' '}
+ <h:selectOneMenu id="input2" value="#{booking.creditCardType}">
+ <f:selectItem itemValue="#{null}" itemLabel="Select..." noSelectionOption="true"/>
+ <f:selectItems value="#{creditCardTypes}" var="_type" itemValue="#{_type}"/>
+ </h:selectOneMenu>
+ </p:edit>
+
+ <p:edit id="creditCardExpiry" label="Credit card expiry">
+ <h:selectOneMenu id="input" value="#{booking.creditCardExpiryMonth}">
+ <f:selectItems value="#{months}" var="_month" itemValue="#{_month.number}" itemLabel="#{_month.shortName}"/>
+ </h:selectOneMenu>
+ <h:selectOneMenu id="input2" value="#{booking.creditCardExpiryYear}">
+ <f:selectItems value="#{creditCardExpiryYears}" var="_year" itemValue="#{_year}"/>
+ </h:selectOneMenu>
+ </p:edit>
+
+ <div class="buttonBox">
+ <h:commandButton id="proceed" value="Proceed" action="#{bookingAgent.validateBooking}"/>
+ #{' '}
+ <h:commandButton id="cancel" value="Cancel" action="#{bookingAgent.cancel}" immediate="true"/>
+ </div>
+
+ </fieldset>
+ </h:form>
+ </div>
+
+ </ui:define>
+
+ <ui:define name="sidebar">
+
+ <h1>Workspace management</h1>
+ <p>
+ As you can see, Seam makes it easy to work in multiple windows or multiple browser tabs. But you can even
+ switch between multiple tasks inside a single browser tab! The "Workspaces" section showcases this advanced
+ feature.
+ </p>
+ <p>
+ <a href="#" onclick="window.open('exp/workspaceExp.html','exp','width=752,height=500,scrollbars=yes');">
+ How does the workspace list work?
+ </a>
+
+ </p>
+
+ </ui:define>
+
+</ui:composition>
Added: examples/trunk/booking-simplified/src/main/webapp/confirm.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/confirm.xhtml (rev 0)
+++ examples/trunk/booking-simplified/src/main/webapp/confirm.xhtml 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,69 @@
+<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:p="http://http://java.sun.com/jsf/composite/components/property"
+ template="/WEB-INF/layout/template.xhtml">
+
+ <ui:define name="content">
+
+ <div class="section">
+ <h1>Confirm Hotel Booking</h1>
+ </div>
+
+ <div class="section">
+
+ <ui:include src="/WEB-INF/fragments/hotel.xhtml"/>
+
+ <p:display label="Total payment" value="#{booking.total}">
+ <f:convertNumber for="output" type="currency" currencySymbol="$"/>
+ </p:display>
+
+ <p:display label="Check-in date" value="#{booking.checkinDate}">
+ <f:convertDateTime for="output" type="date" pattern="MM/dd/yyyy"/>
+ </p:display>
+
+ <p:display label="Check-out date" value="#{booking.checkoutDate}">
+ <f:convertDateTime for="output" type="date" pattern="MM/dd/yyyy"/>
+ </p:display>
+
+ <p:display label="Credit card #" value="#{booking.creditCardNumber}"/>
+
+ <p:display label="Credit card type" value="#{booking.creditCardType}"/>
+
+ <div class="buttonBox">
+ <h:form id="confirmForm">
+ <h:commandButton id="confirm" value="Confirm" action="#{bookingAgent.confirm}"/>
+ #{' '}
+ <h:button id="revise" value="Revise" outcome="/book.xhtml">
+ <f:param name="cid" value="#{javax.context.conversation.id}"/>
+ </h:button>
+ #{' '}
+ <h:commandButton id="cancel" value="Cancel" action="#{bookingAgent.cancel}" immediate="true"/>
+ </h:form>
+ </div>
+
+ </div>
+
+ </ui:define>
+
+ <ui:define name="sidebar">
+ <h1>Back button navigation</h1>
+ <p>
+ When you click "Confirm", the new booking is written to the database,
+ the conversation ends, and state associated with the conversation is
+ automatically destroyed by Seam. After you confirm your booking, try
+ hitting the back button on your web browser and clicking "Confirm"
+ again. Seam makes it easy implement applications that behave elegantly
+ in response to the back, forward and refresh buttons.
+ </p>
+ <p>
+ <a href="#" onclick="window.open('exp/confirmExp.html','exp','width=752,height=500,scrollbars=yes');">
+ What happens when the conversation ends?
+ </a>
+ </p>
+ </ui:define>
+
+</ui:composition>
Added: examples/trunk/booking-simplified/src/main/webapp/css/screen.css
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/css/screen.css (rev 0)
+++ examples/trunk/booking-simplified/src/main/webapp/css/screen.css 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,291 @@
+/* Setup defaults since variable in browsers
+----------------------------------------------- */
+body, div, span, dd, dt, dl, img, ul, ol, li, p, h1, h2, h3, h4, h5, form, hr, fieldset {
+ margin: 0;
+ padding: 0;
+}
+/* Element Defaults
+----------------------------------------------- */
+html {
+ height: 100%;
+ background-color: #DBD4C6;
+ overflow-y: scroll;
+}
+body {
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-size: small;
+ line-height: 1.25em;
+ color: #362F2D;
+ position: relative;
+ width: 760px;
+ height: 100%;
+ margin-left: auto;
+ margin-right: auto;
+}
+a img {
+ border: none;
+}
+.label {
+ font-weight: bold;
+ color: #5E5147;
+}
+input, select {
+ border: 1px solid #C3BBB6;
+ margin: 5px 0;
+ background: #FFFFFF url(../img/input.bg.gif) 0 0 repeat-x;
+}
+input {
+ padding: 4px;
+}
+select {
+ padding: 1px;
+}
+ol, ul {
+ margin: 10px 0px 10px 6px;
+}
+li {
+ margin: 10px 12px;
+}
+fieldset {
+ border: 0;
+}
+/* Layout
+----------------------------------------------- */
+#document {
+ padding: 0 1px;
+ background: #FFFFFF url(../img/bg.gif) 0 0 repeat-y;
+ float: left;
+ border-bottom: 1px solid #C3BBB6;
+}
+#header {
+ float: left;
+ width: 758px;
+ height: 46px;
+ background: url(../img/hdr.bg.gif) 0 0 repeat-x;
+}
+#container {
+ float: left;
+ width: 758px;
+ background: url(../img/hdr.bar.jpg) 0 0 repeat-x;
+}
+#sidebar {
+ float: left;
+ width: 190px;
+ margin-top: 96px;
+ padding: 20px 10px 0 10px;
+ background: url(../img/sdb.bg.gif) 0 0 no-repeat;
+}
+#content {
+ float: left;
+ width: 548px;
+ margin-top: 75px;
+ padding-top: 5px;
+ background: #FFFFFF url(../img/cnt.bg.gif) 0 0 repeat-x;
+}
+#footer {
+ clear: both;
+ margin-top: 40px;
+ float: left;
+ padding: 20px;
+ border-top: 1px solid #C3BBB6;
+ background-color: #FFFFFF;
+ width: 718px;
+ text-align: right;
+}
+/* General
+----------------------------------------------- */
+input[type=submit], input[type=button] {
+ font-weight: bold;
+ color: #FFFFFF;
+ border: 1px solid #5D1414;
+ height: 26px;
+ background: #FFFFFF url(../img/btn.bg.gif) 0 0 repeat-x;
+ border-style: none;
+ cursor: pointer;
+}
+.center {
+ text-align: center;
+}
+.entry {
+ clear: both;
+ padding-top: 10px;
+}
+.entry .label {
+ float: left;
+ padding-right: 5px;
+ font-weight: bold;
+ width: 160px;
+ text-align: right;
+}
+.entry input {
+ margin: 0;
+}
+.entry .input, .entry .output, .entry .error {
+ float: right;
+ width: 350px;
+ text-align: left;
+}
+/* Sidebar
+----------------------------------------------- */
+.notes {
+ text-align: center;
+ font-size: small;
+}
+.subnotes {
+ margin-top: 1em;
+ font-size: small;
+}
+.errors {
+ font-size: small;
+ font-weight: bold;
+ /*text-align: center;*/
+ color: #600000;
+}
+.errors div {
+ text-align: left;
+}
+.errors span {
+ text-align: left;
+}
+.errors input, .errors select, .errors textarea {
+ border: 1px solid #600000;
+}
+.errors ul {
+ list-style: none;
+}
+#messages {
+ margin-left: 1px;
+ margin-bottom: 20px;
+}
+#messages li {
+ margin-left: 0;
+}
+.buttonBox {
+ text-align: center;
+ padding: 5px 0;
+ clear: both;
+}
+#sidebar p {
+ font-size: small;
+ color: #8B7869;
+ line-height: 150%;
+ padding-bottom: 10px;
+}
+#sidebar li {
+ font-size: small;
+ color: #8B7869;
+}
+#sidebar h1 {
+ line-height: normal;
+ font-weight: bold;
+ font-size: small;
+}
+/*
+#sidebar p:hover {
+ color: #362F2D;
+}
+*/
+/* Content
+----------------------------------------------- */
+#content .section {
+ float: left;
+ width: 518px;
+ padding: 15px 15px 0 15px;
+}
+#content .section h1 {
+ font-family: "Trebuchet MS", Arial, sans-serif;
+ line-height: normal;
+ font-weight: normal;
+ font-size: large;
+}
+#content .section p {
+ line-height: 150%;
+ padding: 10px 0;
+ font-size: small;
+}
+#content table {
+ width: 100%;
+ border: 1px solid #D2C9C4;
+ border-collapse: collapse;
+}
+#content table caption {
+ padding-bottom: 6px;
+ text-align: left;
+ font-weight: bold;
+}
+#content table thead th {
+ border-left: 1px solid #D2C9C4;
+ background: #FFFFFF url(../img/th.bg.gif) 0 100% repeat-x;
+ border-bottom: 1px solid #D2C9C4;
+ padding: 6px;
+ text-align: left;
+ font-size: small;
+}
+#content table tbody td {
+ border-left: 1px solid #E4DBD5;
+ padding: 4px;
+ border-bottom: 1px solid #D2C9C4;
+ font-size: small;
+}
+td.action {
+ text-align: center;
+}
+#content dt {
+ font-weight: bold;
+ float: left;
+ width: 33%;
+}
+#content dd {
+ padding-left: 10px;
+ float: left;
+ width: 66%;
+}
+#content table.radio {
+ border: 0px;
+}
+#content table.radio tbody tr td {
+ border: 0px;
+ border-left: 0px;
+ border-bottom: 0px;
+}
+/* Header
+----------------------------------------------- */
+#title {
+ float: left;
+ padding: 1px 0 6px 15px;
+}
+#status {
+ color: #C7B299;
+ float: right;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-weight: bold;
+ font-size: x-small;
+ text-align: right;
+ padding-top: 14px;
+ padding-right: 15px;
+}
+#status a {
+ color: #C7B299;
+ text-decoration: none;
+}
+#status span.user {
+ padding-right: 5px;
+ color: #FFFDFB;
+ font-weight: normal;
+}
+/* Homepage Modifications
+----------------------------------------------- */
+body.home #container {
+ background: url(../img/hdr.ad.jpg) 0 0 repeat-x;
+}
+body.home #sidebar {
+ margin-top: 207px;
+}
+body.home #content {
+ margin-top: 183px;
+}
+/* Extras
+----------------------------------------------- */
+#javax_faces_developmentstage_messages {
+ display: none;
+}
Added: examples/trunk/booking-simplified/src/main/webapp/denied.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/denied.xhtml (rev 0)
+++ examples/trunk/booking-simplified/src/main/webapp/denied.xhtml 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,23 @@
+<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:p="http://http://java.sun.com/jsf/composite/components/property"
+ template="/WEB-INF/layout/template.xhtml">
+
+ <ui:define name="content">
+
+ <div class="section">
+ <h1>Access Denied</h1>
+ </div>
+
+ <div class="section">
+ <p>You are not authorized to perform the requested action.</p>
+ <p>#{facesContext.externalContext.requestMap['javax.servlet.error.message']}</p>
+ </div>
+
+ </ui:define>
+
+</ui:composition>
Added: examples/trunk/booking-simplified/src/main/webapp/error.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/error.xhtml (rev 0)
+++ examples/trunk/booking-simplified/src/main/webapp/error.xhtml 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,23 @@
+<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:p="http://http://java.sun.com/jsf/composite/components/property"
+ template="/WEB-INF/layout/template.xhtml">
+
+ <ui:define name="content">
+
+ <div class="section">
+ <h1>Error Encountered</h1>
+ </div>
+
+ <div class="section">
+ <p>An unexpected error has occurred.</p>
+ <p>#{facesContext.externalContext.requestMap['javax.servlet.error.message']}</p>
+ </div>
+
+ </ui:define>
+
+</ui:composition>
Added: examples/trunk/booking-simplified/src/main/webapp/favicon.ico
===================================================================
(Binary files differ)
Property changes on: examples/trunk/booking-simplified/src/main/webapp/favicon.ico
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: examples/trunk/booking-simplified/src/main/webapp/home.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/home.xhtml (rev 0)
+++ examples/trunk/booking-simplified/src/main/webapp/home.xhtml 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,69 @@
+<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ template="/WEB-INF/layout/template.xhtml">
+
+ <ui:param name="pageClass" value="home"/>
+
+ <ui:define name="content">
+ <div class="section">
+
+ <h1>About this example application</h1>
+
+ <p>
+ This sample application demonstrates how easy it is to develop stateful web applications using JBoss Seam.
+ Just register, login, and book a room to see Seam in action. Throughout the application you'll see popup
+ links like the ones at the bottom of this page. Click them to see how the application works under the hood.
+ </p>
+
+ <p>
+ Note: Please do NOT enter personal information or your credit card number in this sample application.
+ </p>
+
+ <p>
+ <a href="#" onclick="window.open('exp/introExp.html','exp','width=752,height=500,scrollbars=yes');">
+ What is Seam?
+ </a>
+ </p>
+
+ <p>
+ <a href="#" onclick="window.open('exp/loginExp.html','exp','width=752,height=500,scrollbars=yes');">
+ What happens when I login?
+ </a>
+ </p>
+
+ </div>
+ </ui:define>
+
+ <ui:define name="sidebar">
+ <h:form id="login" rendered="#{not identity.loggedIn}">
+ <fieldset>
+ <div>
+ <h:outputLabel for="username" value="Login name"/>
+ <h:inputText id="username" value="#{credentials.username}" style="width: 175px;"/>
+ <div class="errors"><h:message for="username"/></div>
+ </div>
+ <div>
+ <h:outputLabel for="password" value="Password"/>
+ <h:inputSecret id="password" value="#{credentials.password}" style="width: 175px;"/>
+ </div>
+ <div class="errors"><h:messages id="messages" globalOnly="true"/></div>
+ <div class="buttonBox"><h:commandButton id="login" action="#{identity.login}" value="Account Login"/></div>
+ <div class="notes"><h:link id="register" outcome="/register.xhtml" value="Register New User"/></div>
+ <div class="subnotes">
+ Or use a demo account:
+ <ul>
+ <li>gavin/mexico</li>
+ <li>pete/edinburgh</li>
+ <li>shane/brisbane</li>
+ <li>dan/laurel</li>
+ </ul>
+ </div>
+ </fieldset>
+ </h:form>
+ </ui:define>
+
+</ui:composition>
Added: examples/trunk/booking-simplified/src/main/webapp/hotel.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/hotel.xhtml (rev 0)
+++ examples/trunk/booking-simplified/src/main/webapp/hotel.xhtml 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,54 @@
+<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ template="/WEB-INF/layout/template.xhtml">
+
+ <ui:define name="content">
+
+ <div class="section">
+ <h1>View Hotel</h1>
+ </div>
+
+ <div class="section">
+ <ui:include src="/WEB-INF/fragments/hotel.xhtml"/>
+
+ <div class="buttonBox">
+ <h:form id="actions">
+ <h:commandButton id="bookHotel" action="#{bookingAgent.bookHotel}" value="Book Hotel"/>
+ #{' '}
+ <h:commandButton id="cancel" action="#{bookingAgent.cancel}" value="Return to Search" immediate="true"/>
+ </h:form>
+ </div>
+
+ </div>
+
+ </ui:define>
+
+ <ui:define name="sidebar">
+
+ <h1>Don't kill your database</h1>
+ <p>
+ Keeping conversational state in memory in the middle tier is a great
+ way to improve your application's scalability. It saves hitting the
+ database every time we refresh a page, to re-read the data we were
+ just looking at five seconds ago. By using Seam's conversation
+ context, we get a natural cache of data associated with the what the
+ user is currently doing. By nature, this cache has a more efficient
+ eviction policy than the MRU-type algorithms used by a typical
+ second-level data cache in an O/R mapping engine like Hibernate (at
+ least for some kinds of data). Of course, you should use a clever
+ combination of second-level caching and conversational data caching to
+ achieve the best performance for your application.
+ </p>
+ <p>
+ <a href="#" onclick="window.open('exp/bookingExp.html','exp','width=752,height=500,scrollbars=yes');">
+ How does the hotel booking wizard work?
+ </a>
+ </p>
+
+ </ui:define>
+
+</ui:composition>
Added: examples/trunk/booking-simplified/src/main/webapp/img/1-star.gif
===================================================================
(Binary files differ)
Property changes on: examples/trunk/booking-simplified/src/main/webapp/img/1-star.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: examples/trunk/booking-simplified/src/main/webapp/img/2-star.gif
===================================================================
(Binary files differ)
Property changes on: examples/trunk/booking-simplified/src/main/webapp/img/2-star.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: examples/trunk/booking-simplified/src/main/webapp/img/3-star.gif
===================================================================
(Binary files differ)
Property changes on: examples/trunk/booking-simplified/src/main/webapp/img/3-star.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: examples/trunk/booking-simplified/src/main/webapp/img/4-star.gif
===================================================================
(Binary files differ)
Property changes on: examples/trunk/booking-simplified/src/main/webapp/img/4-star.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: examples/trunk/booking-simplified/src/main/webapp/img/5-star.gif
===================================================================
(Binary files differ)
Property changes on: examples/trunk/booking-simplified/src/main/webapp/img/5-star.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: examples/trunk/booking-simplified/src/main/webapp/img/bg.gif
===================================================================
(Binary files differ)
Property changes on: examples/trunk/booking-simplified/src/main/webapp/img/bg.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: examples/trunk/booking-simplified/src/main/webapp/img/btn.bg.gif
===================================================================
(Binary files differ)
Property changes on: examples/trunk/booking-simplified/src/main/webapp/img/btn.bg.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: examples/trunk/booking-simplified/src/main/webapp/img/cal-next.png
===================================================================
(Binary files differ)
Property changes on: examples/trunk/booking-simplified/src/main/webapp/img/cal-next.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: examples/trunk/booking-simplified/src/main/webapp/img/cal-prev.png
===================================================================
(Binary files differ)
Property changes on: examples/trunk/booking-simplified/src/main/webapp/img/cal-prev.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: examples/trunk/booking-simplified/src/main/webapp/img/cnt.bg.gif
===================================================================
(Binary files differ)
Property changes on: examples/trunk/booking-simplified/src/main/webapp/img/cnt.bg.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: examples/trunk/booking-simplified/src/main/webapp/img/dtpick.gif
===================================================================
(Binary files differ)
Property changes on: examples/trunk/booking-simplified/src/main/webapp/img/dtpick.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: examples/trunk/booking-simplified/src/main/webapp/img/hdr.ad.jpg
===================================================================
(Binary files differ)
Property changes on: examples/trunk/booking-simplified/src/main/webapp/img/hdr.ad.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: examples/trunk/booking-simplified/src/main/webapp/img/hdr.bar.jpg
===================================================================
(Binary files differ)
Property changes on: examples/trunk/booking-simplified/src/main/webapp/img/hdr.bar.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: examples/trunk/booking-simplified/src/main/webapp/img/hdr.bg.gif
===================================================================
(Binary files differ)
Property changes on: examples/trunk/booking-simplified/src/main/webapp/img/hdr.bg.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: examples/trunk/booking-simplified/src/main/webapp/img/hdr.title.gif
===================================================================
(Binary files differ)
Property changes on: examples/trunk/booking-simplified/src/main/webapp/img/hdr.title.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: examples/trunk/booking-simplified/src/main/webapp/img/header_line.gif
===================================================================
(Binary files differ)
Property changes on: examples/trunk/booking-simplified/src/main/webapp/img/header_line.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: examples/trunk/booking-simplified/src/main/webapp/img/input.bg.gif
===================================================================
(Binary files differ)
Property changes on: examples/trunk/booking-simplified/src/main/webapp/img/input.bg.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: examples/trunk/booking-simplified/src/main/webapp/img/sdb.bg.gif
===================================================================
(Binary files differ)
Property changes on: examples/trunk/booking-simplified/src/main/webapp/img/sdb.bg.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: examples/trunk/booking-simplified/src/main/webapp/img/spinner.gif
===================================================================
(Binary files differ)
Property changes on: examples/trunk/booking-simplified/src/main/webapp/img/spinner.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: examples/trunk/booking-simplified/src/main/webapp/img/th.bg.gif
===================================================================
(Binary files differ)
Property changes on: examples/trunk/booking-simplified/src/main/webapp/img/th.bg.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: examples/trunk/booking-simplified/src/main/webapp/index.html
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/index.html (rev 0)
+++ examples/trunk/booking-simplified/src/main/webapp/index.html 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1 @@
+<html><head><meta http-equiv="Refresh" content="0; URL=home.seam"/></head></html>
Added: examples/trunk/booking-simplified/src/main/webapp/main.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/main.xhtml (rev 0)
+++ examples/trunk/booking-simplified/src/main/webapp/main.xhtml 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,178 @@
+<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:s="http://jboss.com/products/seam/taglib"
+ template="/WEB-INF/layout/template.xhtml">
+
+ <ui:define name="head">
+ <script type="text/javascript">
+function controlSpinner(behavior)
+{
+ if (behavior.name == 'begin')
+ {
+ document.getElementById('activity').style.display = 'inline';
+ }
+ else if (behavior.name == 'complete')
+ {
+ document.getElementById('activity').style.display = 'none';
+ }
+}
+ </script>
+ </ui:define>
+
+ <ui:define name="content">
+
+ <div class="section">
+
+ <span class="errors">
+ <h:messages id="messages" globalOnly="true"/>
+ </span>
+
+ <h1>Search Hotels</h1>
+
+ <h:form id="searchForm" prependId="false">
+ <fieldset>
+ <h:inputText id="query" value="#{searchCriteria.query}" style="width: 165px;">
+ <f:ajax event="keyup" listener="#{hotelSearch.find}" render="searchResults" onevent="controlSpinner"/>
+ </h:inputText>
+ #{' '}
+ <h:commandButton id="findHotels" value="Find Hotels" action="#{hotelSearch.find}">
+ <f:ajax execute="query" render="searchResults" onevent="controlSpinner"/>
+ </h:commandButton>
+ #{' '}
+ <span id="activity" style="display: none;"><h:graphicImage id="spinner" value="/img/spinner.gif"/></span>
+ <br/>
+ <h:outputLabel id="lblPageSize" for="pageSize" value="Maximum results:"/>
+ #{' '}
+ <h:selectOneMenu id="pageSize" value="#{searchCriteria.pageSize}">
+ <f:ajax listener="#{hotelSearch.find}" render="searchResults" onevent="controlSpinner"/>
+ <f:selectItem itemLabel="5" itemValue="5"/>
+ <f:selectItem itemLabel="10" itemValue="10"/>
+ <f:selectItem itemLabel="20" itemValue="20"/>
+ </h:selectOneMenu>
+ </fieldset>
+ </h:form>
+ </div>
+
+ <h:panelGroup id="searchResults">
+ <div class="section">
+ <h:outputText id="noHotelsMsg" value="No Hotels Found" rendered="#{empty hotels}"/>
+ <h:form id="hotelSelectionForm">
+ <h:dataTable id="hotels" value="#{hotels}" var="_hotel" rendered="#{not empty hotels}"
+ columnClasses=",,,,action">
+ <h:column id="nameCol">
+ <f:facet id="nameFct" name="header">Hotel name</f:facet>
+ #{_hotel.name}
+ </h:column>
+ <h:column id="addrCol">
+ <f:facet id="addrFct" name="header">Address</f:facet>
+ #{_hotel.address}
+ </h:column>
+ <h:column id="locCol">
+ <f:facet id="locFct" name="header">Location</f:facet>
+ #{_hotel.location}
+ </h:column>
+ <h:column id="zipCol">
+ <f:facet id="zipFct" name="header">Zip</f:facet>
+ #{_hotel.zip}
+ </h:column>
+ <h:column id="actCol">
+ <f:facet id="actFct" name="header">Action</f:facet>
+ <h:commandLink id="view" value="View" action="#{bookingAgent.selectHotel(_hotel)}" style="white-space: nowrap;"/>
+ <ui:remove><!--
+ <h:commandButton id="view" value="View" action="#{bookingAgent.selectHotel(_hotel)}"/>
+ --></ui:remove>
+ </h:column>
+ </h:dataTable>
+ </h:form>
+ <h:form id="paginationForm">
+ <h:commandButton id="previousResults" value="Previous page" action="#{hotelSearch.previousPage}" rendered="#{hotelSearch.previousPageAvailable}">
+ <f:ajax render="searchResults" onevent="controlSpinner"/>
+ </h:commandButton>
+ #{' '}
+ <h:commandButton id="moreResults" value="More results" action="#{hotelSearch.nextPage}" rendered="#{hotelSearch.nextPageAvailable}">
+ <f:ajax render="searchResults" onevent="controlSpinner"/>
+ </h:commandButton>
+ <ui:remove><!--
+ <h:commandLink id="previousResults" value="Previous page" action="#{hotelSearch.previousPage}" rendered="#{hotelSearch.previousPageAvailable}">
+ <f:ajax render="searchResults" onevent="controlSpinner"/>
+ </h:commandLink>
+ #{' '}
+ <h:commandLink id="moreResults" value="More results" action="#{hotelSearch.nextPage}" rendered="#{hotelSearch.nextPageAvailable}">
+ <f:ajax render="searchResults" onevent="controlSpinner"/>
+ </h:commandLink>
+ --></ui:remove>
+ </h:form>
+ </div>
+ </h:panelGroup>
+
+ <div class="section">
+ <h1>Current Hotel Bookings</h1>
+ </div>
+ <div class="section">
+ <h:panelGroup rendered="#{not identity.loggedIn}">
+ You must be logged in to see the list of your hotel bookings.
+ </h:panelGroup>
+ <h:form id="bookings" rendered="#{identity.loggedIn}">
+ <h:outputText value="No bookings found." rendered="#{bookings.size == 0}"/>
+ <h:dataTable id="bookings" value="#{bookings}" var="_booking" rendered="#{bookings.size gt 0}">
+ <h:column id="nameCol">
+ <f:facet id="nameFct" name="header">Hotel name</f:facet>
+ #{_booking.hotel.name}
+ </h:column>
+ <h:column id="locCol">
+ <f:facet id="locFct" name="header">Location</f:facet>
+ #{_booking.hotel.location}
+ </h:column>
+ <h:column id="inCol">
+ <f:facet id="inCol" name="header">Check-in date</f:facet>
+ <h:outputText value="#{_booking.checkinDate}">
+ <f:convertDateTime type="date" pattern="MM/dd/yyyy"/>
+ </h:outputText>
+ </h:column>
+ <h:column id="outCol">
+ <f:facet id="outFct" name="header">Check-out date</f:facet>
+ <h:outputText value="#{_booking.checkoutDate}">
+ <f:convertDateTime type="date" pattern="MM/dd/yyyy"/>
+ </h:outputText>
+ </h:column>
+ <h:column id="idCol">
+ <f:facet id="idFct" name="header">Confirmation number</f:facet>
+ #{_booking.id}
+ </h:column>
+ <h:column id="actCol">
+ <f:facet id="ActFct" name="header">Action</f:facet>
+ <h:commandLink id="cancel" value="Cancel" action="#{bookingHistory.cancelBooking(_booking)}"/>
+ </h:column>
+ </h:dataTable>
+ </h:form>
+ </div>
+
+ </ui:define>
+
+ <ui:define name="sidebar">
+
+ <h1>State management in Seam</h1>
+ <p>
+ State in Seam is <em>contextual</em>. When you click "Find Hotels", the application
+ retrieves a list of hotels from the database and caches it in the session context. When you
+ navigate to one of the hotel records by clicking the "View Hotel" link, a <em>conversation</em>
+ begins. The conversation is attached to a particular tab, in a particular browser window. You can
+ navigate to multiple hotels using "open in new tab" or "open in new window" in your web browser.
+ Each window will execute in the context of a different conversation. The application keeps state
+ associated with your hotel booking in the conversation context, which ensures that the concurrent
+ conversations do not interfere with each other.
+ </p>
+
+ <p>
+ <a href="#" onclick="window.open('exp/mainExp.html','exp','width=752,height=500,scrollbars=yes');">
+ How does the search page work?
+ </a>
+ </p>
+
+ </ui:define>
+
+</ui:composition>
Added: examples/trunk/booking-simplified/src/main/webapp/password.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/password.xhtml (rev 0)
+++ examples/trunk/booking-simplified/src/main/webapp/password.xhtml 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,62 @@
+<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:p="http://http://java.sun.com/jsf/composite/components/property"
+ template="/WEB-INF/layout/template.xhtml">
+
+ <ui:define name="content">
+
+ <div class="section">
+ <h1>Change Your Password</h1>
+ </div>
+
+ <div class="section">
+
+ <div class="errors">
+ <h:messages id="messages" globalOnly="true"/>
+ </div>
+
+ <h:form id="changePasswordForm">
+
+ <fieldset>
+
+ <p:edit id="password" label="Password">
+ <h:inputSecret id="input" value="#{user.password}" redisplay="true"/>
+ </p:edit>
+
+ <p:edit id="confirmPassword" label="Confirm password">
+ <h:inputSecret id="input" value="#{passwordManager.confirmPassword}" redisplay="true"
+ binding="#{registrationFormControls.confirmPassword}"/>
+ </p:edit>
+
+ <div class="buttonBox">
+ <h:commandButton id="change" value="Change" action="#{passwordManager.changePassword}"/>
+ #{' '}
+ <h:button id="cancel" value="Cancel" outcome="/main.xhtml"/>
+ </div>
+
+ </fieldset>
+
+ </h:form>
+ </div>
+
+</ui:define>
+
+ <ui:define name="sidebar">
+
+ <h1>Simple things should be easy</h1>
+ <p>
+ (And so should some complex things.) You shouldn't have to write four different classes just to change a
+ password. Traditional J2EE architectures require that developers spend more time writing code to make the
+ frameworks happy, than they ever get to spend writing code to make the user happy. Seam lets you reduce the
+ size of your code dramatically. And that reduces bugs. And it makes refactoring easier. And it makes
+ delivering new functionality quicker. Productivity matters. But with Seam, JSF, EJB 3.0 and jBPM, you don't
+ need to sacrifice the ability to handle complex problems just to achieve great productivity.
+ </p>
+
+ </ui:define>
+
+</ui:composition>
Added: examples/trunk/booking-simplified/src/main/webapp/register.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/register.xhtml (rev 0)
+++ examples/trunk/booking-simplified/src/main/webapp/register.xhtml 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,90 @@
+<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:p="http://http://java.sun.com/jsf/composite/components/property"
+ template="/WEB-INF/layout/template.xhtml">
+
+ <ui:param name="pageClass" value="home"/>
+
+ <ui:define name="metadata">
+ <f:event type="preRenderView" listener="#{registrar.notifyIfRegistrationIsInvalid(facesContext.validationFailed)}"/>
+ </ui:define>
+
+ <ui:define name="content">
+
+ <div class="section">
+ <h1>Register</h1>
+ </div>
+
+ <div class="section">
+
+ <div class="errors">
+ <h:messages id="messages" globalOnly="true"/>
+ </div>
+
+ <h:form id="registrationForm" prependId="false">
+
+ <fieldset>
+
+ <p:edit id="username" label="Username">
+ <h:inputText id="input" value="#{newUser.username}"
+ binding="#{registrationFormControls.username}">
+ <f:ajax event="blur" render="username"/>
+ </h:inputText>
+ </p:edit>
+
+ <p:edit id="name" label="Real name">
+ <h:inputText id="input" value="#{newUser.name}">
+ <f:ajax event="blur" render="name"/>
+ </h:inputText>
+ </p:edit>
+
+ <p:edit id="password" label="Password">
+ <h:inputSecret id="input" value="#{newUser.password}" redisplay="true">
+ <f:ajax event="blur" render="password"/>
+ </h:inputSecret>
+ </p:edit>
+
+ <p:edit id="confirmPassword" label="Confirm Password">
+ <h:inputSecret id="input" value="#{registrar.confirmPassword}" redisplay="true"
+ binding="#{registrationFormControls.confirmPassword}">
+ <f:ajax event="blur" render="confirmPassword"/>
+ </h:inputSecret>
+ </p:edit>
+
+ <div class="buttonBox">
+ <h:commandButton id="register" value="Register" action="#{registrar.register}"/>
+ #{' '}
+ <h:button id="cancel" value="Cancel" outcome="/home.xhtml"/>
+ </div>
+
+ </fieldset>
+ </h:form>
+
+ </div>
+
+ </ui:define>
+
+ <ui:define name="sidebar">
+
+ <h1>Integrated multi-layer validation</h1>
+ <p>
+ Robust applications need data validation in several different places. Seam integrates Hibernate Validator, a
+ set of annotations for expressing data model constraints in your domain model classes. Then, these constraints
+ are applied almost completely transparently at three levels of the application: by Seam when the user first
+ enters data, by EJB before persisting data to the database, and, if you use Hibernate to generate your database
+ schema, by the database constraints themselves. Multi-layer validation hardens your application and protects
+ your data. Even better, it's self-documenting, and easy to change when your business rules change.
+ </p>
+ <p>
+ <a href="#" onclick="window.open('exp/registerExp.html','exp','width=752,height=500,scrollbars=yes');">
+ What happens when I register?
+ </a>
+ </p>
+
+ </ui:define>
+
+</ui:composition>
Added: examples/trunk/booking-simplified/src/main/webapp/resources/components/property/display.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/resources/components/property/display.xhtml (rev 0)
+++ examples/trunk/booking-simplified/src/main/webapp/resources/components/property/display.xhtml 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,32 @@
+<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:c="http://java.sun.com/jsp/jstl/core"
+ xmlns:comp="http://java.sun.com/jsf/composite">
+
+ <comp:interface>
+ <comp:attribute name="label" required="true"/>
+ <comp:attribute name="value" required="false"/>
+ <comp:attribute name="override" required="false" default="false"/>
+ </comp:interface>
+
+ <ui:remove>
+ TODO allow for a template to be specified, falling back to a default
+ </ui:remove>
+
+ <comp:implementation>
+ <div class="entry" id="#{cc.clientId}">
+ <span class="label">#{cc.attrs.label}:</span>
+ <span class="output">
+ <c:choose>
+ <c:when test="#{cc.attrs.override}"><comp:insertChildren/></c:when>
+ <c:otherwise><h:outputText id="output" value="#{cc.attrs.value}"><comp:insertChildren/></h:outputText></c:otherwise>
+ </c:choose>
+ </span>
+ </div>
+ </comp:implementation>
+
+</ui:composition>
Added: examples/trunk/booking-simplified/src/main/webapp/resources/components/property/edit.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/resources/components/property/edit.xhtml (rev 0)
+++ examples/trunk/booking-simplified/src/main/webapp/resources/components/property/edit.xhtml 2010-05-26 22:31:21 UTC (rev 12833)
@@ -0,0 +1,40 @@
+<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:c="http://java.sun.com/jsp/jstl/core"
+ xmlns:comp="http://java.sun.com/jsf/composite">
+
+ <comp:interface>
+ <comp:attribute name="label" required="true"/>
+ <comp:attribute name="required" required="false" default="true"/>
+ </comp:interface>
+
+ <ui:remove>
+ TODO allow for a template to be specified, falling back to a default
+ TODO detect required from child or from bean validation annotation
+ Ed claims there is #{component.messageList}, but I don't see it
+ </ui:remove>
+
+ <comp:implementation>
+
+ <c:set var="invalid" value="#{not empty facesContext.getMessageList(cc.clientId.concat(':input'))}"/>
+ <c:set var="invalid2" value="#{not empty facesContext.getMessageList(cc.clientId.concat(':input2'))}"/>
+
+ <div class="entry" id="#{cc.clientId}">
+ <h:outputLabel value="#{cc.attrs.label}:" for="input" styleClass="label#{invalid || invalid2 ? ' errors' : ''}">
+ <c:if test="#{required}"><span class="required">*</span></c:if>
+ </h:outputLabel>
+ <span class="input#{invalid || invalid2 ? ' errors' : ''}">
+ <comp:insertChildren/>
+ </span>
+ <h:message for="input" styleClass="error errors" rendered="#{invalid}"/>
+ <h:message for="input2" styleClass="error errors" rendered="#{invalid2}"/>
+ </div>
+
+ </comp:implementation>
+
+
+</ui:composition>
More information about the seam-commits
mailing list