[seam-commits] Seam SVN: r11027 - in examples/trunk/booking: ejb-jar/src/main/java/org/jboss/seam/examples/booking/account and 6 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Thu May 28 15:15:06 EDT 2009


Author: dan.j.allen
Date: 2009-05-28 15:15:03 -0400 (Thu, 28 May 2009)
New Revision: 11027

Added:
   examples/trunk/booking/ejb-jar/src/main/resources/messages.properties
   examples/trunk/booking/war/src/main/resources/
   examples/trunk/booking/war/src/main/webapp/denied.xhtml
Modified:
   examples/trunk/booking/WORKLOG
   examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/AccountProducerBean.java
   examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/PasswordManagerBean.java
   examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/RegistrarBean.java
   examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgentBean.java
   examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistoryBean.java
   examples/trunk/booking/ejb-jar/src/main/resources/META-INF/beans.xml
   examples/trunk/booking/war/src/main/webapp/WEB-INF/web.xml
   examples/trunk/booking/war/src/main/webapp/error.xhtml
Log:
remove Faces deployment type
fix login after register
introduce resource bundle (messages) and add StatusMessages from resource bundle
add access denied page
update worklog


Modified: examples/trunk/booking/WORKLOG
===================================================================
--- examples/trunk/booking/WORKLOG	2009-05-28 19:13:06 UTC (rev 11026)
+++ examples/trunk/booking/WORKLOG	2009-05-28 19:15:03 UTC (rev 11027)
@@ -1,25 +1,21 @@
 KNOWN ISSUES
 ============
 
-(1) Ajax is not working on blur in p:edit form fields (had to disable)
-    Alert box showing "error malformedXML"
+(1) No list of workspaces
 
-(2) No list of workspaces
+(2) @AfterTransactionSuccess observer does not work
 
-(3) @AfterTransactionSuccess observer does not work
-
-(4) Ghost click first time clicking on View after results are returned
+(3) Ghost click first time clicking on View after results are returned
     Mojarra Issue #1116; ViewState is not being put in form on partial page update
 
-(5) If you visit the main.seam page before logging in, when you logging, you remain an anonymous user; the session-scoped
-    user bean is not being cleared on login. (temporary fix)
+(4) If you visit the main.seam page before logging in, when you logging, you remain an anonymous user; the session-scoped
+    user bean is not being cleared on login. (temporary fix in place, but it's a hack)
 
-(6) blank user shown after registering
+(5) would like to put messages in war/src/main/resources but loader cannot see it there at the moment
 
 TODO
 ====
 
-- secure pages (likely will use <s:restrictView require=""/>
 - add remember me from Seam identity
 - get status messages from default or resource bundle (not just hardcoded defaults)
 - demonstrate use of exception handling in JSF 2

Modified: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/AccountProducerBean.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/AccountProducerBean.java	2009-05-28 19:13:06 UTC (rev 11026)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/AccountProducerBean.java	2009-05-28 19:15:03 UTC (rev 11027)
@@ -47,7 +47,7 @@
       }
 
       log.info("Producing dummy User");
-      // TODO can't return null, but then we are not honoring the semantics of our binding type
+      // TODO can't return null because this is a scoped producer, but then we are not honoring the semantics of our binding type
       return new User();
    }
 }

Modified: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/PasswordManagerBean.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/PasswordManagerBean.java	2009-05-28 19:13:06 UTC (rev 11026)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/PasswordManagerBean.java	2009-05-28 19:15:03 UTC (rev 11027)
@@ -40,7 +40,7 @@
          // FIXME: dirty hack, can't merge a managed bean
          em.merge(new User(user.getName(), user.getUsername(), user.getPassword()));
          user.setPassword(null);
-         statusMessages.add("Password successfully updated.");
+         statusMessages.addFromResourceBundleOrDefault("account.passwordChanged", "Password successfully updated.");
          changed = true;
       }
       else
@@ -48,7 +48,8 @@
          // FIME reverting isn't going to work here
          //revertUser();
          confirmPassword = null;
-         statusMessages.addToControl(formControls.getConfirmPasswordControlId(), "Passwords do not match. Please re-type the new password.");
+         statusMessages.addToControlFromResourceBundleOrDefault(formControls.getConfirmPasswordControlId(),
+            "account.passwordsDoNotMatch", "Passwords do not match. Please re-type the new password.");
       }
    }
 

