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

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Mon May 11 16:31:59 EDT 2009


Author: dan.j.allen
Date: 2009-05-11 16:31:59 -0400 (Mon, 11 May 2009)
New Revision: 10864

Added:
   examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/model/CreditCardType.java
   examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/reference/CreditCardReferenceProducer.java
   examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/AuthenticationEventListener.java
Modified:
   examples/trunk/booking/ear/pom.xml
   examples/trunk/booking/ejb-jar/pom.xml
   examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/AccountProducer.java
   examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearchBean.java
   examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/inventory/SearchCriteria.java
   examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/model/Booking.java
   examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/reference/CalendarReferenceProducer.java
   examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/Authenticator.java
   examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/AuthenticatorBean.java
   examples/trunk/booking/pom.xml
   examples/trunk/booking/war/src/main/webapp/WEB-INF/layout/template.xhtml
   examples/trunk/booking/war/src/main/webapp/WEB-INF/web.xml
   examples/trunk/booking/war/src/main/webapp/book.xhtml
   examples/trunk/booking/war/src/main/webapp/confirm.xhtml
   examples/trunk/booking/war/src/main/webapp/css/screen.css
   examples/trunk/booking/war/src/main/webapp/main.xhtml
   examples/trunk/booking/war/src/main/webapp/resources/property/display.xhtml
   examples/trunk/booking/war/src/main/webapp/resources/property/edit.xhtml
Log:
change ejb artifact name to ejb-jar
rename searchString property to query on SearchCriteria
enable hotel information in bookings
add credit card type to demonstrate using enum in UI
use Seam's session manager
accomodate two inputs in p:edit
create observer for authentication events
create producer for credit card information
update maven-cli-plugin aliases


Modified: examples/trunk/booking/ear/pom.xml
===================================================================
--- examples/trunk/booking/ear/pom.xml	2009-05-11 20:28:30 UTC (rev 10863)
+++ examples/trunk/booking/ear/pom.xml	2009-05-11 20:31:59 UTC (rev 10864)
@@ -208,7 +208,7 @@
 
         <dependency>
             <groupId>${project.groupId}</groupId>
-            <artifactId>${project.parent.artifactId}-ejb</artifactId>
+            <artifactId>${project.parent.artifactId}-ejb-jar</artifactId>
             <type>ejb</type>
         </dependency>
 

Modified: examples/trunk/booking/ejb-jar/pom.xml
===================================================================
--- examples/trunk/booking/ejb-jar/pom.xml	2009-05-11 20:28:30 UTC (rev 10863)
+++ examples/trunk/booking/ejb-jar/pom.xml	2009-05-11 20:31:59 UTC (rev 10864)
@@ -10,12 +10,12 @@
       <version>3.0.0-SNAPSHOT</version>
    </parent>
 
-   <artifactId>seam-booking-ejb</artifactId>
+   <artifactId>seam-booking-ejb-jar</artifactId>
    <packaging>ejb</packaging>
    <name>Seam Booking Example (EJB module)</name>
 
    <build>
-      <finalName>${project.artifactId}</finalName>
+      <finalName>${project.parent.artifactId}-ejb</finalName>
       <plugins>
 
          <plugin>
@@ -65,12 +65,6 @@
       </dependency>
 
       <dependency>
-         <groupId>javax.annotation</groupId>
-         <artifactId>jsr250-api</artifactId>
-         <scope>provided</scope>
-      </dependency>
-
-      <dependency>
          <groupId>javax.ejb</groupId>
          <artifactId>ejb-api</artifactId>
          <scope>provided</scope>
@@ -96,6 +90,12 @@
 
       <dependency>
          <groupId>${seam.groupId}</groupId>
+         <artifactId>seam-webbeans-bridge</artifactId> <!-- assumes use of Web Beans RI -->
+         <scope>runtime</scope>
+      </dependency>
+
+      <dependency>
+         <groupId>${seam.groupId}</groupId>
          <artifactId>seam-faces</artifactId>
       </dependency>
       
@@ -105,20 +105,48 @@
       </dependency>
 
       <dependency>
