[seam-commits] Seam SVN: r10707 - in examples/trunk/booking: seam-booking-ear and 14 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Wed Apr 29 02:07:09 EDT 2009


Author: dan.j.allen
Date: 2009-04-29 02:07:09 -0400 (Wed, 29 Apr 2009)
New Revision: 10707

Added:
   examples/trunk/booking/seam-booking-ejb/src/main/java/org/jboss/seam/examples/booking/session/
   examples/trunk/booking/seam-booking-ejb/src/main/java/org/jboss/seam/examples/booking/session/BookingAgent.java
   examples/trunk/booking/seam-booking-ejb/src/main/java/org/jboss/seam/examples/booking/session/BookingAgentBean.java
   examples/trunk/booking/seam-booking-war/src/main/webapp/WEB-INF/fragments/
   examples/trunk/booking/seam-booking-war/src/main/webapp/WEB-INF/fragments/hotel.xhtml
   examples/trunk/booking/seam-booking-war/src/main/webapp/book.xhtml
   examples/trunk/booking/seam-booking-war/src/main/webapp/confirm.xhtml
   examples/trunk/booking/seam-booking-war/src/main/webapp/hotel.xhtml
   examples/trunk/booking/seam-booking-war/src/main/webapp/resources/
   examples/trunk/booking/seam-booking-war/src/main/webapp/resources/property/
   examples/trunk/booking/seam-booking-war/src/main/webapp/resources/property/display.xhtml
   examples/trunk/booking/seam-booking-war/src/main/webapp/resources/property/edit.xhtml
Removed:
   examples/trunk/booking/seam-booking-ejb/src/main/java/org/jboss/seam/examples/booking/action/
   examples/trunk/booking/seam-booking-war/src/main/java/
Modified:
   examples/trunk/booking/pom.xml
   examples/trunk/booking/seam-booking-ear/pom.xml
   examples/trunk/booking/seam-booking-ejb/pom.xml
   examples/trunk/booking/seam-booking-ejb/src/main/java/org/jboss/seam/examples/booking/model/Booking.java
   examples/trunk/booking/seam-booking-ejb/src/main/java/org/jboss/seam/examples/booking/model/Hotel.java
   examples/trunk/booking/seam-booking-ejb/src/main/java/org/jboss/seam/examples/booking/model/User.java
   examples/trunk/booking/seam-booking-ejb/src/main/java/org/jboss/seam/examples/booking/session/HotelSearch.java
   examples/trunk/booking/seam-booking-ejb/src/main/java/org/jboss/seam/examples/booking/session/HotelSearchBean.java
   examples/trunk/booking/seam-booking-ejb/src/main/java/org/jboss/seam/examples/booking/session/SearchCriteria.java
   examples/trunk/booking/seam-booking-ejb/src/main/resources/META-INF/beans.xml
   examples/trunk/booking/seam-booking-war/pom.xml
   examples/trunk/booking/seam-booking-war/src/main/webapp/WEB-INF/faces-config.xml
   examples/trunk/booking/seam-booking-war/src/main/webapp/WEB-INF/layout/template.xhtml
   examples/trunk/booking/seam-booking-war/src/main/webapp/WEB-INF/web.xml
   examples/trunk/booking/seam-booking-war/src/main/webapp/css/screen.css
   examples/trunk/booking/seam-booking-war/src/main/webapp/main.xhtml
Log:
major update including full booking flow


Modified: examples/trunk/booking/pom.xml
===================================================================
--- examples/trunk/booking/pom.xml	2009-04-29 06:03:37 UTC (rev 10706)
+++ examples/trunk/booking/pom.xml	2009-04-29 06:07:09 UTC (rev 10707)
@@ -26,6 +26,7 @@
       <pluginManagement>
          <plugins>
 
+            <!-- version matrix or parent? -->
             <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
@@ -34,6 +35,7 @@
                </configuration>
             </plugin>
 
+            <!-- version matrix or parent? -->
             <plugin>
                <artifactId>maven-ejb-plugin</artifactId>
                <configuration>
@@ -45,6 +47,12 @@
       </pluginManagement>
    </build>
 
+   <properties>
+      <!-- To override jboss.home, set the jboss.home property in an active profile in the Maven 2 settings.xml file -->
+      <jboss.home>${env.JBOSS_HOME}</jboss.home>
+      <jboss.domain>default</jboss.domain>
+   </properties>
+
    <profiles>
 
       <profile>
@@ -54,6 +62,14 @@
          </properties>
       </profile>
 
+      <profile>
+         <id>undeploy</id>
+      </profile>
+
+      <profile>
+         <id>restart</id>
+      </profile>
+
    </profiles>
 
    <dependencyManagement>
@@ -78,12 +94,14 @@
 
    <dependencies>
 
+      <!--
       <dependency>
          <groupId>org.testng</groupId>
          <artifactId>testng</artifactId>
          <scope>test</scope>
          <classifier>jdk15</classifier>
       </dependency>
+      -->
 
    </dependencies>
 

Modified: examples/trunk/booking/seam-booking-ear/pom.xml
===================================================================
--- examples/trunk/booking/seam-booking-ear/pom.xml	2009-04-29 06:03:37 UTC (rev 10706)
+++ examples/trunk/booking/seam-booking-ear/pom.xml	2009-04-29 06:07:09 UTC (rev 10707)
@@ -19,17 +19,7 @@
       <finalName>${project.parent.artifactId}</finalName>
       <plugins>
 
-         <!--
          <plugin>
-            <groupId>org.codehaus.mojo</groupId>
-            <artifactId>jboss-maven-plugin</artifactId>
-            <configuration>
-               <fileName>${project.build.directory}/${project.build.finalName}</fileName>
-            </configuration>
-         </plugin>
-         -->
-
-         <plugin>
             <artifactId>maven-ear-plugin</artifactId>
             <configuration>
                <defaultJavaBundleDir>lib</defaultJavaBundleDir>
@@ -55,12 +45,6 @@
       </plugins>
    </build>
 
-   <properties>
-      <!-- To override jboss.home, set the jboss.home property in an active profile in the Maven 2 settings.xml file -->
-      <jboss.home>${env.JBOSS_HOME}</jboss.home>
-      <jboss.domain>default</jboss.domain>
-   </properties>
-
    <profiles>
 
       <profile>
@@ -71,6 +55,7 @@
                   <artifactId>maven-antrun-plugin</artifactId>
                   <executions>
                      <execution>
+                        <id>explode-to-jboss-as</id>
                         <phase>package</phase>
                         <configuration>
                            <tasks>
@@ -151,6 +136,7 @@
                   <artifactId>maven-antrun-plugin</artifactId>
                   <executions>
                      <execution>
+                        <id>restart-on-jboss-as</id>
                         <phase>validate</phase>
                         <configuration>
                            <tasks>