Modified: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/RegistrarBean.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/RegistrarBean.java	2009-05-28 19:13:06 UTC (rev 11026)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/RegistrarBean.java	2009-05-28 19:15:03 UTC (rev 11027)
@@ -49,9 +49,10 @@
       {
          em.persist(newUser);
          credentials.setUsername(newUser.getUsername());
-         identity.login();
+         credentials.setPassword(newUser.getPassword());
+         identity.quietLogin();
          registered = true;
-         statusMessages.add("You have been successfully registered as the user {0}!", newUser.getUsername());
+         statusMessages.addFromResourceBundleOrDefault("registration.registered", "You have been successfully registered as the user {0}!", newUser.getUsername());
       }
       else
       {
@@ -69,7 +70,7 @@
    {
       if (validationFailed || registrationInvalid)
       {
-         statusMessages.add(StatusMessage.Severity.WARN, "Invalid registration. Please correct the errors and try again.");
+         statusMessages.addFromResourceBundleOrDefault(StatusMessage.Severity.WARN, "registration.invalid", "Invalid registration. Please correct the errors and try again.");
       }
    }
 
@@ -105,7 +106,8 @@
    {
       if (!newUser.getPassword().equals(confirmPassword))
       {
-         statusMessages.addToControl(formControls.getConfirmPasswordControlId(), "Passwords do not match. Please re-type your password.");
+         statusMessages.addToControlFromResourceBundleOrDefault(formControls.getConfirmPasswordControlId(),
+            "account.passwordsDoNotMatch", "Passwords do not match. Please re-type your password.");
          confirmPassword = null;
          return false;
       }
@@ -118,7 +120,8 @@
       User existing = em.find(User.class, newUser.getUsername());
       if (existing != null)
       {
-         statusMessages.addToControl(formControls.getUsernameControlId(), "The username '{0}' is already taken. Please choose another username.", newUser.getUsername());
+         statusMessages.addToControlFromResourceBundleOrDefault(formControls.getUsernameControlId(),
+            "account.usernameTaken", "The username '{0}' is already taken. Please choose another username.", newUser.getUsername());
          return false;
       }
 

Modified: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgentBean.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgentBean.java	2009-05-28 19:13:06 UTC (rev 11026)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgentBean.java	2009-05-28 19:15:03 UTC (rev 11027)
@@ -93,7 +93,7 @@
       calendar.add(Calendar.DAY_OF_MONTH, 1);
       booking.setCheckoutDate(calendar.getTime());
 	   hotelSelection = null;
-      statusMessages.add("You've initiated a booking at {0}.", booking.getHotel().getName());
+      statusMessages.addFromResourceBundleOrDefault("booking.initiated", "You've initiated a booking at {0}.", booking.getHotel().getName());
    }
 
    public void validateBooking()
@@ -102,12 +102,12 @@
       calendar.add(Calendar.DAY_OF_MONTH, -1);
       if (booking.getCheckinDate().before(calendar.getTime()))
       {
-         statusMessages.addToControl(formControls.getCheckinDateControlId(), "Check in date must be a future date");
+         statusMessages.addToControlFromResourceBundleOrDefault(formControls.getCheckinDateControlId(), "booking.checkInNotFutureDate", "Check in date must be a future date");
          bookingValid = false;
       }
       else if (!booking.getCheckinDate().before(booking.getCheckoutDate()))
       {
-         statusMessages.addToControl(formControls.getCheckoutDateControlId(), "Check out date must be after check in date");
+         statusMessages.addToControlFromResourceBundleOrDefault(formControls.getCheckoutDateControlId(), "booking.checkOutBeforeCheckIn", "Check out date must be after check in date");
          bookingValid = false;
       }
       else
@@ -123,7 +123,7 @@
       //bookingConfirmedEvent.fire(new BookingEvent(booking));
       manager.fireEvent(new BookingEvent(booking), new AnnotationLiteral<Confirmed>() {});
       log.info("New booking at the {0} confirmed for {1}", booking.getHotel().getName(), booking.getUser().getName());
-      statusMessages.add("You're booked!");
+      statusMessages.addFromResourceBundleOrDefault("booking.confirmed", "Booking confirmed.");
       conversation.end();
    }
 