+         <groupId>${seam.groupId}</groupId>
+         <artifactId>seam-web</artifactId>
+      </dependency>
+
+      <dependency>
          <groupId>${webbeans.groupId}</groupId>
          <artifactId>jsr299-api</artifactId>
          <scope>provided</scope>
       </dependency>
 
+      <!-- TEMPORARY! -->
       <dependency>
          <groupId>${webbeans.groupId}</groupId>
-         <artifactId>webbeans-logging</artifactId>
+         <artifactId>webbeans-spi</artifactId>
+         <version>1.0.0-SNAPSHOT</version>
          <scope>provided</scope>
       </dependency>
 
       <dependency>
          <groupId>${webbeans.groupId}</groupId>
+         <artifactId>webbeans-core</artifactId>
+         <version>1.0.0-SNAPSHOT</version>
+         <scope>provided</scope>
+      </dependency>
+      <!-- /TEMPORARY! -->
+
+      <dependency>
+         <groupId>${webbeans.groupId}</groupId>
+         <artifactId>webbeans-logging</artifactId>
+         <scope>provided</scope> <!-- assumes the use of Web Beans RI -->
+      </dependency>
+
+      <dependency>
+         <groupId>${webbeans.groupId}</groupId>
          <artifactId>webbeans-logger</artifactId>
+         <exclusions>
+            <!-- This exclusion is necessary, but I don't understand why since it's marked as provided above -->
+            <exclusion>
+               <groupId>${webbeans.groupId}</groupId>
+               <artifactId>webbeans-logging</artifactId>
+            </exclusion>
+         </exclusions>
       </dependency>
 
    </dependencies>

Modified: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/AccountProducer.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/AccountProducer.java	2009-05-11 20:28:30 UTC (rev 10863)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/AccountProducer.java	2009-05-11 20:31:59 UTC (rev 10864)
@@ -12,6 +12,7 @@
  */
 public
 @Local
-interface AccountProducer {
+interface AccountProducer
+{
    User getCurrentAccount();
 }

Modified: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearchBean.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearchBean.java	2009-05-11 20:28:30 UTC (rev 10863)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearchBean.java	2009-05-11 20:31:59 UTC (rev 10864)
@@ -111,6 +111,6 @@
       {
          hotels = results;
       }
-      log.info("Found {0} hotel(s) matching search term ''{1}'' (limit {2})", hotels.size(), criteria.getSearchString(), criteria.getPageSize());
+      log.info("Found {0} hotel(s) matching search term ''{1}'' (limit {2})", hotels.size(), criteria.getQuery(), criteria.getPageSize());
    }
 }

Modified: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/inventory/SearchCriteria.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/inventory/SearchCriteria.java	2009-05-11 20:28:30 UTC (rev 10863)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/inventory/SearchCriteria.java	2009-05-11 20:31:59 UTC (rev 10864)
@@ -37,19 +37,19 @@
    private static final String REPEAT_SQL_WIDCARD_REGEX = SQL_WILDCARD_STR + "+";
    private static final char HUMAN_WILDCARD_CHAR = '*';
 
-   private String searchString = "";
+   private String query = "";
    private int pageSize = 5;
    private int page = 0;
 
    public String getSearchPattern()
    {
-      if (searchString == null || searchString.length() == 0)
+      if (query == null || query.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));
+      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);
@@ -81,15 +81,14 @@
       this.pageSize = pageSize;
    }
 
-   // QUESTION: rename to searchTerm?
-   public String getSearchString()
+   public String getQuery()
    {
-      return searchString;
+      return query;
    }
 
-   public void setSearchString(String searchString)
+   public void setQuery(String query)
    {
-      this.searchString = (searchString != null ? searchString.trim() : null);
+      this.query = (query != null ? query.trim() : null);
    }
 
    public void nextPage()

Modified: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/model/Booking.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/model/Booking.java	2009-05-11 20:28:30 UTC (rev 10863)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/model/Booking.java	2009-05-11 20:31:59 UTC (rev 10864)
@@ -31,6 +31,8 @@
 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;
@@ -58,7 +60,8 @@
    private Hotel hotel;
    private Date checkinDate;
    private Date checkoutDate;
-   private String creditCard;
+   private String creditCardNumber;
+   private CreditCardType creditCardType;
    private String creditCardName;
    private int creditCardExpiryMonth;
    private int creditCardExpiryYear;
