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

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Thu Jun 17 14:55:45 EDT 2010


Author: dan.j.allen
Date: 2010-06-17 14:55:44 -0400 (Thu, 17 Jun 2010)
New Revision: 13219

Added:
   examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ConfirmedLiteral.java
   examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationNotifier.java
   examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/i18n/
   examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/i18n/DefaultBundleKey.java
   examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Credentials.java
Removed:
   examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/Bundles.java
   examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationNotifier.java
   examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationNotifierBean.java
   examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Credentials.java
   examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/MockCredentials.java
Modified:
   examples/trunk/booking-simplified/
   examples/trunk/booking-simplified/pom.xml
   examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Authenticated.java
   examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/ConfirmPasswordValidator.java
   examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/CurrentPasswordValidator.java
   examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManager.java
   examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Registrar.java
   examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgent.java
   examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistory.java
   examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationDateRangeValidator.java
   examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Authenticator.java
   examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Identity.java
   examples/trunk/booking-simplified/src/main/java/org/jboss/seam/faces/component/UIInputContainer.java
Log:
switch to DefaultBundleKey
cleanups



Property changes on: examples/trunk/booking-simplified
___________________________________________________________________
Name: svn:ignore
   - .settings
.classpath
.project
faces-config.NavData
nbactions*
target
.pom.xml.swp

   + .settings
.classpath
.project
faces-config.NavData
nbactions*
target


Modified: examples/trunk/booking-simplified/pom.xml
===================================================================
--- examples/trunk/booking-simplified/pom.xml	2010-06-17 17:41:30 UTC (rev 13218)
+++ examples/trunk/booking-simplified/pom.xml	2010-06-17 18:55:44 UTC (rev 13219)
@@ -92,6 +92,19 @@
       </dependency>
 
       <dependency>
+         <groupId>org.jboss.seam.jms</groupId>
+         <artifactId>seam-jms-api</artifactId>
+         <version>3.0.0-SNAPSHOT</version>
+      </dependency>
+
+      <dependency>
+         <groupId>org.jboss.seam.jms</groupId>
+         <artifactId>seam-jms</artifactId>
+         <version>3.0.0-SNAPSHOT</version>
+         <scope>runtime</scope>
+      </dependency>
+
+      <dependency>
          <groupId>com.ocpsoft</groupId>
          <artifactId>prettyfaces-jsf2</artifactId>
          <version>3.0.1</version>

Deleted: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/Bundles.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/Bundles.java	2010-06-17 17:41:30 UTC (rev 13218)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/Bundles.java	2010-06-17 18:55:44 UTC (rev 13219)
@@ -1,30 +0,0 @@
-/* 
- * 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;
-
-/**
- * @author Dan Allen
- */
-public interface Bundles
-{
-   static final String MESSAGES = "messages";
-}

Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Authenticated.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Authenticated.java	2010-06-17 17:41:30 UTC (rev 13218)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Authenticated.java	2010-06-17 18:55:44 UTC (rev 13219)
@@ -28,7 +28,6 @@
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
 
 import java.lang.annotation.Documented;
-import java.lang.annotation.Inherited;
 import java.lang.annotation.Retention;
 import java.lang.annotation.Target;
 

Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/ConfirmPasswordValidator.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/ConfirmPasswordValidator.java	2010-06-17 17:41:30 UTC (rev 13218)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/ConfirmPasswordValidator.java	2010-06-17 18:55:44 UTC (rev 13219)
@@ -30,15 +30,14 @@
 import javax.faces.validator.ValidatorException;
 import javax.inject.Inject;
 
-import org.jboss.seam.examples.booking.Bundles;
+import org.jboss.seam.examples.booking.i18n.DefaultBundleKey;
 import org.jboss.seam.faces.validation.InputField;
-import org.jboss.seam.international.status.builder.BundleKey;
 import org.jboss.seam.international.status.builder.BundleTemplateMessage;
 
 /**
  * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
  */
