[seam-commits] Seam SVN: r13154 - in examples/trunk/booking-simplified/src/main: java/org/jboss/seam/examples/booking/account and 8 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Tue Jun 15 14:30:09 EDT 2010


Author: lincolnthree
Date: 2010-06-15 14:30:09 -0400 (Tue, 15 Jun 2010)
New Revision: 13154

Added:
   examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/MockCredentials.java
   examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/MockIdentity.java
   examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/setup/
   examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/setup/ApplicationSetupBean.java
   examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/setup/SetupBean.java
   examples/trunk/booking-simplified/src/main/webapp/META-INF/
   examples/trunk/booking-simplified/src/main/webapp/META-INF/MANIFEST.MF
Modified:
   examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/RegistrarBean.java
   examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/Hotel.java
   examples/trunk/booking-simplified/src/main/resources/META-INF/persistence.xml
   examples/trunk/booking-simplified/src/main/webapp/WEB-INF/fragments/account.xhtml
   examples/trunk/booking-simplified/src/main/webapp/WEB-INF/layout/template.xhtml
   examples/trunk/booking-simplified/src/main/webapp/password.xhtml
Log:
Now functions on any app-server.

Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/RegistrarBean.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/RegistrarBean.java	2010-06-15 18:26:52 UTC (rev 13153)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/RegistrarBean.java	2010-06-15 18:30:09 UTC (rev 13154)
@@ -31,9 +31,7 @@
    @Inject
    private RegistrationFormControls formControls;
 
-   @Inject
-   @Registered
-   User newUser;
+   private final User newUser = new User();
 
    private String confirmPassword;
 
@@ -46,6 +44,7 @@
       if (verifyPasswordsMatch() && verifyUsernameIsAvailable())
       {
          registered = true;
+         em.persist(newUser);
          messages.info(new BundleKey("messages.properties", "registration.registered")).textDefault("You have been successfully registered as the user {0}!").textParams(newUser.getUsername());
       }
       else
@@ -69,9 +68,9 @@
       }
    }
 
-   @Produces
-   @Named
+   @Named("newUser")
    @RequestScoped
+   @Produces
    public User getNewUser()
    {
       return newUser;

Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/Hotel.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/Hotel.java	2010-06-15 18:26:52 UTC (rev 13153)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/Hotel.java	2010-06-15 18:30:09 UTC (rev 13154)
@@ -30,7 +30,6 @@
 import javax.persistence.Entity;
 import javax.persistence.GeneratedValue;
 import javax.persistence.Id;
-
 import javax.persistence.Table;
 import javax.persistence.Transient;
 import javax.validation.constraints.Max;
@@ -39,8 +38,10 @@
 import javax.validation.constraints.Size;
 
 /**
- * <p><strong>Hotel</strong> is the model/entity class that represents a hotel.</p>
- *
+ * <p>
+ * <strong>Hotel</strong> is the model/entity class that represents a hotel.
+ * </p>
+ * 
  * @author Gavin King
  * @author Dan Allen
  */
@@ -58,9 +59,11 @@
    private Integer stars;
    private BigDecimal price;
 
-   public Hotel() {}
+   public Hotel()
+   {
+   }
 
-   public Hotel(String name, String address, String city, String state, String zip, String country)
+   public Hotel(final String name, final String address, final String city, final String state, final String zip, final String country)
    {
       this.name = name;
       this.address = address;
@@ -70,6 +73,18 @@
       this.country = country;
    }
 
+   public Hotel(final int price, final int stars, final String name, final String address, final String city, final String state, final String zip, final String country)
+   {
+      this.price = new BigDecimal(price);
+      this.stars = stars;
+      this.name = name;
+      this.address = address;
+      this.city = city;
+      this.state = state;
+      this.zip = zip;
+      this.country = country;
+   }
+
    @Id
    @GeneratedValue
    public Long getId()
@@ -77,7 +92,7 @@
       return id;
    }
 
-   public void setId(Long id)
+   public void setId(final Long id)
    {
       this.id = id;
    }
@@ -89,7 +104,7 @@
       return name;
    }
 
-   public void setName(String name)
+   public void setName(final String name)
    {
       this.name = name;
    }