@@ -184,6 +170,7 @@
                   <artifactId>maven-antrun-plugin</artifactId>
                   <executions>
                      <execution>
+                        <id>undeploy-from-jboss-as</id>
                         <phase>validate</phase>
                         <configuration>
                            <tasks>

Modified: examples/trunk/booking/seam-booking-ejb/pom.xml
===================================================================
--- examples/trunk/booking/seam-booking-ejb/pom.xml	2009-04-29 06:03:37 UTC (rev 10706)
+++ examples/trunk/booking/seam-booking-ejb/pom.xml	2009-04-29 06:07:09 UTC (rev 10707)
@@ -16,11 +16,55 @@
 
    <build>
       <finalName>${project.artifactId}</finalName>
+      <plugins>
+
+         <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <configuration>
+               <suiteXmlFiles>
+                  <suiteXmlFile>src/test/resources/test-suite.xml</suiteXmlFile>
+               </suiteXmlFiles>
+            </configuration>
+         </plugin>
+
+      </plugins>
    </build>
 
    <dependencies>
 
       <dependency>
+         <groupId>org.testng</groupId>
+         <artifactId>testng</artifactId>
+         <classifier>jdk15</classifier>
+         <scope>test</scope>
+      </dependency>
+
+      <dependency>
+         <groupId>${webbeans.groupId}</groupId>
+         <artifactId>webbeans-core-test</artifactId>
+         <scope>test</scope>
+      </dependency>
+
+      <dependency>
+         <groupId>org.jboss.test-harness</groupId>
+         <artifactId>jboss-test-harness</artifactId>
+         <scope>test</scope>
+      </dependency>
+
+      <dependency>
+         <groupId>javax.servlet</groupId>
+         <artifactId>servlet-api</artifactId>
+         <scope>test</scope>
+      </dependency>
+
+      <dependency>
+         <groupId>org.jboss.ejb3</groupId>
+         <artifactId>jboss-ejb3-api</artifactId>
+         <scope>test</scope>
+      </dependency>
+
+      <dependency>
          <groupId>javax.annotation</groupId>
          <artifactId>jsr250-api</artifactId>
          <scope>provided</scope>
@@ -45,11 +89,193 @@
       </dependency>
 
       <dependency>
-         <groupId>org.jboss.webbeans</groupId>
+         <groupId>${seam.groupId}</groupId>
+         <artifactId>seam-faces</artifactId>
+      </dependency>
+
+      <dependency>
+         <groupId>${webbeans.groupId}</groupId>
          <artifactId>jsr299-api</artifactId>
          <scope>provided</scope>
       </dependency>
 
+      <dependency>
+         <groupId>${webbeans.groupId}</groupId>
+         <artifactId>webbeans-logging</artifactId>
+         <scope>provided</scope>
+      </dependency>
+
+      <dependency>
+         <groupId>${webbeans.groupId}</groupId>
+         <artifactId>webbeans-logger</artifactId>
+         <version>1.0.0-SNAPSHOT</version> <!-- TODO push to version-matrix -->
+      </dependency>
+
    </dependencies>
 
+   <profiles>
+      <profile>
+         <id>integration-tests</id>
+         <build>
+            <plugins>
+               <plugin>
+                  <groupId>org.apache.maven.plugins</groupId>
+                  <artifactId>maven-dependency-plugin</artifactId>
+                  <executions>
+                     <execution>
+                        <id>copy-integration-test-dependencies</id>
+                        <phase>generate-test-sources</phase>
+                        <goals>
+                           <goal>copy</goal>
+                        </goals>
+                        <configuration>
+                           <stripVersion>true</stripVersion>
+                           <artifactItems>
+                              <artifactItem>
+                                 <groupId>org.jboss.test-harness</groupId>
+                                 <artifactId>jboss-test-harness</artifactId>
+                                 <version>1.0.0-SNAPSHOT</version> <!-- inheritence isn't working here -->
+                                 <overWrite>true</overWrite>
+                                 <outputDirectory>${project.build.directory}/classes/lib</outputDirectory>
+                              </artifactItem>
+                              <!--
+                              <artifactItem>
+                                 <groupId>javax.el</groupId>
+                                 <artifactId>el-ri</artifactId>
+                                 <overWrite>true</overWrite>
+                                 <outputDirectory>${project.build.directory}/dependency/lib</outputDirectory>
+                              </artifactItem>
+                              -->
+                           </artifactItems>
+                        </configuration>
+                     </execution>
+                  </executions>
+               </plugin>
+               <plugin>
+                  <groupId>org.apache.maven.plugins</groupId>
+                  <artifactId>maven-surefire-plugin</artifactId>
+                  <configuration>
+                     <suiteXmlFiles>
+                        <suiteXmlFile>src/test/resources/test-suite.xml</suiteXmlFile>
+                     </suiteXmlFiles>
+                     <systemProperties>
+                        <property>
+                           <name>jboss.home</name>
+                           <value>${jboss.home}</value>
+                        </property>
+                        <property>
+                           <name>org.jboss.testharness.standalone</name>
+                           <value>false</value>
+                        </property>
+                        <property>
+                           <name>org.jboss.testharness.container.extraConfigurationDir</name>
+                           <value>../../</value>
+                        </property>
+                        <property>
+                           <name>org.jboss.testharness.container.forceRestart</name>
+                           <value>false</value>
+                        </property>
+                        <property>
+                           <name>org.jboss.testharness.runIntegrationTests</name>
+                           <value>true</value>
+                        </property>
+                        <property>
+                           <name>org.jboss.testharness.libraryDirectory</name>
+                           <value>${project.build.directory}/dependency/lib</value>
+                        </property>
+                        <property>
+                           <name>org.jboss.testharness.outputDirectory</name>
+                           <value>${project.build.directory}</value>
+                        </property>
+                     </systemProperties>
+                  </configuration>
+               </plugin>
+            </plugins>
+         </build>
+         <dependencies>
+
+            <!--
+            <dependency>
+               <groupId>javax.servlet</groupId>
+               <artifactId>servlet-api</artifactId>
+               <version>2.5</version>
+               <scope>test</scope>
+            </dependency>
+
+            <dependency>
+               <groupId>org.jboss.ejb3</groupId>
+               <artifactId>jboss-ejb3-api</artifactId>
+               <version>3.1.0-Alpha1</version>
+               <scope>test</scope>
+               <exclusions>
+                  <exclusion>
+                     <artifactId>jboss-jaxrpc</artifactId>
+                     <groupId>jbossws</groupId>
+                  </exclusion>
+                  <exclusion>
+                     <artifactId>jboss-transaction-api</artifactId>
+                     <groupId>org.jboss.javaee</groupId>
+                  </exclusion>
+                  <exclusion>
+                     <artifactId>jboss-jaxrpc</artifactId>
+                     <groupId>jboss.jbossws</groupId>
+                  </exclusion>
+               </exclusions>
+            </dependency>
+            -->
+
+            <dependency>
+               <groupId>org.jboss.test-harness</groupId>
+               <artifactId>jboss-test-harness-jboss-as-50</artifactId>
+               <version>1.0.0-SNAPSHOT</version>
+               <scope>test</scope>
+            </dependency>
+
+         </dependencies>
+      </profile>
+
+      <profile>
+         <id>dump-test-artifacts</id>
+         <build>
+            <plugins>
+               <plugin>
+                  <groupId>org.codehaus.mojo</groupId>
+                  <artifactId>exec-maven-plugin</artifactId>
+                  <executions>
+                     <execution>
+                        <id>generate-test-artifacts</id>
+                        <phase>test-compile</phase>
+                        <goals>
+                           <goal>java</goal>
+                        </goals>
+                     </execution>
+                  </executions>
+                  <configuration>
+                     <mainClass>org.jboss.testharness.api.TCK</mainClass>
+                     <classpathScope>test</classpathScope>
+                     <systemProperties>
+                        <systemProperty>
+                           <key>dumpArtifacts</key>
+                           <value>true</value>
+                        </systemProperty>
+                        <systemProperty>
+                           <key>org.jboss.testharness.testPackage</key>
+                           <value>${project.groupId}</value>
+                        </systemProperty>
+                        <systemProperty>
+                           <key>org.jboss.testharness.outputDirectory</key>
+                           <value>${project.build.directory}/test-artifacts</value>
+                        </systemProperty>
+                        <systemProperty>
+                           <key>org.jboss.testharness.libraryDirectory</key>
+                           <value>${project.build.directory}/dependency/lib</value>
+                        </systemProperty>
+                     </systemProperties>
+                  </configuration>
+               </plugin>
+            </plugins>
+         </build>
+      </profile>
+
+   </profiles>
 </project>