- at FacesValidator(value = "confirmPasswordValidator")
+ at FacesValidator("confirmPasswordValidator")
 public class ConfirmPasswordValidator implements Validator
 {
    @Inject
@@ -58,7 +57,7 @@
       {
          throw new ValidatorException(
                   new FacesMessage(messageBuilder.get().text(
-                           new BundleKey(Bundles.MESSAGES, "account.passwordsDoNotMatch"))
+                           new DefaultBundleKey("account.passwordsDoNotMatch"))
                            .build().getText()));
       }
    }

Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/CurrentPasswordValidator.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/CurrentPasswordValidator.java	2010-06-17 17:41:30 UTC (rev 13218)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/CurrentPasswordValidator.java	2010-06-17 18:55:44 UTC (rev 13219)
@@ -9,15 +9,14 @@
 import javax.faces.validator.ValidatorException;
 import javax.inject.Inject;
 
-import org.jboss.seam.examples.booking.Bundles;
+import org.jboss.seam.examples.booking.i18n.DefaultBundleKey;
 import org.jboss.seam.examples.booking.model.User;
-import org.jboss.seam.international.status.builder.BundleKey;
 import org.jboss.seam.international.status.builder.BundleTemplateMessage;
 
 /**
  * @author Dan Allen
  */
- at FacesValidator(value = "currentPasswordValidator")
+ at FacesValidator("currentPasswordValidator")
 public class CurrentPasswordValidator implements Validator
 {
    @Inject
@@ -37,7 +36,7 @@
           * This is an ugly way to put i18n in FacesMessages: https://jira.jboss.org/browse/SEAMFACES-24
           */
          throw new ValidatorException(new FacesMessage(msg.get().text(
-                  new BundleKey(Bundles.MESSAGES, "account.passwordNotConfirmed")).build()
+                  new DefaultBundleKey("account.passwordNotConfirmed")).build()
                   .getText()));
       }
    }

Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManager.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManager.java	2010-06-17 17:41:30 UTC (rev 13218)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManager.java	2010-06-17 18:55:44 UTC (rev 13219)
@@ -22,25 +22,22 @@
 package org.jboss.seam.examples.booking.account;
 
 import javax.ejb.Stateful;
-import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Model;
 import javax.inject.Inject;
-import javax.inject.Named;
 import javax.persistence.EntityManager;
 import javax.persistence.PersistenceContext;
 import javax.validation.constraints.NotNull;
 import javax.validation.constraints.Size;
 
-import org.jboss.seam.examples.booking.Bundles;
+import org.jboss.seam.examples.booking.i18n.DefaultBundleKey;
 import org.jboss.seam.examples.booking.model.User;
 import org.jboss.seam.international.status.Messages;
-import org.jboss.seam.international.status.builder.BundleKey;
 
 /**
  * @author Dan Allen
  */
- at Named
 @Stateful
