Seam SVN: r10751 - examples/trunk/booking.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-05-02 01:36:05 -0400 (Sat, 02 May 2009)
New Revision: 10751
Modified:
examples/trunk/booking/pom.xml
Log:
reexplode command was wrong
Modified: examples/trunk/booking/pom.xml
===================================================================
--- examples/trunk/booking/pom.xml 2009-05-02 00:24:13 UTC (rev 10750)
+++ examples/trunk/booking/pom.xml 2009-05-02 05:36:05 UTC (rev 10751)
@@ -61,7 +61,7 @@
<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,explode</reexplode>
+ <reexplode>package -o -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>
16 years, 8 months
Seam SVN: r10750 - examples/trunk/booking.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-05-01 20:24:13 -0400 (Fri, 01 May 2009)
New Revision: 10750
Modified:
examples/trunk/booking/pom.xml
examples/trunk/booking/readme.txt
Log:
add maven-cli-plugin
document maven-cli-plugin
Modified: examples/trunk/booking/pom.xml
===================================================================
--- examples/trunk/booking/pom.xml 2009-05-02 00:23:53 UTC (rev 10749)
+++ examples/trunk/booking/pom.xml 2009-05-02 00:24:13 UTC (rev 10750)
@@ -46,6 +46,33 @@
</plugins>
</pluginManagement>
+
+ <plugins>
+
+ <plugin>
+ <groupId>org.twdata.maven</groupId>
+ <artifactId>maven-cli-plugin</artifactId>
+ <version>0.6.3.CR1</version> <!-- TODO move to version-matrix -->
+ <configuration>
+ <!-- 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,explode</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>
+
+ </plugins>
</build>
<properties>
Modified: examples/trunk/booking/readme.txt
===================================================================
--- examples/trunk/booking/readme.txt 2009-05-02 00:23:53 UTC (rev 10749)
+++ examples/trunk/booking/readme.txt 2009-05-02 00:24:13 UTC (rev 10750)
@@ -2,18 +2,18 @@
================================
This example demonstrates the use of Seam 3 in a Java EE 6 environment (or a
-Java EE 5 environment enhanced with JSR-299 [Web Beans] and JSF 2.0).
-Contextual state management and dependency injection are handled by JSR-299.
-Transaction and persistence context management is handled by the EJB 3
-container. Validation of input fields is handled by Bean Validation.
+Java EE 5 environment enhanced with JSR-299 [Web Beans], JSF 2.0 and Bean
+Validation). Contextual state management and dependency injection are handled
+by JSR-299. Transaction and persistence context management is handled by the
+EJB 3 container. Validation of input fields is handled by Bean Validation.
= Prerequisites
Please consult the Web Beans reference documentation for instructions on how to
deploy the Web Bean implementation to JBoss AS 5. To upgrade the JSF libraries
to JSF 2.0, go to the Seam jsf-updater-tool module and follow the instructions
-there. You will also need to have Bean Validation installed in the container
-(or added to the classpath) in order for UI validation to work. Installing Bean
+there. You also need to have Bean Validation installed in the container (or
+added to the classpath) in order for UI validation to work. Installing Bean
Validation is as simple as putting the JARs in the library directory of the
application server.
@@ -26,14 +26,62 @@
Now you're ready to deploy.
-= Deploying a packaged archive to JBoss AS
+= Pointing Maven at your JBoss AS installation
First, set the JBOSS_HOME environment variable to the location of a JBoss AS 5
installation and start the server. You can optionally set the jboss.home Maven
-property in a settings.xml file. Maven assumes JBoss AS is running on port
-8080. (This can be changed in the plugin configuration). Once that's setup, you
-can deploy the application to JBoss AS via JMX by executing this command:
+property in an active profile defined in the $HOME/.m2/settings.xml file.
+Maven assumes JBoss AS is running on port 8080. (This can be changed in the
+plugin configuration). Once that's setup, you can deploy the application to
+JBoss AS using Maven.
+
+= Deploying an packaged or exploded archive to JBoss AS (the wicked fast way)
+
+Since this build is based on Maven 2, you're probably thinking you'll need to
+take a stroll to the kitchen for coffee while you wait for the build to run.
+Well, you better have your coffee ready because this build is fast...and easy!
+
+The secret? The Maven 2 CLI plugin: http://github.com/mrdon/maven-cli-plugin.
+This plugin gives you a command console to execute maven goals and plugins.
+Even better, it supports aliases, so no more having to type long Maven commands
+with switches and properties. Here's how to get started.
+
+First, rev up the command console:
+
+ mvn cli:execute-phase
+
+You'll be presented with a prompt:
+
+maven2>
+
+At the prompt, you can type any of the following commands (a description is
+provide for each command, but don't type that of course):
+
+explode -> deploy as an exploded archive to JBoss AS)
+deploy -> deploy as a packaged archive to JBoss AS
+undeploy -> undeploy the exploded or packaged archive from JBoss AS
+restart -> restart the exploded or packaged archive deployed to JBoss AS
+reexplode -> undeploy then explode
+
+You can prefix any command with "clean" if you want to do a clean build:
+
+maven2> clean explode
+
+Leave the console running and enjoy extremely fast deployments ;)
+
+But fast isn't for all of us.
+
+= Deploying a packaged archive to JBoss AS (the Slowskys' way)
+
+Why work fast when you can work slow? Perhaps your boss is annoying you and you
+want to irritate him with long builds. Or maybe you just fear speed. If that's
+the case, this section is for you (or if you just want to know what all those
+commands are doing above).
+
+Putting JBOSS_HOME aside for the moment, you can deploy the application to
+JBoss AS via JMX by executing this command:
+
mvn -o -f seam-booking-ear/pom.xml jboss:deploy
You can undeploy the application via JMX using this command:
@@ -49,9 +97,9 @@
mvn -o -f seam-booking-ear/pom.xml jboss:harddeploy
-For ease of development, you probably want to use an exploded archive instead.
+But likely during development, you're only interested in exploded archives.
-= Deploying an exploded archive to JBoss AS
+= Deploying a packaged archive to JBoss AS (the Slowskys' way)
It's much better to use the antrun plugin over the jboss plugin since it's
smarter about what it copies to the server. The antrun plugin is bound to the
@@ -78,9 +126,10 @@
mvn -o package -Pundeploy,explode
Note that the -o puts Maven in offline mode so that it doesn't perform time
-consuming update checks.
+consuming update checks. The -o flag is included in the aliases configured for
+the Maven CLI plugin documented above.
-= Highlights
+= Example highlights
- 3 module Maven 2 reactor project (ejb-jar, war, ear)
- establishes a standard for Seam 3 examples
16 years, 8 months
Seam SVN: r10749 - examples/trunk/booking/ear.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-05-01 20:23:53 -0400 (Fri, 01 May 2009)
New Revision: 10749
Modified:
examples/trunk/booking/ear/pom.xml
Log:
support restart of packaged archive
set jboss home according to jboss.home Maven property (indirectly JBOSS_HOME)
Modified: examples/trunk/booking/ear/pom.xml
===================================================================
--- examples/trunk/booking/ear/pom.xml 2009-05-02 00:22:24 UTC (rev 10748)
+++ examples/trunk/booking/ear/pom.xml 2009-05-02 00:23:53 UTC (rev 10749)
@@ -20,6 +20,14 @@
<plugins>
<plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jboss-maven-plugin</artifactId>
+ <configuration>
+ <jbossHome>${jboss.home}</jbossHome>
+ </configuration>
+ </plugin>
+
+ <plugin>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
<defaultJavaBundleDir>lib</defaultJavaBundleDir>
@@ -143,10 +151,12 @@
<property name="deploy.dir" value="${jboss.home}/server/${jboss.domain}/deploy"/>
<property name="ear.archive.name" value="${project.build.finalName}.ear"/>
<property name="ear.deploy.dir" value="${deploy.dir}/${ear.archive.name}"/>
- <available property="deployed" file="${ear.deploy.dir}/META-INF/application.xml" type="file"/>
+ <available property="deployed" file="${ear.deploy.dir}" type="file"/>
+ <available property="exploded" file="${ear.deploy.dir}/META-INF/application.xml" type="file"/>
<touch>
<fileset dir="${deploy.dir}">
- <include name="${ear.archive.name}/META-INF/application.xml" if="deployed"/>
+ <include name="${ear.archive.name}" if="deployed"/>
+ <include name="${ear.archive.name}/META-INF/application.xml" if="exploded"/>
</fileset>
</touch>
</tasks>
16 years, 8 months
Seam SVN: r10748 - examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/inventory.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-05-01 20:22:24 -0400 (Fri, 01 May 2009)
New Revision: 10748
Modified:
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearchBean.java
Log:
fix broken compilation
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-01 19:55:55 UTC (rev 10747)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearchBean.java 2009-05-02 00:22:24 UTC (rev 10748)
@@ -23,7 +23,6 @@
*/
package org.jboss.seam.examples.booking.inventory;
-import org.jboss.seam.examples.booking.session.*;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Named;
16 years, 8 months
Seam SVN: r10747 - examples/trunk/booking.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-05-01 15:55:55 -0400 (Fri, 01 May 2009)
New Revision: 10747
Modified:
examples/trunk/booking/readme.txt
Log:
add TODO item
Modified: examples/trunk/booking/readme.txt
===================================================================
--- examples/trunk/booking/readme.txt 2009-05-01 19:54:05 UTC (rev 10746)
+++ examples/trunk/booking/readme.txt 2009-05-01 19:55:55 UTC (rev 10747)
@@ -117,3 +117,6 @@
= TODO
- use Cargo plugin to support deployment to other Java EE servers (GlassFish)
+
+- refactor the password/confirm password into a reusable component (needed on
+ registration and change password)
16 years, 8 months
Seam SVN: r10746 - examples/trunk/booking/ejb-jar/src/main/java.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-05-01 15:54:05 -0400 (Fri, 01 May 2009)
New Revision: 10746
Removed:
examples/trunk/booking/ejb-jar/src/main/java/controls/
examples/trunk/booking/ejb-jar/src/main/java/ui/
Log:
remove more empty folders
16 years, 8 months
Seam SVN: r10745 - examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-05-01 15:53:12 -0400 (Fri, 01 May 2009)
New Revision: 10745
Removed:
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/bindings/
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/events/
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/
Log:
remove empty folders
16 years, 8 months
Seam SVN: r10744 - in examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking: booking and 1 other directories.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-05-01 15:51:21 -0400 (Fri, 01 May 2009)
New Revision: 10744
Added:
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/Registered.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/booking/BookingEvent.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/booking/Confirmed.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/controls/BookingFormControls.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/controls/RegistrationFormControls.java
Log:
repackaging
Added: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/Registered.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/Registered.java (rev 0)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/Registered.java 2009-05-01 19:51:21 UTC (rev 10744)
@@ -0,0 +1,35 @@
+package org.jboss.seam.examples.booking.account;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+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;
+import javax.inject.BindingType;
+import org.jboss.seam.examples.booking.model.User;
+
+/**
+ * A binding type representing something that is registererd.
+ * In this simple application the only thing that can be
+ * registered is a {@link User}.
+ *
+ * @author Dan Allen
+ */
+public
+@Target(
+{
+ TYPE, METHOD, PARAMETER, FIELD
+})
+@Retention(RUNTIME)
+@Documented
+@BindingType
+@Inherited
+@interface Registered
+{
+}
Added: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/booking/BookingEvent.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/booking/BookingEvent.java (rev 0)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/booking/BookingEvent.java 2009-05-01 19:51:21 UTC (rev 10744)
@@ -0,0 +1,25 @@
+package org.jboss.seam.examples.booking.booking;
+
+import org.jboss.seam.examples.booking.model.Booking;
+
+/**
+ * An event that is raised when a booking change occurs
+ * (either a new booking is confirmed or an existing
+ * booking is canceled).
+ *
+ * @author Dan Allen
+ */
+public class BookingEvent
+{
+ private Booking booking;
+
+ public BookingEvent(Booking booking)
+ {
+ this.booking = booking;
+ }
+
+ public Booking getBooking()
+ {
+ return booking;
+ }
+}
Added: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/booking/Confirmed.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/booking/Confirmed.java (rev 0)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/booking/Confirmed.java 2009-05-01 19:51:21 UTC (rev 10744)
@@ -0,0 +1,30 @@
+package org.jboss.seam.examples.booking.booking;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+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;
+import javax.inject.BindingType;
+
+/**
+ * @author Dan Allen
+ */
+public
+@Target(
+{
+ TYPE, METHOD, PARAMETER, FIELD
+})
+@Retention(RUNTIME)
+@Documented
+@BindingType
+@Inherited
+@interface Confirmed
+{
+}
Added: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/controls/BookingFormControls.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/controls/BookingFormControls.java (rev 0)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/controls/BookingFormControls.java 2009-05-01 19:51:21 UTC (rev 10744)
@@ -0,0 +1,51 @@
+package org.jboss.seam.examples.booking.controls;
+
+import javax.annotation.Named;
+import javax.context.RequestScoped;
+import javax.faces.component.UIComponent;
+
+/**
+ * A UI binding bean that can provide access to the local id and client id
+ * of selected input components in the booking form.
+ *
+ * @author Dan Allen
+ */
+public
+@Named
+@RequestScoped
+class BookingFormControls
+{
+ private UIComponent checkinDate;
+
+ private UIComponent checkoutDate;
+
+ public UIComponent getCheckinDate()
+ {
+ return checkinDate;
+ }
+
+ public String getCheckinDateControlId()
+ {
+ return checkinDate.getClientId();
+ }
+
+ public void setCheckinDate(UIComponent checkinDate)
+ {
+ this.checkinDate = checkinDate;
+ }
+
+ public UIComponent getCheckoutDate()
+ {
+ return checkoutDate;
+ }
+
+ public void setCheckoutDate(UIComponent checkoutDate)
+ {
+ this.checkoutDate = checkoutDate;
+ }
+
+ public String getCheckoutDateControlId()
+ {
+ return checkoutDate.getClientId();
+ }
+}
Added: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/controls/RegistrationFormControls.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/controls/RegistrationFormControls.java (rev 0)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/controls/RegistrationFormControls.java 2009-05-01 19:51:21 UTC (rev 10744)
@@ -0,0 +1,52 @@
+package org.jboss.seam.examples.booking.controls;
+
+import javax.annotation.Named;
+import javax.context.RequestScoped;
+import javax.faces.component.UIComponent;
+
+/**
+ * A UI binding bean that can provide access to the local id and client id
+ * of selected input components in the registration form.
+ *
+ * @author Dan Allen
+ */
+public
+@Named
+@RequestScoped
+class RegistrationFormControls
+{
+ private UIComponent username;
+
+ private UIComponent confirmPassword;
+
+ public UIComponent getConfirmPassword()
+ {
+ return confirmPassword;
+ }
+
+ public void setConfirmPassword(UIComponent confirmPassword)
+ {
+ this.confirmPassword = confirmPassword;
+ }
+
+ public String getConfirmPasswordControlId()
+ {
+ return confirmPassword.getClientId();
+ }
+
+ public UIComponent getUsername()
+ {
+ return username;
+ }
+
+ public void setUsername(UIComponent username)
+ {
+ this.username = username;
+ }
+
+ public String getUsernameControlId()
+ {
+ return username.getClientId();
+ }
+
+}
16 years, 8 months
Seam SVN: r10743 - in examples/trunk/booking/ejb-jar/src/main/java: org/jboss/seam/examples/booking and 5 other directories.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-05-01 15:49:27 -0400 (Fri, 01 May 2009)
New Revision: 10743
Added:
examples/trunk/booking/ejb-jar/src/main/java/controls/
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/
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/AccountProducerBean.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/PasswordManager.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/Registrar.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/bindings/
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/booking/
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgent.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/BookingHistory.java
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/controls/
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/events/
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/inventory/
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearch.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
Removed:
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/BookingEvent.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/Confirmed.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/Registered.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/AccountProducer.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/AccountProducerBean.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/BookingAgent.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/BookingAgentBean.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/BookingHistory.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/BookingHistoryBean.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/HotelSearch.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/HotelSearchBean.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/PasswordManager.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/PasswordManagerBean.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/Registrar.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/RegistrarBean.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/SearchCriteria.java
examples/trunk/booking/ejb-jar/src/main/java/ui/BookingFormControls.java
examples/trunk/booking/ejb-jar/src/main/java/ui/RegistrationFormControls.java
Log:
packaging
Deleted: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/BookingEvent.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/BookingEvent.java 2009-05-01 19:42:23 UTC (rev 10742)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/BookingEvent.java 2009-05-01 19:49:27 UTC (rev 10743)
@@ -1,25 +0,0 @@
-package org.jboss.seam.examples.booking;
-
-import org.jboss.seam.examples.booking.model.Booking;
-
-/**
- * An event that is raised when a booking change occurs
- * (either a new booking is confirmed or an existing
- * booking is canceled).
- *
- * @author Dan Allen
- */
-public class BookingEvent
-{
- private Booking booking;
-
- public BookingEvent(Booking booking)
- {
- this.booking = booking;
- }
-
- public Booking getBooking()
- {
- return booking;
- }
-}
Deleted: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/Confirmed.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/Confirmed.java 2009-05-01 19:42:23 UTC (rev 10742)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/Confirmed.java 2009-05-01 19:49:27 UTC (rev 10743)
@@ -1,30 +0,0 @@
-package org.jboss.seam.examples.booking;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-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;
-import javax.inject.BindingType;
-
-/**
- * @author Dan Allen
- */
-public
-@Target(
-{
- TYPE, METHOD, PARAMETER, FIELD
-})
-@Retention(RUNTIME)
-@Documented
-@BindingType
-@Inherited
-@interface Confirmed
-{
-}
Deleted: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/Registered.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/Registered.java 2009-05-01 19:42:23 UTC (rev 10742)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/Registered.java 2009-05-01 19:49:27 UTC (rev 10743)
@@ -1,35 +0,0 @@
-package org.jboss.seam.examples.booking;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-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;
-import javax.inject.BindingType;
-import org.jboss.seam.examples.booking.model.User;
-
-/**
- * A binding type representing something that is registererd.
- * In this simple application the only thing that can be
- * registered is a {@link User}.
- *
- * @author Dan Allen
- */
-public
-@Target(
-{
- TYPE, METHOD, PARAMETER, FIELD
-})
-@Retention(RUNTIME)
-@Documented
-@BindingType
-@Inherited
-@interface Registered
-{
-}
Copied: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/AccountProducer.java (from rev 10729, examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/AccountProducer.java)
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/AccountProducer.java (rev 0)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/AccountProducer.java 2009-05-01 19:49:27 UTC (rev 10743)
@@ -0,0 +1,17 @@
+package org.jboss.seam.examples.booking.account;
+
+import javax.ejb.Local;
+import org.jboss.seam.examples.booking.model.User;
+
+/**
+ * The <strong>AccountProducer</strong> produces the object that
+ * represents the current user's account information. The account
+ * information is represented by the {@link User} entity.
+ *
+ * @author Dan Allen
+ */
+public
+@Local
+interface AccountProducer {
+ User getCurrentAccount();
+}
Copied: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/AccountProducerBean.java (from rev 10734, examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/AccountProducerBean.java)
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/AccountProducerBean.java (rev 0)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/AccountProducerBean.java 2009-05-01 19:49:27 UTC (rev 10743)
@@ -0,0 +1,45 @@
+package org.jboss.seam.examples.booking.account;
+
+import javax.annotation.Named;
+import javax.context.SessionScoped;
+import javax.ejb.Stateless;
+import javax.inject.Current;
+import javax.inject.Produces;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import org.jboss.seam.examples.booking.account.Registered;
+import org.jboss.seam.examples.booking.model.User;
+import org.jboss.seam.examples.booking.security.Identity;
+
+/**
+ * @author Dan Allen
+ */
+public
+@Stateless
+class AccountProducerBean implements AccountProducer
+{
+ @PersistenceContext EntityManager em;
+
+ @Current Identity identity;
+
+ public
+ @Produces
+ @Registered
+ @Named("user")
+ @SessionScoped
+ User getCurrentAccount()
+ {
+ if (identity.isLoggedIn())
+ {
+ User user = em.find(User.class, identity.getUsername());
+ if (user != null)
+ {
+ user.setPassword(null);
+ return user;
+ }
+ }
+
+ // TODO can't return null, but then we are not honoring the semantics of our binding type
+ return new User();
+ }
+}
Copied: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/PasswordManager.java (from rev 10734, examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/PasswordManager.java)
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/PasswordManager.java (rev 0)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/PasswordManager.java 2009-05-01 19:49:27 UTC (rev 10743)
@@ -0,0 +1,26 @@
+package org.jboss.seam.examples.booking.account;
+
+import javax.ejb.Local;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+/**
+ *
+ * @author Dan Allen
+ */
+public
+@Local
+interface PasswordManager
+{
+ void changePassword();
+
+ boolean isChanged();
+
+ void setConfirmPassword(String password);
+
+ @NotNull
+ @Size(min = 5, max = 15)
+ String getConfirmPassword();
+
+ void destroy();
+}
Copied: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/PasswordManagerBean.java (from rev 10734, examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/PasswordManagerBean.java)
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/PasswordManagerBean.java (rev 0)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/PasswordManagerBean.java 2009-05-01 19:49:27 UTC (rev 10743)
@@ -0,0 +1,74 @@
+package org.jboss.seam.examples.booking.account;
+
+import javax.annotation.Named;
+import javax.annotation.PreDestroy;
+import javax.context.RequestScoped;
+import javax.ejb.Stateful;
+import javax.inject.Current;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import org.jboss.seam.examples.booking.account.Registered;
+import org.jboss.seam.examples.booking.model.User;
+import org.jboss.seam.international.StatusMessages;
+import org.jboss.seam.examples.booking.controls.RegistrationFormControls;
+
+/**
+ * @author Dan Allen
+ */
+public
+@Named("passwordManager")
+@Stateful
+@RequestScoped
+class PasswordManagerBean implements PasswordManager
+{
+ @PersistenceContext EntityManager em;
+
+ @Current StatusMessages statusMessages;
+
+ @Current RegistrationFormControls formControls;
+
+ @Registered User user;
+
+ private String confirmPassword;
+
+ private boolean changed;
+
+ public void changePassword()
+ {
+ if (user.getPassword().equals(confirmPassword))
+ {
+ // 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.");
+ changed = true;
+ }
+ else
+ {
+ // 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.");
+ }
+ }
+
+ public boolean isChanged()
+ {
+ return changed;
+ }
+
+ public void setConfirmPassword(String password)
+ {
+ this.confirmPassword = password;
+ }
+
+ public String getConfirmPassword()
+ {
+ return this.confirmPassword;
+ }
+
+ @PreDestroy
+ public void destroy()
+ {
+ }
+}
Copied: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/Registrar.java (from rev 10729, examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/Registrar.java)
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/Registrar.java (rev 0)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/Registrar.java 2009-05-01 19:49:27 UTC (rev 10743)
@@ -0,0 +1,32 @@
+package org.jboss.seam.examples.booking.account;
+
+import javax.ejb.Local;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import org.jboss.seam.examples.booking.model.User;
+
+/**
+ * @author Dan Allen
+ */
+public
+@Local
+interface Registrar
+{
+ void register();
+
+ boolean isRegistrationInvalid();
+
+ void notifyIfRegistrationIsInvalid(boolean validationFailed);
+
+ User getNewUser();
+
+ boolean isRegistered();
+
+ @NotNull
+ @Size(min = 5, max = 15)
+ String getConfirmPassword();
+
+ void setConfirmPassword(String password);
+
+ void destroy();
+}
Copied: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/RegistrarBean.java (from rev 10740, examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/RegistrarBean.java)
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/RegistrarBean.java (rev 0)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/account/RegistrarBean.java 2009-05-01 19:49:27 UTC (rev 10743)
@@ -0,0 +1,131 @@
+package org.jboss.seam.examples.booking.account;
+
+import javax.annotation.Named;
+import javax.annotation.PreDestroy;
+import javax.context.RequestScoped;
+import javax.ejb.Stateful;
+import javax.inject.Current;
+import javax.inject.Produces;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import org.jboss.seam.examples.booking.model.User;
+import org.jboss.seam.examples.booking.security.Credentials;
+import org.jboss.seam.examples.booking.security.Identity;
+import org.jboss.seam.international.StatusMessage;
+import org.jboss.seam.international.StatusMessages;
+import org.jboss.seam.examples.booking.controls.RegistrationFormControls;
+
+/**
+ * @author Dan Allen
+ */
+public
+@Named("registrar")
+@Stateful
+@RequestScoped
+class RegistrarBean implements Registrar
+{
+ @PersistenceContext EntityManager em;
+
+ @Current StatusMessages statusMessages;
+
+ @Current RegistrationFormControls formControls;
+
+ @Current Credentials credentials;
+
+ @Current Identity identity;
+
+ private User newUser;
+
+ private String confirmPassword;
+
+ private boolean registered;
+
+ private boolean registrationInvalid;
+
+ public void register()
+ {
+ if (verifyPasswordsMatch() && verifyUsernameIsAvailable())
+ {
+ em.persist(newUser);
+ credentials.setUsername(newUser.getUsername());
+ identity.autoLogin();
+ registered = true;
+ statusMessages.add("You have been successfully registered as the user {0}!", newUser.getUsername());
+ }
+ else
+ {
+ registrationInvalid = true;
+ }
+ }
+
+ public boolean isRegistrationInvalid()
+ {
+ return registrationInvalid;
+ }
+
+ // TODO it would be nice to move the conditional to the UI but <f:event> doesn't support if=""
+ public void notifyIfRegistrationIsInvalid(boolean validationFailed)
+ {
+ if (validationFailed || registrationInvalid)
+ {
+ statusMessages.add(StatusMessage.Severity.WARN, "Invalid registration. Please correct the errors and try again.");
+ }
+ }
+
+ public
+ @Produces
+ @Named
+ @RequestScoped
+ User getNewUser()
+ {
+ newUser = new User();
+ return newUser;
+ }
+
+ public boolean isRegistered()
+ {
+ return registered;
+ }
+
+ public String getConfirmPassword()
+ {
+ return confirmPassword;
+ }
+
+ public void setConfirmPassword(String password)
+ {
+ this.confirmPassword = password;
+ }
+
+ /**
+ * Verify that the same password is entered twice.
+ */
+ private boolean verifyPasswordsMatch()
+ {
+ if (!newUser.getPassword().equals(confirmPassword))
+ {
+ statusMessages.addToControl(formControls.getConfirmPasswordControlId(), "Passwords do not match. Please re-type your password.");
+ confirmPassword = null;
+ return false;
+ }
+
+ return true;
+ }
+
+ private boolean verifyUsernameIsAvailable()
+ {
+ 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());
+ return false;
+ }
+
+ return true;
+ }
+
+ @PreDestroy
+ public void destroy()
+ {
+ }
+}
Copied: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgent.java (from rev 10713, examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/BookingAgent.java)
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgent.java (rev 0)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgent.java 2009-05-01 19:49:27 UTC (rev 10743)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * $Id$
+ */
+package org.jboss.seam.examples.booking.booking;
+
+import javax.ejb.Local;
+import org.jboss.seam.examples.booking.model.Booking;
+import org.jboss.seam.examples.booking.model.Hotel;
+
+/**
+ * @author Dan Allen
+ */
+public
+@Local
+interface BookingAgent
+{
+ void selectHotel(Hotel hotel);
+
+ void bookHotel();
+
+ void validateBooking();
+
+ void cancel();
+
+ void confirm();
+
+ Hotel getHotelSelection();
+
+ Booking getBooking();
+
+ boolean isBookingValid();
+
+ void destroy();
+}
Copied: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgentBean.java (from rev 10734, examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/BookingAgentBean.java)
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgentBean.java (rev 0)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgentBean.java 2009-05-01 19:49:27 UTC (rev 10743)
@@ -0,0 +1,160 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * $Id$
+ */
+package org.jboss.seam.examples.booking.booking;
+
+import java.util.Calendar;
+import static javax.persistence.PersistenceContextType.EXTENDED;
+import javax.annotation.Named;
+import javax.context.Conversation;
+import javax.context.ConversationScoped;
+import javax.context.RequestScoped;
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+import javax.event.Event;
+import javax.event.Fires;
+import javax.inject.Current;
+import javax.inject.Produces;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import org.jboss.seam.examples.booking.booking.BookingEvent;
+import org.jboss.seam.examples.booking.booking.Confirmed;
+import org.jboss.seam.examples.booking.account.Registered;
+import org.jboss.seam.examples.booking.model.Booking;
+import org.jboss.seam.examples.booking.model.Hotel;
+import org.jboss.seam.examples.booking.model.User;
+import org.jboss.seam.international.StatusMessages;
+import org.jboss.webbeans.log.Log;
+import org.jboss.webbeans.log.Logger;
+import org.jboss.seam.examples.booking.controls.BookingFormControls;
+
+public
+@Named("bookingAgent")
+@Stateful
+@ConversationScoped
+class BookingAgentBean implements BookingAgent
+{
+ private @Logger Log log;
+
+ @PersistenceContext(type = EXTENDED) EntityManager em;
+
+ @Current Conversation conversation;
+
+ @Current StatusMessages statusMessages;
+
+ @Current BookingFormControls formControls;
+
+ @Registered User user;
+
+ //@Fires @Confirmed Event<BookingEvent> bookingConfirmedEvent;
+
+ private Hotel hotelSelection;
+
+ private Booking booking;
+
+ private boolean bookingValid;
+
+ public void selectHotel(Hotel hotel)
+ {
+ // NOTE get a fresh reference that's managed by the conversational persistence context
+ hotelSelection = em.find(Hotel.class, hotel.getId());
+ log.info("Selected the " + hotelSelection.getName() + " in " + hotelSelection.getCity());
+ conversation.begin();
+ }
+
+ public void bookHotel()
+ {
+ booking = new Booking(hotelSelection, user);
+ // QUESTION push logic into Booking?
+ Calendar calendar = Calendar.getInstance();
+ booking.setCheckinDate(calendar.getTime());
+ calendar.add(Calendar.DAY_OF_MONTH, 1);
+ booking.setCheckoutDate(calendar.getTime());
+ hotelSelection = null;
+ statusMessages.add("You've initiated a booking at {0}.", booking.getHotel().getName());
+ }
+
+ public void validateBooking()
+ {
+ Calendar calendar = Calendar.getInstance();
+ calendar.add(Calendar.DAY_OF_MONTH, -1);
+ if (booking.getCheckinDate().before(calendar.getTime()))
+ {
+ statusMessages.addToControl(formControls.getCheckinDateControlId(), "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");
+ bookingValid = false;
+ }
+ else
+ {
+ bookingValid = true;
+ }
+ }
+
+ public void confirm()
+ {
+ em.persist(booking);
+ //bookingConfirmedEvent.fire(new BookingEvent(booking));
+ log.info("New booking at the " + booking.getHotel().getName() + " confirmed for " + booking.getUser().getName());
+ statusMessages.add("You're booked!");
+ conversation.end();
+ }
+
+ public void cancel()
+ {
+ booking = null;
+ hotelSelection = null;
+ conversation.end();
+ }
+
+ public
+ @Produces
+ @Named
+ @ConversationScoped
+ Booking getBooking()
+ {
+ return booking;
+ }
+
+ public
+ @Produces
+ @Named("hotel")
+ @RequestScoped
+ Hotel getHotelSelection()
+ {
+ return booking != null ? booking.getHotel() : hotelSelection;
+ }
+
+ public boolean isBookingValid()
+ {
+ return bookingValid;
+ }
+
+ @Remove
+ public void destroy()
+ {
+ }
+}
Copied: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistory.java (from rev 10734, examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/BookingHistory.java)
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistory.java (rev 0)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistory.java 2009-05-01 19:49:27 UTC (rev 10743)
@@ -0,0 +1,22 @@
+package org.jboss.seam.examples.booking.booking;
+
+import java.util.List;
+import javax.ejb.Local;
+import org.jboss.seam.examples.booking.booking.BookingEvent;
+import org.jboss.seam.examples.booking.model.Booking;
+
+/**
+ * @author Dan Allen
+ */
+public
+@Local
+interface BookingHistory
+{
+ List<Booking> getBookingsForCurrentUser();
+
+ void cancelBooking(Booking booking);
+
+ void destroy();
+
+ void afterBookingConfirmed(BookingEvent bookingEvent);
+}
Copied: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistoryBean.java (from rev 10734, examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/BookingHistoryBean.java)
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistoryBean.java (rev 0)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistoryBean.java 2009-05-01 19:49:27 UTC (rev 10743)
@@ -0,0 +1,85 @@
+package org.jboss.seam.examples.booking.booking;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.annotation.Named;
+import javax.annotation.PreDestroy;
+import javax.context.RequestScoped;
+import javax.context.SessionScoped;
+import javax.ejb.Stateful;
+import javax.event.Observes;
+import javax.inject.Current;
+import javax.inject.Produces;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import org.jboss.seam.examples.booking.booking.BookingEvent;
+import org.jboss.seam.examples.booking.booking.Confirmed;
+import org.jboss.seam.examples.booking.account.Registered;
+import org.jboss.seam.examples.booking.model.Booking;
+import org.jboss.seam.examples.booking.model.User;
+import org.jboss.seam.international.StatusMessages;
+import org.jboss.webbeans.log.Log;
+import org.jboss.webbeans.log.Logger;
+
+/**
+ * @author Dan Allen
+ */
+public
+@Named("bookingHistory")
+@Stateful
+@SessionScoped
+class BookingHistoryBean implements BookingHistory {
+
+ private @Logger Log log;
+
+ @PersistenceContext EntityManager em;
+
+ @Current StatusMessages statusMessages;
+
+ @Registered User user;
+
+ private List<Booking> bookingsForUser = new ArrayList<Booking>();
+
+ public
+ @Produces
+ @Registered
+ @Named("bookings")
+ @SessionScoped
+ List<Booking> getBookingsForCurrentUser()
+ {
+ bookingsForUser.clear();
+ bookingsForUser.addAll(em.createQuery("select b from Booking b join fetch b.hotel where b.user.username = :username order by b.checkinDate")
+ .setParameter("username", user.getUsername())
+ .getResultList());
+ return bookingsForUser;
+ }
+
+ // TODO should probably observe after transaction success
+ public void afterBookingConfirmed(@Observes @Confirmed BookingEvent bookingEvent)
+ {
+ getBookingsForCurrentUser();
+ }
+
+ public void cancelBooking(Booking selectedBooking)
+ {
+ log.info("Canceling booking " + selectedBooking.getId() + " for " + user.getName());
+ Booking booking = em.find(Booking.class, selectedBooking.getId());
+ if (booking != null)
+ {
+ em.remove(booking);
+ statusMessages.add("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.");
+ }
+
+ bookingsForUser.remove(selectedBooking);
+ }
+
+ @PreDestroy
+ public void destroy()
+ {
+ }
+
+}
Copied: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearch.java (from rev 10713, examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/HotelSearch.java)
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearch.java (rev 0)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearch.java 2009-05-01 19:49:27 UTC (rev 10743)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * $Id$
+ */
+package org.jboss.seam.examples.booking.inventory;
+
+import java.util.List;
+import javax.ejb.Local;
+import org.jboss.seam.examples.booking.model.Hotel;
+
+public
+@Local
+interface HotelSearch
+{
+ public void find();
+
+ public void previousPage();
+
+ public void nextPage();
+
+ public List<Hotel> getHotels();
+
+ public boolean isNextPageAvailable();
+
+ public boolean isPreviousPageAvailable();
+
+ public void destroy();
+}
Copied: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearchBean.java (from rev 10734, examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/HotelSearchBean.java)
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearchBean.java (rev 0)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearchBean.java 2009-05-01 19:49:27 UTC (rev 10743)
@@ -0,0 +1,117 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * $Id$
+ */
+package org.jboss.seam.examples.booking.inventory;
+
+import org.jboss.seam.examples.booking.session.*;
+import java.util.ArrayList;
+import java.util.List;
+import javax.annotation.Named;
+import javax.context.SessionScoped;
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+import javax.inject.Current;
+import javax.inject.Produces;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import org.jboss.seam.examples.booking.model.Hotel;
+import org.jboss.webbeans.log.Log;
+import org.jboss.webbeans.log.Logger;
+
+public
+@Named("hotelSearch")
+@Stateful
+@SessionScoped
+class HotelSearchBean implements HotelSearch
+{
+ private @Logger Log log;
+
+ @PersistenceContext EntityManager em;
+
+ @Current SearchCriteria criteria;
+
+ private boolean nextPageAvailable = false;
+
+ private List<Hotel> hotels = new ArrayList<Hotel>();
+
+ public void find()
+ {
+ criteria.firstPage();
+ queryHotels(criteria);
+ }
+
+ public void nextPage()
+ {
+ criteria.nextPage();
+ queryHotels(criteria);
+ }
+
+ public void previousPage()
+ {
+ criteria.previousPage();
+ queryHotels(criteria);
+ }
+
+ public
+ @Produces
+ @Named
+ //@RequestScoped // if enabled, variable doesn't get updated after the action is executed w/o a redirect
+ List<Hotel> getHotels()
+ {
+ return hotels;
+ }
+
+ public boolean isNextPageAvailable()
+ {
+ return nextPageAvailable;
+ }
+
+ public boolean isPreviousPageAvailable()
+ {
+ return criteria.getPage() > 0;
+ }
+
+ @Remove
+ public void destroy()
+ {
+ }
+
+ private void queryHotels(SearchCriteria criteria)
+ {
+ List<Hotel> results = em.createQuery(
+ "select h from Hotel h where lower(h.name) like :pattern or lower(h.city) like :pattern or lower(h.zip) like :pattern or lower(h.address) like :pattern").
+ setParameter("pattern", criteria.getSearchPattern()).setMaxResults(criteria.getPageSize() + 1).setFirstResult(criteria.getPage() * criteria.getPageSize()).
+ getResultList();
+
+ nextPageAvailable = results.size() > criteria.getPageSize();
+ if (nextPageAvailable)
+ {
+ hotels = new ArrayList<Hotel>(results.subList(0, criteria.getPageSize()));
+ }
+ else
+ {
+ hotels = results;
+ }
+ log.info("Found " + hotels.size() + " hotels matching search term '" + criteria.getSearchString() + "' (limit " + criteria.getPageSize() + ")");
+ }
+}
Copied: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/inventory/SearchCriteria.java (from rev 10734, examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/SearchCriteria.java)
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/inventory/SearchCriteria.java (rev 0)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/inventory/SearchCriteria.java 2009-05-01 19:49:27 UTC (rev 10743)
@@ -0,0 +1,112 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * $Id$
+ */
+package org.jboss.seam.examples.booking.inventory;
+
+import java.io.Serializable;
+import javax.annotation.Named;
+import javax.context.SessionScoped;
+
+public
+@Named
+@SessionScoped
+class SearchCriteria implements Serializable
+{
+ private static final char SQL_WILDCARD_CHAR = '%';
+ private static final String SQL_WILDCARD_STR = String.valueOf(SQL_WILDCARD_CHAR);
+ private static final String REPEAT_SQL_WIDCARD_REGEX = SQL_WILDCARD_STR + "+";
+ private static final char HUMAN_WILDCARD_CHAR = '*';
+
+ private String searchString = "";
+ private int pageSize = 5;
+ private int page = 0;
+
+ public String getSearchPattern()
+ {
+ if (searchString == null || searchString.length() == 0)
+ {
+ return SQL_WILDCARD_STR;
+ }
+
+ StringBuilder pattern = new StringBuilder();
+ pattern.append(searchString.toLowerCase().replace(HUMAN_WILDCARD_CHAR, SQL_WILDCARD_CHAR).replaceAll(REPEAT_SQL_WIDCARD_REGEX, SQL_WILDCARD_STR));
+ if (pattern.length() == 0 || pattern.charAt(0) != SQL_WILDCARD_CHAR)
+ {
+ pattern.insert(0, SQL_WILDCARD_CHAR);
+ }
+ if (pattern.length() > 1 && pattern.charAt(pattern.length() - 1) != SQL_WILDCARD_CHAR)
+ {
+ pattern.append(SQL_WILDCARD_CHAR);
+ }
+ return pattern.toString();
+ }
+
+ public int getPage()
+ {
+ return page;
+ }
+
+ public void setPage(int page)
+ {
+ this.page = page;
+ }
+
+ public int getPageSize()
+ {
+ return pageSize;
+ }
+
+ public void setPageSize(int pageSize)
+ {
+ this.pageSize = pageSize;
+ }
+
+ // QUESTION: rename to searchTerm?
+ public String getSearchString()
+ {
+ return searchString;
+ }
+
+ public void setSearchString(String searchString)
+ {
+ this.searchString = (searchString != null ? searchString.trim() : null);
+ }
+
+ public void nextPage()
+ {
+ page++;
+ }
+
+ public void previousPage()
+ {
+ if (page > 0)
+ {
+ page--;
+ }
+ }
+
+ public void firstPage()
+ {
+ page = 0;
+ }
+}
Deleted: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/AccountProducer.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/AccountProducer.java 2009-05-01 19:42:23 UTC (rev 10742)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/AccountProducer.java 2009-05-01 19:49:27 UTC (rev 10743)
@@ -1,17 +0,0 @@
-package org.jboss.seam.examples.booking.session;
-
-import javax.ejb.Local;
-import org.jboss.seam.examples.booking.model.User;
-
-/**
- * The <strong>AccountProducer</strong> produces the object that
- * represents the current user's account information. The account
- * information is represented by the {@link User} entity.
- *
- * @author Dan Allen
- */
-public
-@Local
-interface AccountProducer {
- User getCurrentAccount();
-}
Deleted: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/AccountProducerBean.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/AccountProducerBean.java 2009-05-01 19:42:23 UTC (rev 10742)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/AccountProducerBean.java 2009-05-01 19:49:27 UTC (rev 10743)
@@ -1,45 +0,0 @@
-package org.jboss.seam.examples.booking.session;
-
-import javax.annotation.Named;
-import javax.context.SessionScoped;
-import javax.ejb.Stateless;
-import javax.inject.Current;
-import javax.inject.Produces;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-import org.jboss.seam.examples.booking.Registered;
-import org.jboss.seam.examples.booking.model.User;
-import org.jboss.seam.examples.booking.security.Identity;
-
-/**
- * @author Dan Allen
- */
-public
-@Stateless
-class AccountProducerBean implements AccountProducer
-{
- @PersistenceContext EntityManager em;
-
- @Current Identity identity;
-
- public
- @Produces
- @Registered
- @Named("user")
- @SessionScoped
- User getCurrentAccount()
- {
- if (identity.isLoggedIn())
- {
- User user = em.find(User.class, identity.getUsername());
- if (user != null)
- {
- user.setPassword(null);
- return user;
- }
- }
-
- // TODO can't return null, but then we are not honoring the semantics of our binding type
- return new User();
- }
-}
Deleted: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/BookingAgent.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/BookingAgent.java 2009-05-01 19:42:23 UTC (rev 10742)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/BookingAgent.java 2009-05-01 19:49:27 UTC (rev 10743)
@@ -1,54 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- *
- * $Id$
- */
-package org.jboss.seam.examples.booking.session;
-
-import javax.ejb.Local;
-import org.jboss.seam.examples.booking.model.Booking;
-import org.jboss.seam.examples.booking.model.Hotel;
-
-/**
- * @author Dan Allen
- */
-public
-@Local
-interface BookingAgent
-{
- void selectHotel(Hotel hotel);
-
- void bookHotel();
-
- void validateBooking();
-
- void cancel();
-
- void confirm();
-
- Hotel getHotelSelection();
-
- Booking getBooking();
-
- boolean isBookingValid();
-
- void destroy();
-}
Deleted: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/BookingAgentBean.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/BookingAgentBean.java 2009-05-01 19:42:23 UTC (rev 10742)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/BookingAgentBean.java 2009-05-01 19:49:27 UTC (rev 10743)
@@ -1,160 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- *
- * $Id$
- */
-package org.jboss.seam.examples.booking.session;
-
-import java.util.Calendar;
-import static javax.persistence.PersistenceContextType.EXTENDED;
-import javax.annotation.Named;
-import javax.context.Conversation;
-import javax.context.ConversationScoped;
-import javax.context.RequestScoped;
-import javax.ejb.Remove;
-import javax.ejb.Stateful;
-import javax.event.Event;
-import javax.event.Fires;
-import javax.inject.Current;
-import javax.inject.Produces;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-import org.jboss.seam.examples.booking.BookingEvent;
-import org.jboss.seam.examples.booking.Confirmed;
-import org.jboss.seam.examples.booking.Registered;
-import org.jboss.seam.examples.booking.model.Booking;
-import org.jboss.seam.examples.booking.model.Hotel;
-import org.jboss.seam.examples.booking.model.User;
-import org.jboss.seam.international.StatusMessages;
-import org.jboss.webbeans.log.Log;
-import org.jboss.webbeans.log.Logger;
-import ui.BookingFormControls;
-
-public
-@Named("bookingAgent")
-@Stateful
-@ConversationScoped
-class BookingAgentBean implements BookingAgent
-{
- private @Logger Log log;
-
- @PersistenceContext(type = EXTENDED) EntityManager em;
-
- @Current Conversation conversation;
-
- @Current StatusMessages statusMessages;
-
- @Current BookingFormControls formControls;
-
- @Registered User user;
-
- //@Fires @Confirmed Event<BookingEvent> bookingConfirmedEvent;
-
- private Hotel hotelSelection;
-
- private Booking booking;
-
- private boolean bookingValid;
-
- public void selectHotel(Hotel hotel)
- {
- // NOTE get a fresh reference that's managed by the conversational persistence context
- hotelSelection = em.find(Hotel.class, hotel.getId());
- log.info("Selected the " + hotelSelection.getName() + " in " + hotelSelection.getCity());
- conversation.begin();
- }
-
- public void bookHotel()
- {
- booking = new Booking(hotelSelection, user);
- // QUESTION push logic into Booking?
- Calendar calendar = Calendar.getInstance();
- booking.setCheckinDate(calendar.getTime());
- calendar.add(Calendar.DAY_OF_MONTH, 1);
- booking.setCheckoutDate(calendar.getTime());
- hotelSelection = null;
- statusMessages.add("You've initiated a booking at {0}.", booking.getHotel().getName());
- }
-
- public void validateBooking()
- {
- Calendar calendar = Calendar.getInstance();
- calendar.add(Calendar.DAY_OF_MONTH, -1);
- if (booking.getCheckinDate().before(calendar.getTime()))
- {
- statusMessages.addToControl(formControls.getCheckinDateControlId(), "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");
- bookingValid = false;
- }
- else
- {
- bookingValid = true;
- }
- }
-
- public void confirm()
- {
- em.persist(booking);
- //bookingConfirmedEvent.fire(new BookingEvent(booking));
- log.info("New booking at the " + booking.getHotel().getName() + " confirmed for " + booking.getUser().getName());
- statusMessages.add("You're booked!");
- conversation.end();
- }
-
- public void cancel()
- {
- booking = null;
- hotelSelection = null;
- conversation.end();
- }
-
- public
- @Produces
- @Named
- @ConversationScoped
- Booking getBooking()
- {
- return booking;
- }
-
- public
- @Produces
- @Named("hotel")
- @RequestScoped
- Hotel getHotelSelection()
- {
- return booking != null ? booking.getHotel() : hotelSelection;
- }
-
- public boolean isBookingValid()
- {
- return bookingValid;
- }
-
- @Remove
- public void destroy()
- {
- }
-}
Deleted: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/BookingHistory.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/BookingHistory.java 2009-05-01 19:42:23 UTC (rev 10742)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/BookingHistory.java 2009-05-01 19:49:27 UTC (rev 10743)
@@ -1,22 +0,0 @@
-package org.jboss.seam.examples.booking.session;
-
-import java.util.List;
-import javax.ejb.Local;
-import org.jboss.seam.examples.booking.BookingEvent;
-import org.jboss.seam.examples.booking.model.Booking;
-
-/**
- * @author Dan Allen
- */
-public
-@Local
-interface BookingHistory
-{
- List<Booking> getBookingsForCurrentUser();
-
- void cancelBooking(Booking booking);
-
- void destroy();
-
- void afterBookingConfirmed(BookingEvent bookingEvent);
-}
Deleted: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/BookingHistoryBean.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/BookingHistoryBean.java 2009-05-01 19:42:23 UTC (rev 10742)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/BookingHistoryBean.java 2009-05-01 19:49:27 UTC (rev 10743)
@@ -1,85 +0,0 @@
-package org.jboss.seam.examples.booking.session;
-
-import java.util.ArrayList;
-import java.util.List;
-import javax.annotation.Named;
-import javax.annotation.PreDestroy;
-import javax.context.RequestScoped;
-import javax.context.SessionScoped;
-import javax.ejb.Stateful;
-import javax.event.Observes;
-import javax.inject.Current;
-import javax.inject.Produces;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-import org.jboss.seam.examples.booking.BookingEvent;
-import org.jboss.seam.examples.booking.Confirmed;
-import org.jboss.seam.examples.booking.Registered;
-import org.jboss.seam.examples.booking.model.Booking;
-import org.jboss.seam.examples.booking.model.User;
-import org.jboss.seam.international.StatusMessages;
-import org.jboss.webbeans.log.Log;
-import org.jboss.webbeans.log.Logger;
-
-/**
- * @author Dan Allen
- */
-public
-@Named("bookingHistory")
-@Stateful
-@SessionScoped
-class BookingHistoryBean implements BookingHistory {
-
- private @Logger Log log;
-
- @PersistenceContext EntityManager em;
-
- @Current StatusMessages statusMessages;
-
- @Registered User user;
-
- private List<Booking> bookingsForUser = new ArrayList<Booking>();
-
- public
- @Produces
- @Registered
- @Named("bookings")
- @SessionScoped
- List<Booking> getBookingsForCurrentUser()
- {
- bookingsForUser.clear();
- bookingsForUser.addAll(em.createQuery("select b from Booking b join fetch b.hotel where b.user.username = :username order by b.checkinDate")
- .setParameter("username", user.getUsername())
- .getResultList());
- return bookingsForUser;
- }
-
- // TODO should probably observe after transaction success
- public void afterBookingConfirmed(@Observes @Confirmed BookingEvent bookingEvent)
- {
- getBookingsForCurrentUser();
- }
-
- public void cancelBooking(Booking selectedBooking)
- {
- log.info("Canceling booking " + selectedBooking.getId() + " for " + user.getName());
- Booking booking = em.find(Booking.class, selectedBooking.getId());
- if (booking != null)
- {
- em.remove(booking);
- statusMessages.add("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.");
- }
-
- bookingsForUser.remove(selectedBooking);
- }
-
- @PreDestroy
- public void destroy()
- {
- }
-
-}
Deleted: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/HotelSearch.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/HotelSearch.java 2009-05-01 19:42:23 UTC (rev 10742)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/HotelSearch.java 2009-05-01 19:49:27 UTC (rev 10743)
@@ -1,47 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- *
- * $Id$
- */
-package org.jboss.seam.examples.booking.session;
-
-import java.util.List;
-import javax.ejb.Local;
-import org.jboss.seam.examples.booking.model.Hotel;
-
-public
-@Local
-interface HotelSearch
-{
- public void find();
-
- public void previousPage();
-
- public void nextPage();
-
- public List<Hotel> getHotels();
-
- public boolean isNextPageAvailable();
-
- public boolean isPreviousPageAvailable();
-
- public void destroy();
-}
Deleted: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/HotelSearchBean.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/HotelSearchBean.java 2009-05-01 19:42:23 UTC (rev 10742)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/HotelSearchBean.java 2009-05-01 19:49:27 UTC (rev 10743)
@@ -1,116 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- *
- * $Id$
- */
-package org.jboss.seam.examples.booking.session;
-
-import java.util.ArrayList;
-import java.util.List;
-import javax.annotation.Named;
-import javax.context.SessionScoped;
-import javax.ejb.Remove;
-import javax.ejb.Stateful;
-import javax.inject.Current;
-import javax.inject.Produces;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-import org.jboss.seam.examples.booking.model.Hotel;
-import org.jboss.webbeans.log.Log;
-import org.jboss.webbeans.log.Logger;
-
-public
-@Named("hotelSearch")
-@Stateful
-@SessionScoped
-class HotelSearchBean implements HotelSearch
-{
- private @Logger Log log;
-
- @PersistenceContext EntityManager em;
-
- @Current SearchCriteria criteria;
-
- private boolean nextPageAvailable = false;
-
- private List<Hotel> hotels = new ArrayList<Hotel>();
-
- public void find()
- {
- criteria.firstPage();
- queryHotels(criteria);
- }
-
- public void nextPage()
- {
- criteria.nextPage();
- queryHotels(criteria);
- }
-
- public void previousPage()
- {
- criteria.previousPage();
- queryHotels(criteria);
- }
-
- public
- @Produces
- @Named
- //@RequestScoped // if enabled, variable doesn't get updated after the action is executed w/o a redirect
- List<Hotel> getHotels()
- {
- return hotels;
- }
-
- public boolean isNextPageAvailable()
- {
- return nextPageAvailable;
- }
-
- public boolean isPreviousPageAvailable()
- {
- return criteria.getPage() > 0;
- }
-
- @Remove
- public void destroy()
- {
- }
-
- private void queryHotels(SearchCriteria criteria)
- {
- List<Hotel> results = em.createQuery(
- "select h from Hotel h where lower(h.name) like :pattern or lower(h.city) like :pattern or lower(h.zip) like :pattern or lower(h.address) like :pattern").
- setParameter("pattern", criteria.getSearchPattern()).setMaxResults(criteria.getPageSize() + 1).setFirstResult(criteria.getPage() * criteria.getPageSize()).
- getResultList();
-
- nextPageAvailable = results.size() > criteria.getPageSize();
- if (nextPageAvailable)
- {
- hotels = new ArrayList<Hotel>(results.subList(0, criteria.getPageSize()));
- }
- else
- {
- hotels = results;
- }
- log.info("Found " + hotels.size() + " hotels matching search term '" + criteria.getSearchString() + "' (limit " + criteria.getPageSize() + ")");
- }
-}
Deleted: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/PasswordManager.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/PasswordManager.java 2009-05-01 19:42:23 UTC (rev 10742)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/PasswordManager.java 2009-05-01 19:49:27 UTC (rev 10743)
@@ -1,26 +0,0 @@
-package org.jboss.seam.examples.booking.session;
-
-import javax.ejb.Local;
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Size;
-
-/**
- *
- * @author Dan Allen
- */
-public
-@Local
-interface PasswordManager
-{
- void changePassword();
-
- boolean isChanged();
-
- void setConfirmPassword(String password);
-
- @NotNull
- @Size(min = 5, max = 15)
- String getConfirmPassword();
-
- void destroy();
-}
Deleted: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/PasswordManagerBean.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/PasswordManagerBean.java 2009-05-01 19:42:23 UTC (rev 10742)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/PasswordManagerBean.java 2009-05-01 19:49:27 UTC (rev 10743)
@@ -1,74 +0,0 @@
-package org.jboss.seam.examples.booking.session;
-
-import javax.annotation.Named;
-import javax.annotation.PreDestroy;
-import javax.context.RequestScoped;
-import javax.ejb.Stateful;
-import javax.inject.Current;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-import org.jboss.seam.examples.booking.Registered;
-import org.jboss.seam.examples.booking.model.User;
-import org.jboss.seam.international.StatusMessages;
-import ui.RegistrationFormControls;
-
-/**
- * @author Dan Allen
- */
-public
-@Named("passwordManager")
-@Stateful
-@RequestScoped
-class PasswordManagerBean implements PasswordManager
-{
- @PersistenceContext EntityManager em;
-
- @Current StatusMessages statusMessages;
-
- @Current RegistrationFormControls formControls;
-
- @Registered User user;
-
- private String confirmPassword;
-
- private boolean changed;
-
- public void changePassword()
- {
- if (user.getPassword().equals(confirmPassword))
- {
- // 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.");
- changed = true;
- }
- else
- {
- // 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.");
- }
- }
-
- public boolean isChanged()
- {
- return changed;
- }
-
- public void setConfirmPassword(String password)
- {
- this.confirmPassword = password;
- }
-
- public String getConfirmPassword()
- {
- return this.confirmPassword;
- }
-
- @PreDestroy
- public void destroy()
- {
- }
-}
Deleted: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/Registrar.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/Registrar.java 2009-05-01 19:42:23 UTC (rev 10742)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/Registrar.java 2009-05-01 19:49:27 UTC (rev 10743)
@@ -1,32 +0,0 @@
-package org.jboss.seam.examples.booking.session;
-
-import javax.ejb.Local;
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Size;
-import org.jboss.seam.examples.booking.model.User;
-
-/**
- * @author Dan Allen
- */
-public
-@Local
-interface Registrar
-{
- void register();
-
- boolean isRegistrationInvalid();
-
- void notifyIfRegistrationIsInvalid(boolean validationFailed);
-
- User getNewUser();
-
- boolean isRegistered();
-
- @NotNull
- @Size(min = 5, max = 15)
- String getConfirmPassword();
-
- void setConfirmPassword(String password);
-
- void destroy();
-}
Deleted: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/RegistrarBean.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/RegistrarBean.java 2009-05-01 19:42:23 UTC (rev 10742)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/RegistrarBean.java 2009-05-01 19:49:27 UTC (rev 10743)
@@ -1,131 +0,0 @@
-package org.jboss.seam.examples.booking.session;
-
-import javax.annotation.Named;
-import javax.annotation.PreDestroy;
-import javax.context.RequestScoped;
-import javax.ejb.Stateful;
-import javax.inject.Current;
-import javax.inject.Produces;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-import org.jboss.seam.examples.booking.model.User;
-import org.jboss.seam.examples.booking.security.Credentials;
-import org.jboss.seam.examples.booking.security.Identity;
-import org.jboss.seam.international.StatusMessage;
-import org.jboss.seam.international.StatusMessages;
-import ui.RegistrationFormControls;
-
-/**
- * @author Dan Allen
- */
-public
-@Named("registrar")
-@Stateful
-@RequestScoped
-class RegistrarBean implements Registrar
-{
- @PersistenceContext EntityManager em;
-
- @Current StatusMessages statusMessages;
-
- @Current RegistrationFormControls formControls;
-
- @Current Credentials credentials;
-
- @Current Identity identity;
-
- private User newUser;
-
- private String confirmPassword;
-
- private boolean registered;
-
- private boolean registrationInvalid;
-
- public void register()
- {
- if (verifyPasswordsMatch() && verifyUsernameIsAvailable())
- {
- em.persist(newUser);
- credentials.setUsername(newUser.getUsername());
- identity.autoLogin();
- registered = true;
- statusMessages.add("You have been successfully registered as the user {0}!", newUser.getUsername());
- }
- else
- {
- registrationInvalid = true;
- }
- }
-
- public boolean isRegistrationInvalid()
- {
- return registrationInvalid;
- }
-
- // TODO it would be nice to move the conditional to the UI but <f:event> doesn't support if=""
- public void notifyIfRegistrationIsInvalid(boolean validationFailed)
- {
- if (validationFailed || registrationInvalid)
- {
- statusMessages.add(StatusMessage.Severity.WARN, "Invalid registration. Please correct the errors and try again.");
- }
- }
-
- public
- @Produces
- @Named
- @RequestScoped
- User getNewUser()
- {
- newUser = new User();
- return newUser;
- }
-
- public boolean isRegistered()
- {
- return registered;
- }
-
- public String getConfirmPassword()
- {
- return confirmPassword;
- }
-
- public void setConfirmPassword(String password)
- {
- this.confirmPassword = password;
- }
-
- /**
- * Verify that the same password is entered twice.
- */
- private boolean verifyPasswordsMatch()
- {
- if (!newUser.getPassword().equals(confirmPassword))
- {
- statusMessages.addToControl(formControls.getConfirmPasswordControlId(), "Passwords do not match. Please re-type your password.");
- confirmPassword = null;
- return false;
- }
-
- return true;
- }
-
- private boolean verifyUsernameIsAvailable()
- {
- 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());
- return false;
- }
-
- return true;
- }
-
- @PreDestroy
- public void destroy()
- {
- }
-}
Deleted: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/SearchCriteria.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/SearchCriteria.java 2009-05-01 19:42:23 UTC (rev 10742)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/SearchCriteria.java 2009-05-01 19:49:27 UTC (rev 10743)
@@ -1,112 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- *
- * $Id$
- */
-package org.jboss.seam.examples.booking.session;
-
-import java.io.Serializable;
-import javax.annotation.Named;
-import javax.context.SessionScoped;
-
-public
-@Named
-@SessionScoped
-class SearchCriteria implements Serializable
-{
- private static final char SQL_WILDCARD_CHAR = '%';
- private static final String SQL_WILDCARD_STR = String.valueOf(SQL_WILDCARD_CHAR);
- private static final String REPEAT_SQL_WIDCARD_REGEX = SQL_WILDCARD_STR + "+";
- private static final char HUMAN_WILDCARD_CHAR = '*';
-
- private String searchString = "";
- private int pageSize = 5;
- private int page = 0;
-
- public String getSearchPattern()
- {
- if (searchString == null || searchString.length() == 0)
- {
- return SQL_WILDCARD_STR;
- }
-
- StringBuilder pattern = new StringBuilder();
- pattern.append(searchString.toLowerCase().replace(HUMAN_WILDCARD_CHAR, SQL_WILDCARD_CHAR).replaceAll(REPEAT_SQL_WIDCARD_REGEX, SQL_WILDCARD_STR));
- if (pattern.length() == 0 || pattern.charAt(0) != SQL_WILDCARD_CHAR)
- {
- pattern.insert(0, SQL_WILDCARD_CHAR);
- }
- if (pattern.length() > 1 && pattern.charAt(pattern.length() - 1) != SQL_WILDCARD_CHAR)
- {
- pattern.append(SQL_WILDCARD_CHAR);
- }
- return pattern.toString();
- }
-
- public int getPage()
- {
- return page;
- }
-
- public void setPage(int page)
- {
- this.page = page;
- }
-
- public int getPageSize()
- {
- return pageSize;
- }
-
- public void setPageSize(int pageSize)
- {
- this.pageSize = pageSize;
- }
-
- // QUESTION: rename to searchTerm?
- public String getSearchString()
- {
- return searchString;
- }
-
- public void setSearchString(String searchString)
- {
- this.searchString = (searchString != null ? searchString.trim() : null);
- }
-
- public void nextPage()
- {
- page++;
- }
-
- public void previousPage()
- {
- if (page > 0)
- {
- page--;
- }
- }
-
- public void firstPage()
- {
- page = 0;
- }
-}
Deleted: examples/trunk/booking/ejb-jar/src/main/java/ui/BookingFormControls.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/ui/BookingFormControls.java 2009-05-01 19:42:23 UTC (rev 10742)
+++ examples/trunk/booking/ejb-jar/src/main/java/ui/BookingFormControls.java 2009-05-01 19:49:27 UTC (rev 10743)
@@ -1,51 +0,0 @@
-package ui;
-
-import javax.annotation.Named;
-import javax.context.RequestScoped;
-import javax.faces.component.UIComponent;
-
-/**
- * A UI binding bean that can provide access to the local id and client id
- * of selected input components in the booking form.
- *
- * @author Dan Allen
- */
-public
-@Named
-@RequestScoped
-class BookingFormControls
-{
- private UIComponent checkinDate;
-
- private UIComponent checkoutDate;
-
- public UIComponent getCheckinDate()
- {
- return checkinDate;
- }
-
- public String getCheckinDateControlId()
- {
- return checkinDate.getClientId();
- }
-
- public void setCheckinDate(UIComponent checkinDate)
- {
- this.checkinDate = checkinDate;
- }
-
- public UIComponent getCheckoutDate()
- {
- return checkoutDate;
- }
-
- public void setCheckoutDate(UIComponent checkoutDate)
- {
- this.checkoutDate = checkoutDate;
- }
-
- public String getCheckoutDateControlId()
- {
- return checkoutDate.getClientId();
- }
-}
Deleted: examples/trunk/booking/ejb-jar/src/main/java/ui/RegistrationFormControls.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/ui/RegistrationFormControls.java 2009-05-01 19:42:23 UTC (rev 10742)
+++ examples/trunk/booking/ejb-jar/src/main/java/ui/RegistrationFormControls.java 2009-05-01 19:49:27 UTC (rev 10743)
@@ -1,52 +0,0 @@
-package ui;
-
-import javax.annotation.Named;
-import javax.context.RequestScoped;
-import javax.faces.component.UIComponent;
-
-/**
- * A UI binding bean that can provide access to the local id and client id
- * of selected input components in the registration form.
- *
- * @author Dan Allen
- */
-public
-@Named
-@RequestScoped
-class RegistrationFormControls
-{
- private UIComponent username;
-
- private UIComponent confirmPassword;
-
- public UIComponent getConfirmPassword()
- {
- return confirmPassword;
- }
-
- public void setConfirmPassword(UIComponent confirmPassword)
- {
- this.confirmPassword = confirmPassword;
- }
-
- public String getConfirmPasswordControlId()
- {
- return confirmPassword.getClientId();
- }
-
- public UIComponent getUsername()
- {
- return username;
- }
-
- public void setUsername(UIComponent username)
- {
- this.username = username;
- }
-
- public String getUsernameControlId()
- {
- return username.getClientId();
- }
-
-}
16 years, 8 months
Seam SVN: r10742 - examples/trunk/booking.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-05-01 15:42:23 -0400 (Fri, 01 May 2009)
New Revision: 10742
Modified:
examples/trunk/booking/readme.txt
Log:
organize instructions
add highlights, bugs, TODOs and open questions
Modified: examples/trunk/booking/readme.txt
===================================================================
--- examples/trunk/booking/readme.txt 2009-05-01 19:00:17 UTC (rev 10741)
+++ examples/trunk/booking/readme.txt 2009-05-01 19:42:23 UTC (rev 10742)
@@ -7,6 +7,8 @@
Transaction and persistence context management is handled by the EJB 3
container. Validation of input fields is handled by Bean Validation.
+= Prerequisites
+
Please consult the Web Beans reference documentation for instructions on how to
deploy the Web Bean implementation to JBoss AS 5. To upgrade the JSF libraries
to JSF 2.0, go to the Seam jsf-updater-tool module and follow the instructions
@@ -15,16 +17,23 @@
Validation is as simple as putting the JARs in the library directory of the
application server.
+= First steps
+
This example uses a Maven 2 build. To build the EJB and WAR and package them
inside an EAR, execute the following command:
mvn
-Then, set the JBOSS_HOME environment variable to the location of a JBoss AS 5
-installation and start the server. Maven will assume that JBoss AS is running
-on port 8080. Once that's done, you can deploy the application to JBoss AS via
-JMX by executing this command:
+Now you're ready to deploy.
+= Deploying a packaged archive to JBoss AS
+
+First, set the JBOSS_HOME environment variable to the location of a JBoss AS 5
+installation and start the server. You can optionally set the jboss.home Maven
+property in a settings.xml file. Maven assumes JBoss AS is running on port
+8080. (This can be changed in the plugin configuration). Once that's setup, you
+can deploy the application to JBoss AS via JMX by executing this command:
+
mvn -o -f seam-booking-ear/pom.xml jboss:deploy
You can undeploy the application via JMX using this command:
@@ -40,26 +49,71 @@
mvn -o -f seam-booking-ear/pom.xml jboss:harddeploy
-But it's better to use the antrun plugin since it is smarter about what it
-copies, which is bound to the end of the package goal when the explode profile
-is active:
+For ease of development, you probably want to use an exploded archive instead.
+= Deploying an exploded archive to JBoss AS
+
+It's much better to use the antrun plugin over the jboss plugin since it's
+smarter about what it copies to the server. The antrun plugin is bound to the
+end of the package goal when the explode profile is active:
+
mvn -o package -Pexplode
-You can force a restart of the application by activating the restart profile:
+This profile executes an series of Ant tasks that copy the exploded WAR,
+EJB-JAR, and EAR to the JBoss AS deploy directory.
+You can force a restart of the application by activating the restart profile,
+which executes an Ant task bound to the validate phase:
+
mvn -o validate -Prestart
-You can remove the archive by activating the undeploy profile:
+You can remove the archive by activating the undeploy profile, which also
+executes an Ant task bound to the validate phase:
mvn -o validate -Pundeploy
+Finally, you can undeploy and explode all in one command using both the
+undeploy and explode profiles with a standard package build:
+
+ mvn -o package -Pundeploy,explode
+
Note that the -o puts Maven in offline mode so that it doesn't perform time
consuming update checks.
-----------------------
-Unfinished intructions
-----------------------
-When this profile is activated, the maven-antrun-plugin will copy the exploded
-packages for the WAR, EJB-JAR, and EAR to the JBoss AS deploy directory. This
-all happens in the maven package phase.
+= Highlights
+
+- 3 module Maven 2 reactor project (ejb-jar, war, ear)
+- establishes a standard for Seam 3 examples
+- repeat elements are kept to a minimum in the Maven POM files (DRY)
+- JBoss datasource is deployed with the EAR to simplify packaging
+ (-ds.xml doesn't have to be deployed to JBoss AS separately)
+- supports both a packaged and exploded deployment to JBoss AS
+
+= Known issues
+
+(1) Clicking on logout throws an exception
+ java.lang.IllegalStateException: getAttribute: Session already invalidated
+ at org.apache.catalina.session.StandardSession.getAttribute(StandardSession.java:1032)
+
+(2) An attempt to login after logging out throws an exception
+ javax.faces.el.EvaluationException: java.lang.reflect.InvocationTargetException
+ at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
+
+(3) List of bookings not refreshed after a booking is created
+
+(4) Ajax is not working on blur in p:edit form fields (had to disable)
+
+(5) No list of workspaces
+
+(6) Cannot use <f:view> in template or else it will remove the conversation id token from the view root
+
+= Open questions
+
+- How do I clear a contextual bean from a scope, in particular the session scope? This causes issue #1 and #3 above.
+
+- How do I inject an Event object into a stateful component? I get an error that there is a reference to a
+ non-serializable object from a bean declaring a non-passivating scope. This is the reason for issue #3.
+
+= TODO
+
+- use Cargo plugin to support deployment to other Java EE servers (GlassFish)
16 years, 8 months