Modified: examples/trunk/booking/seam-booking-ejb/src/main/java/org/jboss/seam/examples/booking/model/Booking.java
===================================================================
--- examples/trunk/booking/seam-booking-ejb/src/main/java/org/jboss/seam/examples/booking/model/Booking.java	2009-04-29 06:03:37 UTC (rev 10706)
+++ examples/trunk/booking/seam-booking-ejb/src/main/java/org/jboss/seam/examples/booking/model/Booking.java	2009-04-29 06:07:09 UTC (rev 10707)
@@ -1,19 +1,24 @@
-/*
+/* 
  * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.
  *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,  
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * 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;
@@ -25,7 +30,6 @@
 import java.text.DateFormat;
 import java.util.Date;
 
-import javax.persistence.Basic;
 import javax.persistence.Entity;
 import javax.persistence.GeneratedValue;
 import javax.persistence.Id;
@@ -71,18 +75,6 @@
       this.user = user;
    }
 
-   @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;
-   }
-
    @Id
    @GeneratedValue
    public Long getId()
@@ -96,7 +88,6 @@
    }
 
    @NotNull
-   @Basic
    @Temporal(DATE)
    public Date getCheckinDate()
    {
@@ -108,8 +99,8 @@
       this.checkinDate = datetime;
    }
 
+   @NotNull
    @ManyToOne
-   @NotNull
    public Hotel getHotel()
    {
       return hotel;
@@ -120,8 +111,8 @@
       this.hotel = hotel;
    }
 
+   @NotNull
    @ManyToOne
-   @NotNull
    public User getUser()
    {
       return user;
@@ -132,9 +123,8 @@
       this.user = user;
    }
 
-   @Basic
+   @NotNull
    @Temporal(TemporalType.DATE)
-   @NotNull
    public Date getCheckoutDate()
    {
       return checkoutDate;
@@ -158,15 +148,6 @@
       this.creditCard = creditCard;
    }
 
-   @Transient
-   public String getDescription()
-   {
-      DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM);
-      return hotel == null ? null : hotel.getName() +
-         ", " + df.format(getCheckinDate()) +
-         " to " + df.format(getCheckoutDate());
-   }
-
    public boolean isSmoking()
    {
       return smoking;
@@ -219,9 +200,30 @@
       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 + ")";
+      return "Booking(" + user + ", " + hotel + ")";
    }
 }

Modified: examples/trunk/booking/seam-booking-ejb/src/main/java/org/jboss/seam/examples/booking/model/Hotel.java
===================================================================
--- examples/trunk/booking/seam-booking-ejb/src/main/java/org/jboss/seam/examples/booking/model/Hotel.java	2009-04-29 06:03:37 UTC (rev 10706)
+++ examples/trunk/booking/seam-booking-ejb/src/main/java/org/jboss/seam/examples/booking/model/Hotel.java	2009-04-29 06:07:09 UTC (rev 10707)
@@ -1,19 +1,24 @@
-/*
+/* 
  * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.
  *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,  
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * 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;

Modified: examples/trunk/booking/seam-booking-ejb/src/main/java/org/jboss/seam/examples/booking/model/User.java
===================================================================
--- examples/trunk/booking/seam-booking-ejb/src/main/java/org/jboss/seam/examples/booking/model/User.java	2009-04-29 06:03:37 UTC (rev 10706)
+++ examples/trunk/booking/seam-booking-ejb/src/main/java/org/jboss/seam/examples/booking/model/User.java	2009-04-29 06:07:09 UTC (rev 10707)
@@ -1,19 +1,24 @@
-/*
+/* 
  * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.
  *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,  
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * 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;

Copied: examples/trunk/booking/seam-booking-ejb/src/main/java/org/jboss/seam/examples/booking/session (from rev 10613, examples/trunk/booking/seam-booking-ejb/src/main/java/org/jboss/seam/examples/booking/action)

Added: examples/trunk/booking/seam-booking-ejb/src/main/java/org/jboss/seam/examples/booking/session/BookingAgent.java
===================================================================
--- examples/trunk/booking/seam-booking-ejb/src/main/java/org/jboss/seam/examples/booking/session/BookingAgent.java	                        (rev 0)
+++ examples/trunk/booking/seam-booking-ejb/src/main/java/org/jboss/seam/examples/booking/session/BookingAgent.java	2009-04-29 06:07:09 UTC (rev 10707)
@@ -0,0 +1,54 @@
+/* 
+ * 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.session;
+
+import javax.ejb.Local;
+import org.jboss.seam.examples.booking.model.Booking;
+import org.jboss.seam.examples.booking.model.Hotel;
+
+/**
+ * @author Dan Allen
+ */
+public
+ at Local
+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/seam-booking-ejb/src/main/java/org/jboss/seam/examples/booking/session/BookingAgentBean.java
===================================================================
--- examples/trunk/booking/seam-booking-ejb/src/main/java/org/jboss/seam/examples/booking/session/BookingAgentBean.java	                        (rev 0)
+++ examples/trunk/booking/seam-booking-ejb/src/main/java/org/jboss/seam/examples/booking/session/BookingAgentBean.java	2009-04-29 06:07:09 UTC (rev 10707)
@@ -0,0 +1,148 @@
+/* 
+ * 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.session;
+
+import java.util.Calendar;
+import static javax.persistence.PersistenceContextType.EXTENDED;
+import javax.annotation.Named;
+import javax.context.Conversation;
+import javax.context.ConversationScoped;
+import javax.context.RequestScoped;
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+import javax.inject.Current;
+import javax.inject.Produces;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+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.jboss.webbeans.log.Log;
+import org.jboss.webbeans.log.Logger;
+
+public
+ at Named("bookingAgent")
+ at Stateful
+ at ConversationScoped
+class BookingAgentBean implements BookingAgent
+{
+   //private @Logger Log log;
+
+   @PersistenceContext(type = EXTENDED) EntityManager em;
+
+   @Current Conversation conversation;
+
+   @Current StatusMessages statusMessages;
+
+   private Hotel hotelSelection;
+
+   private Booking booking;
+
+   private boolean bookingValid;
+
+   public void selectHotel(Hotel hotel)
+   {
+      conversation.begin();
+	  // get a fresh reference that's managed by the conversational persistence context
+      hotelSelection = em.find(Hotel.class, hotel.getId());
+   }
+
+   public void bookHotel()
+   {
+      // FIXME use current user
+      User user = em.find(User.class, "dan");
+      booking = new Booking(hotelSelection, user);
+      // 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.add("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.addToControl("booking:checkinDate:input", "Check in date must be a future date");
+         bookingValid = false;
+      }
+      else if (!booking.getCheckinDate().before(booking.getCheckoutDate()))
+      {
+         statusMessages.addToControl("booking:checkoutDate:input", "Check out date must be after check in date");
+         bookingValid = false;
+      }
+      else
+      {
+         bookingValid = true;
+      }
+   }
+
+   public void confirm()
+   {
+      em.persist(booking);
+      //log.info("New booking confirmed for...");
+      statusMessages.add("You're booked!");
+      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()
+   {
+   }
+}

Modified: examples/trunk/booking/seam-booking-ejb/src/main/java/org/jboss/seam/examples/booking/session/HotelSearch.java
===================================================================
--- examples/trunk/booking/seam-booking-ejb/src/main/java/org/jboss/seam/examples/booking/action/HotelSearch.java	2009-04-23 16:04:24 UTC (rev 10613)
+++ examples/trunk/booking/seam-booking-ejb/src/main/java/org/jboss/seam/examples/booking/session/HotelSearch.java	2009-04-29 06:07:09 UTC (rev 10707)
@@ -1,4 +1,27 @@
-package org.jboss.seam.examples.booking.action;
+/* 
+ * 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.session;
 
 import java.util.List;
 import javax.ejb.Local;

Modified: examples/trunk/booking/seam-booking-ejb/src/main/java/org/jboss/seam/examples/booking/session/HotelSearchBean.java
===================================================================
--- examples/trunk/booking/seam-booking-ejb/src/main/java/org/jboss/seam/examples/booking/action/HotelSearchBean.java	2009-04-23 16:04:24 UTC (rev 10613)
+++ examples/trunk/booking/seam-booking-ejb/src/main/java/org/jboss/seam/examples/booking/session/HotelSearchBean.java	2009-04-29 06:07:09 UTC (rev 10707)
@@ -1,9 +1,31 @@
-package org.jboss.seam.examples.booking.action;
+/* 
+ * 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.session;
 
 import java.util.ArrayList;
 import java.util.List;
 import javax.annotation.Named;
-import javax.context.RequestScoped;
 import javax.context.SessionScoped;
 import javax.ejb.Remove;
 import javax.ejb.Stateful;
@@ -48,7 +70,7 @@
    public
    @Produces
    @Named
-   @RequestScoped
+   //@RequestScoped // if enabled, variable doesn't get updated after the action is executed w/o a redirect
    List<Hotel> getHotels()
    {
       return hotels;

Modified: examples/trunk/booking/seam-booking-ejb/src/main/java/org/jboss/seam/examples/booking/session/SearchCriteria.java
===================================================================
--- examples/trunk/booking/seam-booking-ejb/src/main/java/org/jboss/seam/examples/booking/action/SearchCriteria.java	2009-04-23 16:04:24 UTC (rev 10613)
+++ examples/trunk/booking/seam-booking-ejb/src/main/java/org/jboss/seam/examples/booking/session/SearchCriteria.java	2009-04-29 06:07:09 UTC (rev 10707)
@@ -1,4 +1,27 @@
-package org.jboss.seam.examples.booking.action;
+/* 
+ * 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.session;
 
 import java.io.Serializable;
 import javax.annotation.Named;
@@ -9,12 +32,33 @@
 @SessionScoped
 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 searchString = "";
    private int pageSize = 5;
    private int page = 0;
 
-   public String getSearchPattern() {
-      return searchString == null ? "%" : '%' + searchString.toLowerCase().replace('*', '%') + '%';
+   public String getSearchPattern()
+   {
+      if (searchString == null || searchString.length() == 0)
+      {
+         return SQL_WILDCARD_STR;
+      }
+
+      StringBuilder pattern = new StringBuilder();
+      pattern.append(searchString.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()
@@ -44,7 +88,7 @@
 
    public void setSearchString(String searchString)
    {
-      this.searchString = searchString;
+      this.searchString = (searchString != null ? searchString.trim() : null);
    }
 
    public void nextPage()
@@ -54,7 +98,8 @@
 
    public void previousPage()
    {
-      if (page > 0) {
+      if (page > 0)
+      {
          page--;
       }
    }

Modified: examples/trunk/booking/seam-booking-ejb/src/main/resources/META-INF/beans.xml
===================================================================
--- examples/trunk/booking/seam-booking-ejb/src/main/resources/META-INF/beans.xml	2009-04-29 06:03:37 UTC (rev 10706)
+++ examples/trunk/booking/seam-booking-ejb/src/main/resources/META-INF/beans.xml	2009-04-29 06:07:09 UTC (rev 10707)
@@ -0,0 +1,8 @@
+<Beans xmlns="urn:java:ee"
+   xmlns:faces="urn:java:org.jboss.seam.faces">
+   <Deploy>
+      <Standard/>
+      <Production/>
+      <faces:Faces/>
+   </Deploy>
+</Beans>

Modified: examples/trunk/booking/seam-booking-war/pom.xml
===================================================================
--- examples/trunk/booking/seam-booking-war/pom.xml	2009-04-29 06:03:37 UTC (rev 10706)
+++ examples/trunk/booking/seam-booking-war/pom.xml	2009-04-29 06:07:09 UTC (rev 10707)
@@ -23,13 +23,24 @@
 
       <!--
       <dependency>
-         <groupId>com.sun.facelets</groupId>
-         <artifactId>jsf-facelets</artifactId>
+         <groupId>javax.faces</groupId>
+         <artifactId>jsf-api</artifactId>
+         <scope>provided</scope>
       </dependency>
 
       <dependency>
-         <groupId>org.jboss.el</groupId>
-         <artifactId>jboss-el</artifactId>
+         <groupId>javax.el</groupId>
+         <artifactId>el-api</artifactId>
+         <scope>provided</scope>
+      </dependency>
+      -->
+
+      <!-- is this necessary? is it for upgrading to EL 1.2? -->
+      <!--
+      <dependency>
+         <groupId>javax.el</groupId>
+         <artifactId>el-ri</artifactId>
+         <scope>runtime</scope>
          <exclusions>
             <exclusion>
                <groupId>javax.el</groupId>
@@ -39,9 +50,18 @@
       </dependency>
       -->
 
+      <!--
       <dependency>
-         <groupId>javax.el</groupId>
-         <artifactId>el-ri</artifactId>
+         <groupId>${seam.groupId}</groupId>
+         <artifactId>seam-faces</artifactId>
+      </dependency>
+      -->
+
+      <!-- pulled in by seam-el
+      <dependency>
+         <groupId>org.jboss.el</groupId>
+         <artifactId>jboss-el</artifactId>
+         <scope>runtime</scope>
          <exclusions>
             <exclusion>
                <groupId>javax.el</groupId>
@@ -49,6 +69,7 @@
             </exclusion>
          </exclusions>
       </dependency>
+      -->
       
    </dependencies>
 

Modified: examples/trunk/booking/seam-booking-war/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- examples/trunk/booking/seam-booking-war/src/main/webapp/WEB-INF/faces-config.xml	2009-04-29 06:03:37 UTC (rev 10706)
+++ examples/trunk/booking/seam-booking-war/src/main/webapp/WEB-INF/faces-config.xml	2009-04-29 06:07:09 UTC (rev 10707)
@@ -3,28 +3,81 @@
    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">
-    
-   <application>
+   
+   <navigation-rule>
+      <from-view-id>*</from-view-id>
+
+      <navigation-case>
+         <from-action>#{bookingAgent.cancel}</from-action>
+         <to-view-id>/main.xhtml</to-view-id>
+         <if>#{true}</if>
+         <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 -->
       <!--
-      <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
+      <navigation-case>
+         <from-action>#{hotelSearch.find}</from-action>
+         <to-view-id>/main.xhtml</to-view-id>
+         <if>#{true}</if>
+         <redirect/>
+      </navigation-case>
+      <navigation-case>
+         <from-action>#{hotelSearch.nextPage}</from-action>
+         <to-view-id>/main.xhtml</to-view-id>
+         <if>#{true}</if>
+         <redirect/>
+      </navigation-case>
       -->
-   </application>
 
+      <navigation-case>
+         <from-action>#{bookingAgent.selectHotel(_hotel)}</from-action>
+         <to-view-id>/hotel.xhtml</to-view-id>
+         <if>#{bookingAgent.hotelSelection != null}</if>
+         <redirect/>
+      </navigation-case>
+
+   </navigation-rule>
+
    <navigation-rule>
-	   <!-- navigation rules are required to reset request-scoped producer variables -->
-	   <from-view-id>/main.xhtml</from-view-id>
-	   <navigation-case>
-		   <from-action>#{hotelSearch.find}</from-action>
-		   <to-view-id>/main.xhtml</to-view-id>
-		   <if>#{true}</if>
-		   <redirect/>
-	   </navigation-case>
-	   <navigation-case>
-		   <from-action>#{hotelSearch.nextPage}</from-action>
-		   <to-view-id>/main.xhtml</to-view-id>
-		   <if>#{true}</if>
-		   <redirect/>
-	   </navigation-case>
+      <from-view-id>/hotel.xhtml</from-view-id>
+
+      <navigation-case>
+         <from-action>#{bookingAgent.bookHotel}</from-action>
+         <to-view-id>/book.xhtml</to-view-id>
+         <if>#{bookingAgent.booking != null}</if>
+         <redirect/>
+      </navigation-case>
+
    </navigation-rule>
 
+   <navigation-rule>
+      <from-view-id>/book.xhtml</from-view-id>
+
+      <navigation-case>
+         <from-action>#{bookingAgent.validateBooking}</from-action>
+         <to-view-id>/confirm.xhtml</to-view-id>
+         <if>#{bookingAgent.bookingValid}</if>
+         <redirect/>
+      </navigation-case>
+
+   </navigation-rule>
+
+   <navigation-rule>
+      <from-view-id>/confirm.xhtml</from-view-id>
+
+      <navigation-case>
+         <from-action>#{bookingAgent.confirm}</from-action>
+         <to-view-id>/main.xhtml</to-view-id>
+         <if>#{true}</if>
+         <redirect/>
+      </navigation-case>
+
+   </navigation-rule>
+
 </faces-config>

Added: examples/trunk/booking/seam-booking-war/src/main/webapp/WEB-INF/fragments/hotel.xhtml
===================================================================
--- examples/trunk/booking/seam-booking-war/src/main/webapp/WEB-INF/fragments/hotel.xhtml	                        (rev 0)
+++ examples/trunk/booking/seam-booking-war/src/main/webapp/WEB-INF/fragments/hotel.xhtml	2009-04-29 06:07:09 UTC (rev 10707)
@@ -0,0 +1,21 @@
+<!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/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="Nightly rate" override="true">
+      <h:outputText value="#{hotel.price}">
+         <f:convertNumber type="currency" currencySymbol="$"/>
+      </h:outputText>
+   </p:display>
+
+</ui:composition>

Modified: examples/trunk/booking/seam-booking-war/src/main/webapp/WEB-INF/layout/template.xhtml
===================================================================
--- examples/trunk/booking/seam-booking-war/src/main/webapp/WEB-INF/layout/template.xhtml	2009-04-29 06:03:37 UTC (rev 10706)
+++ examples/trunk/booking/seam-booking-war/src/main/webapp/WEB-INF/layout/template.xhtml	2009-04-29 06:07:09 UTC (rev 10707)
@@ -1,25 +1,26 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<f:view xmlns="http://www.w3.org/1999/xhtml"
+<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"
-   contentType="text/html">
-<html>
-   <head>
+   xmlns:f="http://java.sun.com/jsf/core"><ui:remove><!-- Using <f:view> as the root prevents conversation from propagating correctly--></ui:remove>
+   <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"/>
-   </head>
-   <body>
+      <ui:insert name="head"/>
+   </h:head>
+   <h:body>
       <div id="document">
          <div id="header">
             <div id="title"><h:graphicImage value="/img/hdr.title.gif" alt="JBoss Suites: seam framework demo"/></div>
             <div id="status">
+               <h:link id="about" outcome="/home.xhtml" value="About"/>
+               #{' | '}
                <h:link id="search" outcome="/main.xhtml" value="Search"/>
                <ui:remove><!--
-               Welcome #{user.name}
+               Welcome #{user.name} or use (#{user.name})
                | <h:link id="search" outcome="/main.xhtml" value="Search"/>
                | <h:link id="settings" outcome="/password.xhtml" value="Settings"/>
                | <s:link id="logout" action="#{identity.logout}" value="Logout"/>
@@ -34,8 +35,11 @@
                <ui:insert name="content"/>
             </div>
          </div>
-         <div id="footer">Created with Seam 3.0, Web Beans, EJB 3.0 and JSF 2.0</div>
+         <div id="footer">
+            Created with Seam 3.0, Web Beans, EJB 3.0 and JSF 2.0
+            <br/>
+            #{javax.context.conversation}
+         </div>
       </div>
-   </body>
+   </h:body>
 </html>
-</f:view>

Modified: examples/trunk/booking/seam-booking-war/src/main/webapp/WEB-INF/web.xml
===================================================================
--- examples/trunk/booking/seam-booking-war/src/main/webapp/WEB-INF/web.xml	2009-04-29 06:03:37 UTC (rev 10706)
+++ examples/trunk/booking/seam-booking-war/src/main/webapp/WEB-INF/web.xml	2009-04-29 06:07:09 UTC (rev 10707)
@@ -5,18 +5,21 @@
    version="2.5">
 
    <display-name>Seam Booking Example</display-name>
-   
-   <!--
+
    <context-param>
-      <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
-      <param-value>.xhtml</param-value>
+      <param-name>facelets.DEVELOPMENT</param-name>
+      <param-value>true</param-value>
    </context-param>
-   -->
    
    <context-param>
-      <param-name>facelets.DEVELOPMENT</param-name>
+      <param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</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>
@@ -32,5 +35,14 @@
    <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>
    
 </web-app>

Added: examples/trunk/booking/seam-booking-war/src/main/webapp/book.xhtml
===================================================================
--- examples/trunk/booking/seam-booking-war/src/main/webapp/book.xhtml	                        (rev 0)
+++ examples/trunk/booking/seam-booking-war/src/main/webapp/book.xhtml	2009-04-29 06:07:09 UTC (rev 10707)
@@ -0,0 +1,115 @@
+<!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/property"
+   template="/WEB-INF/layout/template.xhtml">
+
+   <ui:define name="content">
+      <div class="section">
+         <h1>Book Hotel</h1>
+      </div>
+
+      <div class="section">
+         <div class="entry errors">
+            <h:messages id="messages" globalOnly="true"/>
+         </div>
+      
+         <ui:include src="/WEB-INF/fragments/hotel.xhtml"/>
+         
+         <div style="clear: both;"/>
+      
+         <h:form id="booking">
+            <fieldset>
+                  
+               <p:edit id="checkinDate" label="Check-in date">
+                  <h:inputText id="input" value="#{booking.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}">
+                     <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.creditCard}"/>
+               </p:edit>
+
+               <p:edit id="creditCardExpiry" label="Credit card expiry">
+                  <h:selectOneMenu id="input" value="#{booking.creditCardExpiryMonth}">
+                     <f:selectItem id="Jan" itemLabel="Jan" itemValue="1"/>
+                     <f:selectItem id="Feb" itemLabel="Feb" itemValue="2"/>
+                     <f:selectItem id="Mar" itemLabel="Mar" itemValue="3"/>
+                     <f:selectItem id="Apr" itemLabel="Apr" itemValue="4"/>
+                     <f:selectItem id="May" itemLabel="May" itemValue="5"/>
+                     <f:selectItem id="Jun" itemLabel="Jun" itemValue="6"/>
+                     <f:selectItem id="Jul" itemLabel="Jul" itemValue="7"/>
+                     <f:selectItem id="Aug" itemLabel="Aug" itemValue="8"/>
+                     <f:selectItem id="Sep" itemLabel="Sep" itemValue="9"/>
+                     <f:selectItem id="Oct" itemLabel="Oct" itemValue="10"/>
+                     <f:selectItem id="Nov" itemLabel="Nov" itemValue="11"/>
+                     <f:selectItem id="Dec" itemLabel="Dec" itemValue="12"/>
+                  </h:selectOneMenu>
+                  <h:selectOneMenu id="input2" value="#{booking.creditCardExpiryYear}">
+                     <f:selectItem id="Year2005" itemLabel="2005" itemValue="2005"/>
+                     <f:selectItem id="Year2006" itemLabel="2006" itemValue="2006"/>
+                     <f:selectItem id="Year2007" itemLabel="2007" itemValue="2007"/>
+                     <f:selectItem id="Year2008" itemLabel="2008" itemValue="2008"/>
+                     <f:selectItem id="Year2009" itemLabel="2009" itemValue="2009"/>
+                  </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/seam-booking-war/src/main/webapp/confirm.xhtml
===================================================================
--- examples/trunk/booking/seam-booking-war/src/main/webapp/confirm.xhtml	                        (rev 0)
+++ examples/trunk/booking/seam-booking-war/src/main/webapp/confirm.xhtml	2009-04-29 06:07:09 UTC (rev 10707)
@@ -0,0 +1,63 @@
+<!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/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" override="true">
+            <h:outputText value="#{booking.total}">
+               <f:convertNumber type="currency" currencySymbol="$"/>
+            </h:outputText>
+         </p:display>
+
+         <p:display label="Check-in date" value="#{booking.checkinDate}"/>
+         <p:display label="Check-out date" value="#{booking.checkoutDate}"/>
+         <p:display label="Credit card #" value="#{booking.creditCard}"/>
+   
+         <div class="buttonBox">
+            <h:form id="confirm">
+               <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>

Modified: examples/trunk/booking/seam-booking-war/src/main/webapp/css/screen.css
===================================================================
--- examples/trunk/booking/seam-booking-war/src/main/webapp/css/screen.css	2009-04-29 06:03:37 UTC (rev 10706)
+++ examples/trunk/booking/seam-booking-war/src/main/webapp/css/screen.css	2009-04-29 06:07:09 UTC (rev 10707)
@@ -1,278 +1,271 @@
 /* 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;
+   margin: 0;
+   padding: 0;
 }
 /* Element Defaults
 ----------------------------------------------- */
 html {
-	height: 100%;
-	background-color: #DBD4C6;
+   height: 100%;
+   background-color: #DBD4C6;
+   overflow-y: scroll;
 }