Modified: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistoryBean.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistoryBean.java	2009-05-28 19:13:06 UTC (rev 11026)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistoryBean.java	2009-05-28 19:15:03 UTC (rev 11027)
@@ -66,11 +66,11 @@
       if (booking != null)
       {
          em.remove(booking);
-         statusMessages.add("The booking at the {0} on {1,date} has been canceled.", selectedBooking.getHotel().getName(), selectedBooking.getCheckinDate());
+         statusMessages.addFromResourceBundleOrDefault("booking.canceled", "The booking at the {0} on {1,date} has been canceled.", selectedBooking.getHotel().getName(), selectedBooking.getCheckinDate());
       }
       else
       {
-         statusMessages.add("Our records indicate that the booking you selected has already been canceled.");
+         statusMessages.addFromResourceBundleOrDefault("booking.doesNotExist", "Our records indicate that the booking you selected has already been canceled.");
       }
 
       bookingsForUser.remove(selectedBooking);

Modified: examples/trunk/booking/ejb-jar/src/main/resources/META-INF/beans.xml
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/resources/META-INF/beans.xml	2009-05-28 19:13:06 UTC (rev 11026)
+++ examples/trunk/booking/ejb-jar/src/main/resources/META-INF/beans.xml	2009-05-28 19:15:03 UTC (rev 11027)
@@ -1,8 +0,0 @@
-<Beans xmlns="urn:java:ee"
-   xmlns:faces="urn:java:org.jboss.seam.faces">
-   <Deploy>
-      <Standard/>
-      <Production/>
-      <faces:Faces/>
-   </Deploy>
-</Beans>

Added: examples/trunk/booking/ejb-jar/src/main/resources/messages.properties
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/resources/messages.properties	                        (rev 0)
+++ examples/trunk/booking/ejb-jar/src/main/resources/messages.properties	2009-05-28 19:15:03 UTC (rev 11027)
@@ -0,0 +1,11 @@
+booking.initiated=You've initiated a booking at {0}.
+booking.checkInNotFutureDate=Check in date must be a future date.
+booking.checkOutBeforeCheckIn=Check out date must be after check in date.
+booking.confirmed=You're booked!
+booking.canceled=The booking at the {0} on {1,date} has been canceled.
+booking.doesNotExist=Our records indicate that the booking you selected has already been canceled.
+account.passwordChanged=Password successfully updated.
+account.passwordsDoNotMatch=Passwords do not match. Please re-type the new password.
+account.usernameTaken=The username '{0}' is already taken. Please choose another username.
+registration.registered=You have been successfully registered as the user {0}!
+registration.invalid=Invalid registration. Please correct the errors and try again.

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-28 19:13:06 UTC (rev 11026)
+++ examples/trunk/booking/war/src/main/webapp/WEB-INF/web.xml	2009-05-28 19:15:03 UTC (rev 11027)
@@ -64,7 +64,7 @@
    
    <error-page>
       <exception-type>org.jboss.seam.security.AuthorizationException</exception-type>
-      <location>/error.seam</location>
+      <location>/denied.seam</location>
    </error-page>
 
    <error-page>

Added: examples/trunk/booking/war/src/main/webapp/denied.xhtml
===================================================================
--- examples/trunk/booking/war/src/main/webapp/denied.xhtml	                        (rev 0)
+++ examples/trunk/booking/war/src/main/webapp/denied.xhtml	2009-05-28 19:15:03 UTC (rev 11027)
@@ -0,0 +1,23 @@
+<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+   xmlns:ui="http://java.sun.com/jsf/facelets"
+   xmlns:f="http://java.sun.com/jsf/core"
+   xmlns:h="http://java.sun.com/jsf/html"
+   xmlns:p="http://http://java.sun.com/jsf/composite/components/property"
+   template="/WEB-INF/layout/template.xhtml">
+
+   <ui:define name="content">
+
+      <div class="section">
+         <h1>Access Denied</h1>
+      </div>
+
+      <div class="section">
+         <p>You are not authorized to perform the requested action.</p>
+         <p>#{facesContext.externalContext.requestMap['javax.servlet.error.message']}</p>
+      </div>
+
+   </ui:define>
+
+</ui:composition>

Modified: examples/trunk/booking/war/src/main/webapp/error.xhtml
===================================================================
--- examples/trunk/booking/war/src/main/webapp/error.xhtml	2009-05-28 19:13:06 UTC (rev 11026)
+++ examples/trunk/booking/war/src/main/webapp/error.xhtml	2009-05-28 19:15:03 UTC (rev 11027)
@@ -14,7 +14,7 @@
       </div>
 
       <div class="section">
-         <p>You are not authorized to perform the requested action.</p>
+         <p>An unexpected error has occurred.</p>
          <p>#{facesContext.externalContext.requestMap['javax.servlet.error.message']}</p>
       </div>
 




More information about the seam-commits mailing list