@@ -135,40 +138,52 @@
    {
       this.checkoutDate = checkoutDate;
    }
-
-   @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 getCreditCard()
-   {
-      return creditCard;
-   }
-
-   public void setCreditCard(String creditCard)
-   {
-      this.creditCard = creditCard;
-   }
-
+   
    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()

Added: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/model/CreditCardType.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/model/CreditCardType.java	                        (rev 0)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/model/CreditCardType.java	2009-05-11 20:31:59 UTC (rev 10864)
@@ -0,0 +1,9 @@
+package org.jboss.seam.examples.booking.model;
+
+public enum CreditCardType
+{
+   VISA,
+   MasterCard,
+   AMEX,
+   Discover
+}
\ No newline at end of file

Modified: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/reference/CalendarReferenceProducer.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/reference/CalendarReferenceProducer.java	2009-05-11 20:28:30 UTC (rev 10863)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/reference/CalendarReferenceProducer.java	2009-05-11 20:31:59 UTC (rev 10864)
@@ -6,6 +6,7 @@
 import java.util.Calendar;
 import java.util.List;
 import java.util.Locale;
+
 import javax.annotation.Named;
 import javax.context.ConversationScoped;
 import javax.inject.Current;
@@ -40,20 +41,4 @@
       return months;
    }
 