-img {
-	border: 0;
-}
 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;
+   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;
+   font-weight: bold;
+   color: #5E5147;
 }
 input {
-	border: 1px solid #C3BBB6;
-	padding: 4px;
-	margin: 5px 0;
-	background: #fff url(../img/input.bg.gif) 0 0 repeat-x;
+   border: 1px solid #C3BBB6;
+   padding: 4px;
+   margin: 5px 0;
+   background: #fff url(../img/input.bg.gif) 0 0 repeat-x;
 }
 select {
-	border: 1px solid #C3BBB6;
-	padding: 4px;
-	margin: 5px 0;
-	background: #fff url(../img/input.bg.gif) 0 0 repeat-x;
+   border: 1px solid #C3BBB6;
+   padding: 4px;
+   margin: 5px 0;
+   background: #fff url(../img/input.bg.gif) 0 0 repeat-x;
 }
 ol, ul {
-	margin: 10px 0px 10px 6px;
+   margin: 10px 0px 10px 6px;
 }
 li {
-	margin: 10px 12px;
+   margin: 10px 12px;
 }
 fieldset {
-	border: 0;
+   border: 0;
 }
 /* Layout
 ----------------------------------------------- */
 #document {
-	padding: 0 1px;
-	background: #fff url(../img/bg.gif) 0 0 repeat-y;
-	float: left;
-	border-bottom: 1px solid #C3BBB6;
+   padding: 0 1px;
+   background: #fff 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;
+   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;
+   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;
+   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: #fff url(../img/cnt.bg.gif) 0 0 repeat-x;
+   float: left;
+   width: 548px;
+   margin-top: 75px;
+   padding-top: 5px;
+   background: #fff 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: #fff;
-	width: 718px;
-	text-align: right;
+   clear: both;
+   margin-top: 40px;
+   float: left;
+   padding: 20px;
+   border-top: 1px solid #C3BBB6;
+   background-color: #fff;
+   width: 718px;
+   text-align: right;
 }
 /* General
 ----------------------------------------------- */
 input[type="submit"], input[type="button"] {
-	font-weight: bold;
-	color: #fff;
-	border: 1px solid #5D1414;
-	height: 26px;
-	background: #fff url(../img/btn.bg.gif) 0 0 repeat-x;
-	border-style: none;
+   font-weight: bold;
+   color: #fff;
+   border: 1px solid #5D1414;
+   height: 26px;
+   background: #fff url(../img/btn.bg.gif) 0 0 repeat-x;
+   border-style: none;
 }
 .center {
-	text-align: center;
+   text-align: center;
 }
 .entry {
-	clear: both;
-	padding-top: 10px;
+   clear: both;
+   padding-top: 10px;
 }
 .entry .label {
-	float: left;
-	padding-right: 5px;
-	font-weight: bold;
-	width: 150px;
-	text-align: right;
+   float: left;
+   padding-right: 5px;
+   font-weight: bold;
+   width: 160px;
+   text-align: right;
 }