@@ -101,7 +116,7 @@
       return address;
    }
 
-   public void setAddress(String address)
+   public void setAddress(final String address)
    {
       this.address = address;
    }
@@ -113,7 +128,7 @@
       return city;
    }
 
-   public void setCity(String city)
+   public void setCity(final String city)
    {
       this.city = city;
    }
@@ -125,7 +140,7 @@
       return zip;
    }
 
-   public void setZip(String zip)
+   public void setZip(final String zip)
    {
       this.zip = zip;
    }
@@ -137,7 +152,7 @@
       return state;
    }
 
-   public void setState(String state)
+   public void setState(final String state)
    {
       this.state = state;
    }
@@ -149,7 +164,7 @@
       return country;
    }
 
-   public void setCountry(String country)
+   public void setCountry(final String country)
    {
       this.country = country;
    }
@@ -161,7 +176,7 @@
       return stars;
    }
 
-   public void setStars(Integer stars)
+   public void setStars(final Integer stars)
    {
       this.stars = stars;
    }
@@ -172,7 +187,7 @@
       return price;
    }
 
-   public void setPrice(BigDecimal price)
+   public void setPrice(final BigDecimal price)
    {
       this.price = price;
    }

Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/MockCredentials.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/MockCredentials.java	                        (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/MockCredentials.java	2010-06-15 18:30:09 UTC (rev 13154)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.
+ */
+package org.jboss.seam.examples.booking.security;
+
+import java.io.Serializable;
+
+import javax.enterprise.context.SessionScoped;
+import javax.inject.Named;
+
+/**
+ * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
+ * 
+ */
+ at Named("credentials")
+ at SessionScoped
+public class MockCredentials implements Serializable
+{
+   private String username;
+   private String password;
+
+   public String getUsername()
+   {
+      return username;
+   }
+
+   public void setUsername(final String username)
+   {
+      this.username = username;
+   }
+
+   public String getPassword()
+   {
+      return password;
+   }
+
+   public void setPassword(final String password)
+   {
+      this.password = password;
+   }
+}

Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/MockIdentity.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/MockIdentity.java	                        (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/MockIdentity.java	2010-06-15 18:30:09 UTC (rev 13154)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.
+ */
+package org.jboss.seam.examples.booking.security;
+
+import java.io.Serializable;
+
+import javax.enterprise.context.SessionScoped;
+import javax.faces.context.FacesContext;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.servlet.http.HttpSession;
+
+/**
+ * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
+ * 
+ */
+ at Named("identity")
+ at SessionScoped
+public class MockIdentity implements Serializable
+{
+   private boolean loggedIn;
+
+   @Inject
+   FacesContext context;
+
+   public boolean isLoggedIn()
+   {
+      return loggedIn;
+   }
+
+   public void setLoggedIn(final boolean loggedIn)
+   {
+      this.loggedIn = loggedIn;
+   }
+
+   public void login()
+   {
+      loggedIn = true;
+   }
+
+   public void logout()
+   {
+      loggedIn = true;
+      HttpSession session = (HttpSession) context.getExternalContext().getSession(true);
+      session.invalidate();
+   }
+
+}

Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/setup/ApplicationSetupBean.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/setup/ApplicationSetupBean.java	                        (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/setup/ApplicationSetupBean.java	2010-06-15 18:30:09 UTC (rev 13154)
@@ -0,0 +1,80 @@
+package org.jboss.seam.examples.booking.setup;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ejb.Stateful;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.event.Observes;
+import javax.faces.event.PostConstructApplicationEvent;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.jboss.seam.examples.booking.model.Hotel;
+import org.jboss.seam.examples.booking.model.User;
+import org.jboss.seam.international.status.Messages;
+
+/**
+ * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
+ */
+ at Stateful
+ at ApplicationScoped
+public class ApplicationSetupBean implements SetupBean
+{
+   @PersistenceContext
+   private EntityManager em;
+
+   @Inject
+   private Messages messages;
+
+   private final List<User> users = new ArrayList<User>();
+   private final List<Hotel> hotels = new ArrayList<Hotel>();
+
+   public ApplicationSetupBean()
+   {
+      users.add(new User("Dan Allen", "dan", "laurel"));
+      users.add(new User("Pete Muir", "pete", "edinburgh"));
+      users.add(new User("Lincoln Baxter III", "lincoln", "charlotte"));
+      users.add(new User("Shane", "shane", "brisbane"));
+      users.add(new User("Gavin King", "gavin", "mexico"));
+
+      hotels.add(new Hotel(129, 3, "Marriott Courtyard", "Tower Place, Buckhead", "Atlanta", "GA", "30305", "USA"));
+      hotels.add(new Hotel(84, 4, "Doubletree Atlanta-Buckhead", "3342 Peachtree Road NE", "Atlanta", "GA", "30326", "USA"));
+      hotels.add(new Hotel(289, 4, "W New York - Union Square", "201 Park Avenue South", "New York", "NY", "10003", "USA"));
+      hotels.add(new Hotel(219, 3, "W New York", "541 Lexington Avenue", "New York", "NY", "10022", "USA"));
+      hotels.add(new Hotel(250, 3, "Hotel Rouge", "1315 16th Street NW", "Washington", "DC", "20036", "USA"));
+      hotels.add(new Hotel(159, 4, "70 Park Avenue Hotel", "70 Park Avenue, 38th St", "New York", "NY", "10016", "USA"));
+      hotels.add(new Hotel(198, 4, "Parc 55", "55 Cyril Magnin Street", "San Francisco", "CA", "94102", "USA"));
+      hotels.add(new Hotel(189, 4, "Conrad Miami", "1395 Brickell Ave", "Miami", "FL", "33131", "USA"));
+      hotels.add(new Hotel(111, 4, "Grand Hyatt", "345 Stockton Street", "San Francisco", "CA", "94108", "USA"));
+      hotels.add(new Hotel(54, 1, "Super 8 Eau Claire Campus Area", "1151 W MacArthur Ave", "Eau Claire", "WI", "54701", "USA"));
+      hotels.add(new Hotel(199, 4, "San Francisco Marriott", "55 Fourth Street", "San Francisco", "CA", "94103", "USA"));
+      hotels.add(new Hotel(543, 4, "Hilton Diagonal Mar", "Passeig del Taulat 262-264", "Barcelona", "Catalunya", "08019", "ES"));
+      hotels.add(new Hotel(335, 5, "Hilton Tel Aviv", "Independence Park", "Tel Aviv", "", "63405", "IL"));
+      hotels.add(new Hotel(242, 5, "InterContinental Hotel Tokyo Bay", "1-15-2 Kaigan", "Tokyo", "Minato", "105", "JP"));
+      hotels.add(new Hotel(130, 4, "Hotel Beaulac", " Esplanade Léopold-Robert 2", "Neuchatel", "", "2000", "CH"));
+      hotels.add(new Hotel(266, 5, "Conrad Treasury Place", "130 William Street", "Brisbane", "QL", "4001", "AU"));
+      hotels.add(new Hotel(170, 4, "Ritz-Carlton Montreal", "1228 Sherbrooke St West", "Montreal", "Quebec", "H3G1H6", "CA"));
+      hotels.add(new Hotel(179, 4, "Ritz-Carlton Atlanta", "181 Peachtree St NE", "Atlanta", "GA", "30303", "USA"));
+      hotels.add(new Hotel(145, 4, "Swissotel Sydney", "68 Market Street", "Sydney", "NSW", "2000", "AU"));
+      hotels.add(new Hotel(178, 4, "Meliá White House", "Albany Street Regents Park", "London", "", "NW13UP", "GB"));
+      hotels.add(new Hotel(159, 3, "Hotel Allegro", "171 W Randolph Street", "Chicago", "IL", "60601", "USA"));
+      hotels.add(new Hotel(296, 5, "Caesars Palace", "3570 Las Vegas Blvd S", "Las Vegas", "NV", "89109", "USA"));
+      hotels.add(new Hotel(300, 4, "Mandalay Bay Resort & Casino", "3950 Las Vegas Blvd S", "Las Vegas", "NV", "89119", "USA"));
+      hotels.add(new Hotel(100, 2, "Hotel Cammerpoorte", "Nationalestraat 38-40", "Antwerp", "", "2000", "BE"));
+   }
+
+   public void init(@Observes final PostConstructApplicationEvent event)
+   {
+      for (User u : users)
+      {
+         if (em.find(User.class, u.getUsername()) == null)
+         {
+            em.persist(u);
+         }
+      }
+
+      // TODO need to persist hotels here
+   }
+}

Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/setup/SetupBean.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/setup/SetupBean.java	                        (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/setup/SetupBean.java	2010-06-15 18:30:09 UTC (rev 13154)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.
+ */
+package org.jboss.seam.examples.booking.setup;
+
+import javax.ejb.Local;
+import javax.faces.event.PostConstructApplicationEvent;
+
+/**
+ * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
+ * 
+ */
+ at Local
+public interface SetupBean
+{
+   public void init(final PostConstructApplicationEvent event);
+}

Modified: examples/trunk/booking-simplified/src/main/resources/META-INF/persistence.xml
===================================================================
--- examples/trunk/booking-simplified/src/main/resources/META-INF/persistence.xml	2010-06-15 18:26:52 UTC (rev 13153)
+++ examples/trunk/booking-simplified/src/main/resources/META-INF/persistence.xml	2010-06-15 18:30:09 UTC (rev 13154)
@@ -12,6 +12,7 @@
       <jta-data-source>java:/DefaultDS</jta-data-source>
       <jta-data-source>jdbc/__arquillian</jta-data-source>
       -->
+      <exclude-unlisted-classes>false</exclude-unlisted-classes>
       <properties>
          <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
          <property name="hibernate.show_sql" value="true"/>

Added: examples/trunk/booking-simplified/src/main/webapp/META-INF/MANIFEST.MF
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/META-INF/MANIFEST.MF	                        (rev 0)
+++ examples/trunk/booking-simplified/src/main/webapp/META-INF/MANIFEST.MF	2010-06-15 18:30:09 UTC (rev 13154)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path: 
+

Modified: examples/trunk/booking-simplified/src/main/webapp/WEB-INF/fragments/account.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/WEB-INF/fragments/account.xhtml	2010-06-15 18:26:52 UTC (rev 13153)
+++ examples/trunk/booking-simplified/src/main/webapp/WEB-INF/fragments/account.xhtml	2010-06-15 18:30:09 UTC (rev 13154)
@@ -6,7 +6,7 @@
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://http://java.sun.com/jsf/composite/components/property">
     
-   <p:display label="Username" value="#{user.username}"/>
-   <p:display label="Real name" value="#{user.name}"/>
+   <p:display label="Username" value="#{currentUser.username}"/>
+   <p:display label="Real name" value="#{currentUser.name}"/>
 
 </ui:composition>

Modified: examples/trunk/booking-simplified/src/main/webapp/WEB-INF/layout/template.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/WEB-INF/layout/template.xhtml	2010-06-15 18:26:52 UTC (rev 13153)
+++ examples/trunk/booking-simplified/src/main/webapp/WEB-INF/layout/template.xhtml	2010-06-15 18:30:09 UTC (rev 13154)
@@ -18,7 +18,7 @@
             <div id="title"><h:graphicImage value="/img/hdr.title.gif" alt="JBoss Suites: seam framework demo"/></div>
             <h:form id="menuForm">
                <div id="status">
-                  <h:outputText value="(#{user.name})" rendered="#{identity.loggedIn}" styleClass="user"/>
+                  <h:outputText value="(#{currentUser.name})" rendered="#{identity.loggedIn}" styleClass="user"/>
                   #{' '}
                   <h:link id="about" outcome="/home.xhtml" value="About"/>
                   #{' | '}

Modified: examples/trunk/booking-simplified/src/main/webapp/password.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/password.xhtml	2010-06-15 18:26:52 UTC (rev 13153)
+++ examples/trunk/booking-simplified/src/main/webapp/password.xhtml	2010-06-15 18:30:09 UTC (rev 13154)
@@ -24,7 +24,7 @@
             <fieldset>
             
                <p:edit id="password" label="Password">
-                  <h:inputSecret id="input" value="#{user.password}" redisplay="true"/>
+                  <h:inputSecret id="input" value="#{currentUser.password}" redisplay="true"/>
                </p:edit>
 
                <p:edit id="confirmPassword" label="Confirm password">



More information about the seam-commits mailing list