- at RequestScoped
+ at Model
 public class PasswordManager
 {
    @PersistenceContext
@@ -62,7 +59,7 @@
    public void changePassword()
    {
       em.merge(user);
-      messages.info(new BundleKey(Bundles.MESSAGES, "account.passwordChanged")).textDefault("Password successfully updated.");
+      messages.info(new DefaultBundleKey("account.passwordChanged")).textDefault("Password successfully updated.");
       changed = true;
    }
 

Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Registrar.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Registrar.java	2010-06-17 17:41:30 UTC (rev 13218)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Registrar.java	2010-06-17 18:55:44 UTC (rev 13219)
@@ -23,6 +23,7 @@
 
 import javax.ejb.Stateful;
 import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Model;
 import javax.enterprise.inject.Produces;
 import javax.faces.component.UIInput;
 import javax.faces.context.FacesContext;
@@ -33,7 +34,7 @@
 import javax.validation.constraints.NotNull;
 import javax.validation.constraints.Size;
 
-import org.jboss.seam.examples.booking.Bundles;
+import org.jboss.seam.examples.booking.i18n.DefaultBundleKey;
 import org.jboss.seam.examples.booking.model.User;
 import org.jboss.seam.international.status.Messages;
 import org.jboss.seam.international.status.builder.BundleKey;
@@ -41,9 +42,8 @@
 /**
  * @author Dan Allen
  */
- at Named
 @Stateful
- at RequestScoped
+ at Model
 public class Registrar
 {
    @PersistenceContext
@@ -74,7 +74,7 @@
          registered = true;
          em.persist(newUser);
 
-         messages.info(new BundleKey(Bundles.MESSAGES, "registration.registered")).textDefault("You have been successfully registered as the user {0}! You can now login.").textParams(newUser.getUsername());
+         messages.info(new DefaultBundleKey("registration.registered")).textDefault("You have been successfully registered as the user {0}! You can now login.").textParams(newUser.getUsername());
       }
       else
       {
@@ -101,7 +101,7 @@
    {
       if (facesContext.isValidationFailed() || registrationInvalid)
       {
-         messages.warn(new BundleKey(Bundles.MESSAGES, "registration.invalid")).textDefault("Invalid registration. Please correct the errors and try again.");
+         messages.warn(new DefaultBundleKey("registration.invalid")).textDefault("Invalid registration. Please correct the errors and try again.");
       }
    }
 

Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgent.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgent.java	2010-06-17 17:41:30 UTC (rev 13218)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgent.java	2010-06-17 18:55:44 UTC (rev 13219)
@@ -36,7 +36,6 @@
 import javax.persistence.EntityManager;
 import javax.persistence.PersistenceContext;
 
-import org.jboss.seam.examples.booking.Bundles;
 import org.jboss.seam.examples.booking.account.Authenticated;
 import org.jboss.seam.examples.booking.model.Booking;
 import org.jboss.seam.examples.booking.model.Hotel;
@@ -44,15 +43,18 @@
 import org.jboss.seam.faces.context.conversation.Begin;
 import org.jboss.seam.faces.context.conversation.End;
 import org.jboss.seam.international.status.Messages;
-import org.jboss.seam.international.status.builder.BundleKey;
 import org.jboss.seam.international.status.builder.TemplateMessage;
 import org.slf4j.Logger;
 
 import com.ocpsoft.pretty.time.PrettyTime;
+import org.jboss.seam.examples.booking.i18n.DefaultBundleKey;
 
+/**
+ * @author Dan Allen
+ */
+ at Named
 @Stateful
 @ConversationScoped
- at Named
 public class BookingAgent
 {
    @Inject
@@ -101,7 +103,7 @@
       // for demo convenience
       booking.setCreditCardNumber("1111222233334444");
 
-      messages.info(new BundleKey(Bundles.MESSAGES, "booking.initiated")).textDefault("You've initiated a booking at the {0}.").textParams(booking.getHotel().getName());
+      messages.info(new DefaultBundleKey("booking.initiated")).textDefault("You've initiated a booking at the {0}.").textParams(booking.getHotel().getName());
    }
 
    public void validate()
@@ -127,7 +129,7 @@
    public void onBookingComplete(@Observes(during = TransactionPhase.AFTER_SUCCESS) @Confirmed final Booking booking)
    {
       log.info(messageBuilder.get().text("New booking at the {0} confirmed for {1}").textParams(booking.getHotel().getName(), booking.getUser().getName()).build().getText());
-      messages.info(new BundleKey(Bundles.MESSAGES, "booking.confirmed")).textDefault("You're booked to stay at the {0} {1}.").textParams(booking.getHotel().getName(), new PrettyTime().format(booking.getCheckinDate()));
+      messages.info(new DefaultBundleKey("booking.confirmed")).textDefault("You're booked to stay at the {0} {1}.").textParams(booking.getHotel().getName(), new PrettyTime().format(booking.getCheckinDate()));
    }
 
    @Produces

Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistory.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistory.java	2010-06-17 17:41:30 UTC (rev 13218)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistory.java	2010-06-17 18:55:44 UTC (rev 13219)
@@ -40,16 +40,15 @@
 import javax.persistence.criteria.CriteriaQuery;
 import javax.persistence.criteria.JoinType;
 import javax.persistence.criteria.Root;
-import org.jboss.seam.examples.booking.Bundles;
 
 import org.jboss.seam.examples.booking.account.Authenticated;
+import org.jboss.seam.examples.booking.i18n.DefaultBundleKey;
 import org.jboss.seam.examples.booking.model.Booking;
 import org.jboss.seam.examples.booking.model.Booking_;
 import org.jboss.seam.examples.booking.model.User;
 import org.jboss.seam.examples.booking.model.User_;
 import org.jboss.seam.examples.booking.security.Identity;
 import org.jboss.seam.international.status.Messages;
-import org.jboss.seam.international.status.builder.BundleKey;
 import org.slf4j.Logger;
 
 /**
@@ -111,14 +110,14 @@
       if (booking != null)
       {
          em.remove(booking);
-         messages.info(new BundleKey(Bundles.MESSAGES, "booking.canceled"))
+         messages.info(new DefaultBundleKey("booking.canceled"))
                .textDefault("The booking at the {0} on {1} has been canceled.")
                .textParams(selectedBooking.getHotel().getName(),
                      DateFormat.getDateInstance(SimpleDateFormat.MEDIUM).format(selectedBooking.getCheckinDate()));
       }
       else
       {
-         messages.info(new BundleKey(Bundles.MESSAGES, "booking.doesNotExist"))
+         messages.info(new DefaultBundleKey("booking.doesNotExist"))
                .textDefault("Our records indicate that the booking you selected has already been canceled.");
       }
 

Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ConfirmedLiteral.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ConfirmedLiteral.java	                        (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ConfirmedLiteral.java	2010-06-17 18:55:44 UTC (rev 13219)
@@ -0,0 +1,8 @@
+package org.jboss.seam.examples.booking.booking;
+
+import javax.enterprise.util.AnnotationLiteral;
+
+public class ConfirmedLiteral extends AnnotationLiteral<Confirmed> implements Confirmed
+{
+   public static final ConfirmedLiteral INSTANCE = new ConfirmedLiteral();
+}

Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationDateRangeValidator.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationDateRangeValidator.java	2010-06-17 17:41:30 UTC (rev 13218)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationDateRangeValidator.java	2010-06-17 18:55:44 UTC (rev 13219)
@@ -35,9 +35,8 @@
 import javax.faces.validator.ValidatorException;
 import javax.inject.Inject;
 
-import org.jboss.seam.examples.booking.Bundles;
+import org.jboss.seam.examples.booking.i18n.DefaultBundleKey;
 import org.jboss.seam.faces.validation.InputField;
-import org.jboss.seam.international.status.builder.BundleKey;
 import org.jboss.seam.international.status.builder.BundleTemplateMessage;
 
 /**
@@ -67,14 +66,14 @@
       calendar.add(Calendar.DAY_OF_MONTH, -1);
       if (beginDate.before(calendar.getTime()))
       {
-         String message = messageBuilder.get().text(new BundleKey(Bundles.MESSAGES, "booking.checkInNotFutureDate"))
+         String message = messageBuilder.get().text(new DefaultBundleKey("booking.checkInNotFutureDate"))
          // FIXME the component should come through via injection
                .targets(fieldMap.get("beginDate").getClientId()).build().getText();
          throw new ValidatorException(new FacesMessage(message));
       }
       else if (!beginDate.before(endDate))
       {
-         String message = messageBuilder.get().text(new BundleKey(Bundles.MESSAGES, "booking.checkOutBeforeCheckIn"))
+         String message = messageBuilder.get().text(new DefaultBundleKey("booking.checkOutBeforeCheckIn"))
          // FIXME the component should come through via injection
                .targets(fieldMap.get("endDate").getClientId()).build().getText();
          throw new ValidatorException(new FacesMessage(message));

Deleted: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationNotifier.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationNotifier.java	2010-06-17 17:41:30 UTC (rev 13218)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationNotifier.java	2010-06-17 18:55:44 UTC (rev 13219)
@@ -1,8 +0,0 @@
-package org.jboss.seam.examples.booking.booking;
-
-import org.jboss.seam.examples.booking.model.Booking;
-
-public interface ReservationNotifier
-{
-   void onBookingComplete(Booking booking);
-}

Copied: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationNotifier.java (from rev 13215, examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationNotifierBean.java)
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationNotifier.java	                        (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationNotifier.java	2010-06-17 18:55:44 UTC (rev 13219)
@@ -0,0 +1,34 @@
+package org.jboss.seam.examples.booking.booking;
+
+import javax.ejb.ActivationConfigProperty;
+import javax.ejb.MessageDriven;
+import javax.inject.Inject;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.ObjectMessage;
+import org.jboss.seam.examples.booking.model.Booking;
+import org.slf4j.Logger;
+
+//@MessageDriven(activationConfig = {
+//      @ActivationConfigProperty(propertyName = "destination", propertyValue = "jms/BookingTopic"),
+//      @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic")
+//})
+public class ReservationNotifier implements MessageListener
+{
+   @Inject
+   private Logger log;
+
+   public void onMessage(Message message)
+   {
+      try
+      {
+         Booking booking = (Booking) ((ObjectMessage) message).getObject();
+         log.info("In a real-world application, send e-mail containing reservation information to " + booking.getUser().getEmailWithName());
+      } catch (JMSException ex)
+      {
+         log.error("Error reading booking from topic");
+      }
+   }
+  
+}
\ No newline at end of file

Deleted: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationNotifierBean.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationNotifierBean.java	2010-06-17 17:41:30 UTC (rev 13218)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationNotifierBean.java	2010-06-17 18:55:44 UTC (rev 13219)
@@ -1,19 +0,0 @@
-package org.jboss.seam.examples.booking.booking;
-
-import javax.enterprise.event.Observes;
-import javax.enterprise.event.TransactionPhase;
-import javax.inject.Inject;
-import org.jboss.seam.examples.booking.model.Booking;
-import org.slf4j.Logger;
-
-public class ReservationNotifierBean implements ReservationNotifier
-{
-   @Inject
-   private Logger log;
-
-   public void onBookingComplete(@Observes(during = TransactionPhase.AFTER_SUCCESS)
-         @Confirmed final Booking booking)
-   {
-      log.info("In a real-world application, send e-mail containing reservation information to " + booking.getUser().getEmailWithName());
-   }
-}
\ No newline at end of file

Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/i18n/DefaultBundleKey.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/i18n/DefaultBundleKey.java	                        (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/i18n/DefaultBundleKey.java	2010-06-17 18:55:44 UTC (rev 13219)
@@ -0,0 +1,16 @@
+package org.jboss.seam.examples.booking.i18n;
+
+import org.jboss.seam.international.status.builder.BundleKey;
+
+/**
+ * @author Dan Allen
+ */
+public class DefaultBundleKey extends BundleKey {
+
+   public static final String DEFAULT_BUNDLE_NAME = "messages";
+
+   public DefaultBundleKey(String key)
+   {
+      super(DEFAULT_BUNDLE_NAME, key);
+   }
+}

Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Authenticator.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Authenticator.java	2010-06-17 17:41:30 UTC (rev 13218)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Authenticator.java	2010-06-17 18:55:44 UTC (rev 13219)
@@ -27,11 +27,10 @@
 import javax.persistence.EntityManager;
 import javax.persistence.PersistenceContext;
 
-import org.jboss.seam.examples.booking.Bundles;
 import org.jboss.seam.examples.booking.account.Authenticated;
+import org.jboss.seam.examples.booking.i18n.DefaultBundleKey;
 import org.jboss.seam.examples.booking.model.User;
 import org.jboss.seam.international.status.Messages;
-import org.jboss.seam.international.status.builder.BundleKey;
 import org.slf4j.Logger;
 
 /**
@@ -64,7 +63,7 @@
       log.info("Logging in " + credentials.getUsername());
       if ((credentials.getUsername() == null) || (credentials.getPassword() == null))
       {
-         messages.info(new BundleKey(Bundles.MESSAGES, "identity.loginFailed"));
+         messages.info(new DefaultBundleKey("identity.loginFailed"));
          return false;
       }
 
@@ -72,12 +71,12 @@
       if ((user != null) && user.getPassword().equals(credentials.getPassword()))
       {
          loginEventSrc.fire(user);
-         messages.info(new BundleKey(Bundles.MESSAGES, "identity.loggedIn"), user.getName());
+         messages.info(new DefaultBundleKey("identity.loggedIn"), user.getName());
          return true;
       }
       else
       {
-         messages.info(new BundleKey(Bundles.MESSAGES, "identity.loginFailed"));
+         messages.info(new DefaultBundleKey("identity.loginFailed"));
          return false;
       }
    }

Deleted: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Credentials.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Credentials.java	2010-06-17 17:41:30 UTC (rev 13218)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Credentials.java	2010-06-17 18:55:44 UTC (rev 13219)
@@ -1,29 +0,0 @@
-/* 
- * 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;
-
-public interface Credentials {
-   String getUsername();
-   void setUsername(String username);
-   String getPassword();
-   void setPassword(String password);
-}

Copied: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Credentials.java (from rev 13218, 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/Credentials.java	                        (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Credentials.java	2010-06-17 18:55:44 UTC (rev 13219)
@@ -0,0 +1,58 @@
+/* 
+ * 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
+ at SessionScoped
+public class Credentials 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;
+   }
+}

Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Identity.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Identity.java	2010-06-17 17:41:30 UTC (rev 13218)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Identity.java	2010-06-17 18:55:44 UTC (rev 13219)
@@ -32,7 +32,7 @@
 /**
  * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
  */
- at Named("identity")
+ at Named
 @SessionScoped
 public class Identity implements Serializable
 {

Deleted: 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	2010-06-17 17:41:30 UTC (rev 13218)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/MockCredentials.java	2010-06-17 18:55:44 UTC (rev 13219)
@@ -1,58 +0,0 @@
-/* 
- * 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 Credentials, 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;
-   }
-}

Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/faces/component/UIInputContainer.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/faces/component/UIInputContainer.java	2010-06-17 17:41:30 UTC (rev 13218)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/faces/component/UIInputContainer.java	2010-06-17 18:55:44 UTC (rev 13219)
@@ -182,6 +182,17 @@
       return "enclose";
    }
 
+   /**
+    * The name of the composite component attribute that indicates whether
+    * the AjaxBehavior should be added to inputs in this container and
+    * which event to fire on. If the value is default, then the default
+    * event for the input component will be used.
+    */
+   public String getAjaxAttributeName()
+   {
+      return "ajax";
+   }
+
    public String getContainerElementName()
    {
       return "div";
@@ -457,7 +468,7 @@
       }
    }
 
-   public static class InputContainerElements
+   public class InputContainerElements
    {
       private String containerId;
       private Map<String, Object> attributes;
@@ -492,15 +503,20 @@
       public void registerInput(final EditableValueHolder input, final Validator validator, final FacesContext context)
       {
          inputs.add(input);
-         if (Boolean.TRUE.equals(attributes.get("ajax")))
+         UIInput inputc = (UIInput) input;
+         String ajaxEvent = (String) attributes.get(getAjaxAttributeName());
+         if (ajaxEvent != null && (ajaxEvent.equalsIgnoreCase("default")))
          {
-            UIInput inputc = (UIInput) input;
+            ajaxEvent = inputc.getDefaultEventName();
+         }
+         if (ajaxEvent != null)
+         {
             Map<String, List<ClientBehavior>> behaviors = inputc.getClientBehaviors();
-            if (!behaviors.containsKey("blur"))
+            if (!behaviors.containsKey(ajaxEvent))
             {
                AjaxBehavior ajax = new AjaxBehavior();
                ajax.setRender(Arrays.asList(containerId));
-               inputc.addClientBehavior("blur", ajax);
+               inputc.addClientBehavior(ajaxEvent.toLowerCase(), ajax);
             }
          }
          if (input.isRequired() || isRequiredByConstraint(input, validator, context))



More information about the seam-commits mailing list