-.entry .output {
-	float: right;
-	width: 360px;
-	padding-top: 10px;
-	text-align: left;
+.entry .input, .entry .output, .entry .error {
+   float: right;
+   width: 350px;
+   text-align: left;
 }
-.entry .input {
-	float: right;
-	width: 360px;
-	text-align: left;
-}
-.entry .error {
-	float: right;
-	width: 360px;
-	text-align: left;
-}
 /* Sidebar
 ----------------------------------------------- */
 .notes {
-	text-align: center;
-	font-size: small;
+   text-align: center;
+   font-size: small;
 }
 .subnotes {
     margin-top: 1em;
-	font-size: small;
+   font-size: small;
 }
 .errors {
-	font-size: small;
-	font-weight: bold;
-	text-align: center;
-	color: #600;
+   font-size: small;
+   font-weight: bold;
+   text-align: center;
+   color: #600;
 }
 .errors div {
-	text-align: left;
+   text-align: left;
 }
 .errors span {
-	text-align: left;
+   text-align: left;
 }
 .errors input {
-	border: 1px solid #600;
+   border: 1px solid #600;
 }
 .errors ul {
-	list-style: none;
+   list-style: none;
 }
 .buttonBox {
-	text-align: center;
-	padding: 5px 0;
-	clear: both;
+   text-align: center;
+   padding: 5px 0;
+   clear: both;
 }
 #sidebar p {
-	font-size: small;
-	color: #8B7869;
-	line-height: 150%;
-	padding-bottom: 10px;
+   font-size: small;
+   color: #8B7869;
+   line-height: 150%;
+   padding-bottom: 10px;
 }
 #sidebar li {