-   public
-   @Produces
-   @Named
-   @ConversationScoped
-   @CreditCardExpiryYears
-   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/ejb-jar/src/main/java/org/jboss/seam/examples/booking/reference/CreditCardReferenceProducer.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/reference/CreditCardReferenceProducer.java	                        (rev 0)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/reference/CreditCardReferenceProducer.java	2009-05-11 20:31:59 UTC (rev 10864)
@@ -0,0 +1,47 @@
+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.annotation.Named;
+import javax.context.ConversationScoped;
+import javax.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
+{
+   public
+   @Produces
+   @Named
+   @ConversationScoped
+   List<CreditCardType> getCreditCardTypes()
+   {
+      return new ArrayList<CreditCardType>(Arrays.asList(CreditCardType.values()));
+   }
+   
+   public
+   @Produces
+   @Named
+   @ConversationScoped
+   @CreditCardExpiryYears
+   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/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/AuthenticationEventListener.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/AuthenticationEventListener.java	                        (rev 0)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/AuthenticationEventListener.java	2009-05-11 20:31:59 UTC (rev 10864)
@@ -0,0 +1,57 @@
+package org.jboss.seam.examples.booking.security;
+
+import javax.context.Context;
+import javax.context.RequestScoped;
+import javax.context.SessionScoped;
+import javax.event.Observes;
+import javax.inject.AnnotationLiteral;
+import javax.inject.manager.Bean;
+import javax.inject.manager.Manager;
+
+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.jboss.webbeans.context.AbstractThreadLocalMapContext;
+import org.jboss.webbeans.log.Log;
+import org.jboss.webbeans.log.Logger;
+
+/**
+ * An observer that monitors authentication events and performs
+ * initialization and cleanup.
+ * 
+ * @author Dan Allen
+ */
+public
+ at RequestScoped
+class AuthenticationEventListener
+{
+   private @Logger Log 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, Manager manager)
+   {
+      log.info(loggedInEvent.getPrincipal().getName() + " has logged in; clearing instance of @Registered User");
+      Bean<User> registeredUserBean = manager.resolveByType(User.class, new AnnotationLiteral<Registered>() {}).iterator().next();
+      Context sessionContext = manager.getContext(SessionScoped.class);
+      ((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();
+   }
+   
+}

Modified: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/Authenticator.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/Authenticator.java	2009-05-11 20:28:30 UTC (rev 10863)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/Authenticator.java	2009-05-11 20:31:59 UTC (rev 10864)
@@ -3,13 +3,14 @@
 import javax.ejb.Local;
 
 /**
- * <strong>Authenticator</strong> is responsible for authenticating
- * the current user.
- *
+ * <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
  */
 public
 @Local
-interface Authenticator extends org.jboss.seam.security.Authenticator {
-   
-}
+interface Authenticator extends org.jboss.seam.security.Authenticator
+{
+}
\ No newline at end of file

Modified: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/AuthenticatorBean.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/AuthenticatorBean.java	2009-05-11 20:28:30 UTC (rev 10863)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/AuthenticatorBean.java	2009-05-11 20:31:59 UTC (rev 10864)
@@ -10,14 +10,12 @@
 import org.jboss.webbeans.log.Logger;
 
 /**
- * This implementation of <strong>Authenticator</strong>
- * cross references the values of the user's credentials
- * against the database.
- *
+ * This implementation of <strong>Authenticator</strong> cross references the
+ * values of the user's credentials against the database.
+ * 
  * @author Dan Allen
  */
-public
- at Stateless
+public @Stateless
 class AuthenticatorBean implements Authenticator
 {
    private @Logger Log log;

Modified: examples/trunk/booking/pom.xml
===================================================================
--- examples/trunk/booking/pom.xml	2009-05-11 20:28:30 UTC (rev 10863)
+++ examples/trunk/booking/pom.xml	2009-05-11 20:31:59 UTC (rev 10864)
@@ -52,23 +52,24 @@
          <plugin>
             <groupId>org.twdata.maven</groupId>
             <artifactId>maven-cli-plugin</artifactId>
-            <version>0.6.3.CR2</version> <!-- TODO move to version-matrix -->
             <configuration>
+               <!-- commands are for cli:execute -->
+               <commands>
+               </commands>
+               <prompt>${project.artifactId}</prompt>
                <!-- userAliases are for cli:execute-phase -->
                <userAliases>
-                  <explode>package -o -Pexplode</explode>
-                  <deploy>seam-booking-ear package -o org.codehaus.mojo:jboss-maven-plugin:harddeploy</deploy>
-                  <undeploy>seam-booking-ear validate -o -Pundeploy</undeploy>
-                  <unexplode>seam-booking-ear validate -o -Pundeploy</unexplode>
-                  <restart>seam-booking-ear validate -o -Prestart</restart>
-                  <reexplode>package -o -Pundeploy -Pexplode</reexplode>
+                  <!-- You can add -o to any alias to work offline -->
+                  <explode>package -Pexplode</explode>
+                  <deploy>seam-booking-ear package org.codehaus.mojo:jboss-maven-plugin:harddeploy</deploy>
+                  <undeploy>seam-booking-ear validate -Pundeploy</undeploy>
+                  <unexplode>seam-booking-ear validate -Pundeploy</unexplode>
+                  <restart>seam-booking-ear validate -Prestart</restart>
+                  <reexplode>package -Pundeploy -Pexplode</reexplode>
                   <!--<redeploy>this requires two distinct steps</redeploy>-->
                   <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>
 
@@ -105,7 +106,7 @@
 
         <dependency>
             <groupId>${project.groupId}</groupId>
-            <artifactId>seam-booking-ejb</artifactId>
+            <artifactId>seam-booking-ejb-jar</artifactId>
             <version>${project.version}</version>
             <type>ejb</type>
         </dependency>

Modified: examples/trunk/booking/war/src/main/webapp/WEB-INF/layout/template.xhtml
===================================================================
--- examples/trunk/booking/war/src/main/webapp/WEB-INF/layout/template.xhtml	2009-05-11 20:28:30 UTC (rev 10863)
+++ examples/trunk/booking/war/src/main/webapp/WEB-INF/layout/template.xhtml	2009-05-11 20:31:59 UTC (rev 10864)
@@ -3,7 +3,7 @@
 <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"><ui:remove><!-- Using <f:view> as the root prevents conversation from propagating correctly--></ui:remove>
+   xmlns:f="http://java.sun.com/jsf/core"><f:view>
    <f:facet name="metadata">
       <ui:insert name="pageMetadata"/>
    </f:facet>
@@ -49,4 +49,4 @@
          </div>
       </div>
    </h:body>
-</html>
+</f:view></html>

Modified: examples/trunk/booking/war/src/main/webapp/WEB-INF/web.xml
===================================================================
--- examples/trunk/booking/war/src/main/webapp/WEB-INF/web.xml	2009-05-11 20:28:30 UTC (rev 10863)
+++ examples/trunk/booking/war/src/main/webapp/WEB-INF/web.xml	2009-05-11 20:31:59 UTC (rev 10864)
@@ -4,7 +4,7 @@
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    version="2.5">
 
-   <display-name>Seam Booking Example</display-name>
+   <display-name>Seam Booking Example (Java EE Environment)</display-name>
 
    <context-param>
       <param-name>facelets.DEVELOPMENT</param-name>
@@ -20,7 +20,17 @@
       <param-name>javax.faces.PROJECT_STAGE</param-name>
       <param-value>Development</param-value>
    </context-param>
-   
+
+   <filter>
+      <filter-name>Seam Filter</filter-name>
+      <filter-class>org.jboss.seam.web.SeamFilter</filter-class>
+   </filter>
+
+   <filter-mapping>
+      <filter-name>Seam Filter</filter-name>
+      <url-pattern>/*</url-pattern>
+   </filter-mapping>
+
    <servlet>
       <servlet-name>Faces Servlet</servlet-name>
       <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>

Modified: examples/trunk/booking/war/src/main/webapp/book.xhtml
===================================================================
--- examples/trunk/booking/war/src/main/webapp/book.xhtml	2009-05-11 20:28:30 UTC (rev 10863)
+++ examples/trunk/booking/war/src/main/webapp/book.xhtml	2009-05-11 20:31:59 UTC (rev 10864)
@@ -56,7 +56,12 @@
                </p:edit>
 
                <p:edit id="creditCardNumber" label="Credit card #">
-                  <h:inputText id="input" value="#{booking.creditCard}"/>
+                  <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">

Modified: examples/trunk/booking/war/src/main/webapp/confirm.xhtml
===================================================================
--- examples/trunk/booking/war/src/main/webapp/confirm.xhtml	2009-05-11 20:28:30 UTC (rev 10863)
+++ examples/trunk/booking/war/src/main/webapp/confirm.xhtml	2009-05-11 20:31:59 UTC (rev 10864)
@@ -29,7 +29,9 @@
             <f:convertDateTime for="output" type="date" pattern="MM/dd/yyyy"/>
          </p:display>
 
-         <p:display label="Credit card #" value="#{booking.creditCard}"/>
+         <p:display label="Credit card #" value="#{booking.creditCardNumber}"/>
+
+         <p:display label="Credit card type" value="#{booking.creditCardType}"/>
    
          <div class="buttonBox">
             <h:form id="confirmForm">

Modified: examples/trunk/booking/war/src/main/webapp/css/screen.css
===================================================================
--- examples/trunk/booking/war/src/main/webapp/css/screen.css	2009-05-11 20:28:30 UTC (rev 10863)
+++ examples/trunk/booking/war/src/main/webapp/css/screen.css	2009-05-11 20:31:59 UTC (rev 10864)
@@ -29,17 +29,16 @@
    font-weight: bold;
    color: #5E5147;
 }
-input {
+input, select {
    border: 1px solid #C3BBB6;
-   padding: 4px;
    margin: 5px 0;
    background: #FFFFFF url(../img/input.bg.gif) 0 0 repeat-x;
 }
+input {
+   padding: 4px;
+}
 select {
-   border: 1px solid #C3BBB6;
    padding: 1px;
-   margin: 5px 0;
-   background: #FFFFFF url(../img/input.bg.gif) 0 0 repeat-x;
 }
 ol, ul {
    margin: 10px 0px 10px 6px;
@@ -148,7 +147,7 @@
 .errors span {
    text-align: left;
 }
-.errors input {
+.errors input, .errors select, .errors textarea {
    border: 1px solid #600000;
 }
 .errors ul {

Modified: examples/trunk/booking/war/src/main/webapp/main.xhtml
===================================================================
--- examples/trunk/booking/war/src/main/webapp/main.xhtml	2009-05-11 20:28:30 UTC (rev 10863)
+++ examples/trunk/booking/war/src/main/webapp/main.xhtml	2009-05-11 20:31:59 UTC (rev 10864)
@@ -35,12 +35,12 @@
 
          <h:form id="searchForm" prependId="false">
             <fieldset> 
-               <h:inputText id="searchString" value="#{searchCriteria.searchString}" style="width: 165px;">
+               <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="searchString" render="searchResults" onevent="controlSpinner"/>
+                  <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>
@@ -82,9 +82,9 @@
                   <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>
+                     <ui:remove><!--
                      <h:commandButton id="view" value="View" action="#{bookingAgent.selectHotel(_hotel)}"/>
-                     </ui:remove>
+                     --></ui:remove>
                   </h:column>
                </h:dataTable>
             </h:form>
@@ -96,7 +96,7 @@
                <h:commandButton id="moreResults" value="More results" action="#{hotelSearch.nextPage}" rendered="#{hotelSearch.nextPageAvailable}">
                   <f:ajax render="searchResults" onevent="controlSpinner"/>
                </h:commandButton>
-               <ui:remove>
+               <ui:remove><!--
                <h:commandLink id="previousResults" value="Previous page" action="#{hotelSearch.previousPage}" rendered="#{hotelSearch.previousPageAvailable}">
                   <f:ajax render="searchResults" onevent="controlSpinner"/>
                </h:commandLink>
@@ -104,7 +104,7 @@
                <h:commandLink id="moreResults" value="More results" action="#{hotelSearch.nextPage}" rendered="#{hotelSearch.nextPageAvailable}">
                   <f:ajax render="searchResults" onevent="controlSpinner"/>
                </h:commandLink>
-               </ui:remove>
+               --></ui:remove>
             </h:form>
          </div>
       </h:panelGroup>
@@ -119,20 +119,14 @@
          <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}">
-               <ui:remove>
                <h:column id="nameCol">
                   <f:facet id="nameFct" name="header">Hotel name</f:facet>
-                  #{_booking.hotel}
+                  #{_booking.hotel.name}
                </h:column>
-               <h:column id="addrCol">
-                  <f:facet id="addrCol" name="header">Address</f:facet>
-                  #{_booking.hotel.address}
-               </h:column>
                <h:column id="locCol">
                   <f:facet id="locFct" name="header">Location</f:facet>
                   #{_booking.hotel.location}
                </h:column>
-               </ui:remove>
                <h:column id="inCol">
                   <f:facet id="inCol" name="header">Check-in date</f:facet>
                   <h:outputText value="#{_booking.checkinDate}">

Modified: examples/trunk/booking/war/src/main/webapp/resources/property/display.xhtml
===================================================================
--- examples/trunk/booking/war/src/main/webapp/resources/property/display.xhtml	2009-05-11 20:28:30 UTC (rev 10863)
+++ examples/trunk/booking/war/src/main/webapp/resources/property/display.xhtml	2009-05-11 20:31:59 UTC (rev 10864)
@@ -13,7 +13,10 @@
       <comp:attribute name="override" required="false" default="false"/>
    </comp:interface>
 
-   <!-- TODO allow for a template to be specified, falling back to a default -->
+   <ui:remove>
+   TODO allow for a template to be specified, falling back to a default
+   </ui:remove>
+
    <comp:implementation>
       <div class="entry">
          <span class="label">#{cc.attrs.label}:</span>

Modified: examples/trunk/booking/war/src/main/webapp/resources/property/edit.xhtml
===================================================================
--- examples/trunk/booking/war/src/main/webapp/resources/property/edit.xhtml	2009-05-11 20:28:30 UTC (rev 10863)
+++ examples/trunk/booking/war/src/main/webapp/resources/property/edit.xhtml	2009-05-11 20:31:59 UTC (rev 10864)
@@ -12,21 +12,27 @@
       <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 -->
+   <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="required" value="#{cc.attrs.required eq null ? true : cc.attrs.required}"/>
       <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">
-         <h:outputLabel value="#{cc.attrs.label}:" for="input" styleClass="label#{invalid ? ' errors' : ''}">
+         <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 ? ' errors' : ''}">
+         <span class="input#{invalid || invalid2 ? ' errors' : ''}">
             <comp:insertChildren/>
          </span>
-         <h:message for="input" styleClass="error errors"/>
+         <h:message for="input" styleClass="error errors" rendered="#{invalid}"/>
+         <h:message for="input2" styleClass="error errors" rendered="#{invalid2}"/>
       </div>
 
    </comp:implementation>




More information about the seam-commits mailing list