-	font-size: small;
-	color: #8B7869;
+   font-size: small;
+   color: #8B7869;
 }
 #sidebar h1 {
-	line-height: normal;
-	font-weight: bold;
-	font-size: small;
+   line-height: normal;
+   font-weight: bold;
+   font-size: small;
 }
 /*
 #sidebar p:hover {
-	color: #362F2D;
+   color: #362F2D;
 }
 */
 /* Content
 ----------------------------------------------- */
 #content .section {
-	float: left;
-	width: 518px;
-	padding: 15px 15px 0 15px;
+   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;
+   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;
+   line-height: 150%;
+   padding: 10px 0;
+   font-size: small;
 }
 #content table {
-	width: 100%;
-	border: 1px solid #D2C9C4;
-	border-collapse: collapse;
+   width: 100%;
+   border: 1px solid #D2C9C4;
+   border-collapse: collapse;
 }
 #content table caption {
-	padding-bottom: 6px;
-	text-align: left;
-	font-weight: bold;
+   padding-bottom: 6px;
+   text-align: left;
+   font-weight: bold;
 }
 #content table thead th {
-	border-left: 1px solid #D2C9C4;
-	background: #fff url(../img/th.bg.gif) 0 100% repeat-x;	
-	border-bottom: 1px solid #D2C9C4;
-	padding: 6px;
-	text-align: left;
-	font-size: small;
+   border-left: 1px solid #D2C9C4;
+   background: #fff 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;
+   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%;
+   font-weight: bold;
+   float: left;
+   width: 33%;
 }
 #content dd {
-	padding-left: 10px;
-	float: left;
-	width: 66%;
+   padding-left: 10px;
+   float: left;
+   width: 66%;
 }
 #content table.radio {
-	border: 0px;
+   border: 0px;
 }
 #content table.radio tbody tr td {
-	border: 0px;
-	border-left: 0px;
-	border-bottom: 0px;
+   border: 0px;
+   border-left: 0px;
+   border-bottom: 0px;
 }
 /* Header
 ----------------------------------------------- */
 #title {
-	float: left;
-	padding: 1px 0 6px 15px;
+   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;
+   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;
+   color: #C7B299;
+   text-decoration: none;
 }
 /* Homepage Modifications
 ----------------------------------------------- */
 #pgHome #container {
-	background: url(../img/hdr.ad.jpg) 0 0 repeat-x;
+   background: url(../img/hdr.ad.jpg) 0 0 repeat-x;
 }
 #pgHome #sidebar {
-	margin-top: 207px;
+   margin-top: 207px;
 }
 #pgHome #content {
-	margin-top: 183px;
+   margin-top: 183px;
 }

Added: examples/trunk/booking/seam-booking-war/src/main/webapp/hotel.xhtml
===================================================================
--- examples/trunk/booking/seam-booking-war/src/main/webapp/hotel.xhtml	                        (rev 0)
+++ examples/trunk/booking/seam-booking-war/src/main/webapp/hotel.xhtml	2009-04-29 06:07:09 UTC (rev 10707)
@@ -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>

Modified: examples/trunk/booking/seam-booking-war/src/main/webapp/main.xhtml
===================================================================
--- examples/trunk/booking/seam-booking-war/src/main/webapp/main.xhtml	2009-04-29 06:03:37 UTC (rev 10706)
+++ examples/trunk/booking/seam-booking-war/src/main/webapp/main.xhtml	2009-04-29 06:07:09 UTC (rev 10707)
@@ -7,6 +7,22 @@
    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">
@@ -17,24 +33,17 @@
     
          <h1>Search Hotels</h1>
 
-         <h:form id="searchForm">
+         <h:form id="searchForm" prependId="false">
             <fieldset> 
                <h:inputText id="searchString" value="#{searchCriteria.searchString}" style="width: 165px;">
-                  <f:ajax event="keyup" listener="#{hotelSearch.find}" render="searchResults"/>
+                  <f:ajax event="keyup" listener="#{hotelSearch.find}" render="searchResults" onevent="controlSpinner"/>
                </h:inputText>
                #{' '}
                <h:commandButton id="findHotels" value="Find Hotels" action="#{hotelSearch.find}">
-                  <ui:remove><f:ajax listener="#{hotelSearch.find}" render="searchResults"/></ui:remove>
+                  <f:ajax listener="#{hotelSearch.find}" execute="searchString" render="searchResults" onevent="controlSpinner"/>
                </h:commandButton>
-               <ui:remove>
-               <!--
-               <a:status id="status">
-                  <f:facet id="startStatus" name="start">
-                     <h:graphicImage id="SpinnerGif" value="/img/spinner.gif"/>
-                  </f:facet>
-               </a:status>
-               -->
-               </ui:remove>
+               #{' '}
+               <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:"/>
                #{' '}
@@ -50,28 +59,34 @@
       <h:panelGroup id="searchResults">
          <div class="section">
             <h:outputText id="noHotelsMsg" value="No Hotels Found" rendered="#{empty hotels}"/>
-            <h:dataTable id="hotels" value="#{hotels}" var="_hotel" rendered="#{not empty hotels}">
-               <h:column id="nameCol">
-                  <f:facet id="nameFct" name="header">Name</f:facet>
-                  #{_hotel.name}
-               </h:column>
-               <h:column id="addressCol">
-                  <f:facet id="addressFct" name="header">Address</f:facet>
-                  #{_hotel.address}
-               </h:column>
-               <h:column id="locationCol">
-                  <f:facet id="locationFct" name="header">Location</f:facet>
-                  #{_hotel.city}, #{_hotel.state}, #{_hotel.country}
-               </h:column> 
-               <h:column id="zipCol">
-                  <f:facet id="zipFct" name="header">Zip</f:facet>
-                  #{_hotel.zip}
-               </h:column>
-               <h:column id="actionCol">
-                  <f:facet id="actionFct" name="header">Action</f:facet>
-                  <ui:remove><!--<s:link id="viewHotel" value="View Hotel" action="#{hotelBooking.selectHotel(hot)}"/>--></ui:remove>
-               </h:column>
-            </h:dataTable>
+            <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">Name</f:facet>
+                     #{_hotel.name}
+                  </h:column>
+                  <h:column id="addressCol">
+                     <f:facet id="addressFct" name="header">Address</f:facet>
+                     #{_hotel.address}
+                  </h:column>
+                  <h:column id="locationCol">
+                     <f:facet id="locationFct" name="header">Location</f:facet>
+                     #{_hotel.city}, #{_hotel.state}, #{_hotel.country}
+                  </h:column> 
+                  <h:column id="zipCol">
+                     <f:facet id="zipFct" name="header">Zip</f:facet>
+                     #{_hotel.zip}
+                  </h:column>
+                  <h:column id="actionCol">
+                     <f:facet id="actionFct" 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}"/>
                #{' '}
@@ -90,6 +105,7 @@
        </h:panelGroup>
 
 <ui:remove>
+<!--
 <div class="section">
    <h1>Current Hotel Bookings</h1>
 </div>
@@ -128,6 +144,7 @@
    </h:dataTable>
   </h:form>
 </div>
+-->
 </ui:remove>
 
    </ui:define>

Added: examples/trunk/booking/seam-booking-war/src/main/webapp/resources/property/display.xhtml
===================================================================
--- examples/trunk/booking/seam-booking-war/src/main/webapp/resources/property/display.xhtml	                        (rev 0)
+++ examples/trunk/booking/seam-booking-war/src/main/webapp/resources/property/display.xhtml	2009-04-29 06:07:09 UTC (rev 10707)
@@ -0,0 +1,30 @@
+<!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>
+
+   <!-- the override is a workaround because assigning an id to the output dynamically is not working -->
+   <!-- TODO allow for a template to be specified, falling back to a default -->
+   <comp:implementation>
+      <div class="entry">
+         <span class="label">#{cc.attrs.label}:</span>
+         <span class="output">
+            <c:choose>
+               <c:when test="#{cc.attrs.override}"><comp:insertChildren/></c:when>
+               <c:otherwise>#{cc.attrs.value}</c:otherwise>
+            </c:choose>
+         </span>
+      </div>
+   </comp:implementation>
+
+</ui:composition>

Added: examples/trunk/booking/seam-booking-war/src/main/webapp/resources/property/edit.xhtml
===================================================================
--- examples/trunk/booking/seam-booking-war/src/main/webapp/resources/property/edit.xhtml	                        (rev 0)
+++ examples/trunk/booking/seam-booking-war/src/main/webapp/resources/property/edit.xhtml	2009-04-29 06:07:09 UTC (rev 10707)
@@ -0,0 +1,35 @@
+<!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"/>
+   </comp:interface>
+
+   <!-- TODO allow for a template to be specified, falling back to a default -->
+   <!-- TODO detect required from child or from bean validation annotation -->
+   <comp:implementation>
+
+      <c:set var="required" value="#{cc.attrs.required eq null ? true : cc.attrs.required}"/>
+      <c:set var="invalid" value="#{not empty facesContext.getMessageList(cc.clientId.concat(':input'))}"/>
+
+      <div class="entry">
+         <h:outputLabel value="#{cc.attrs.label}:" for="input" styleClass="label#{invalid ? ' errors' : ''}">
+            <c:if test="#{required}"><span class="required">*</span></c:if>
+         </h:outputLabel>
+         <span class="input#{invalid ? ' errors' : ''}">
+            <comp:insertChildren/>
+         </span>
+         <h:message for="input" styleClass="error errors"/>
+      </div>
+
+   </comp:implementation>
+
+
+</ui:composition>




More information about the seam-commits mailing list