Seam SVN: r13214 - examples/trunk/booking-simplified/src/main/webapp.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2010-06-17 10:10:52 -0400 (Thu, 17 Jun 2010)
New Revision: 13214
Modified:
examples/trunk/booking-simplified/src/main/webapp/search.xhtml
Log:
remove comment
Modified: examples/trunk/booking-simplified/src/main/webapp/search.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/search.xhtml 2010-06-17 11:32:38 UTC (rev 13213)
+++ examples/trunk/booking-simplified/src/main/webapp/search.xhtml 2010-06-17 14:10:52 UTC (rev 13214)
@@ -93,15 +93,6 @@
<h:commandButton id="moreResults" value="More results" action="#{hotelSearch.nextPage}" rendered="#{hotelSearch.nextPageAvailable}">
<f:ajax render=":searchResults" onevent="controlSpinner"/>
</h:commandButton>
- <ui:remove><!--
- <h:commandLink id="previousResults" value="Previous page" action="#{hotelSearch.previousPage}" rendered="#{hotelSearch.previousPageAvailable}">
- <f:ajax render=":searchResults" onevent="controlSpinner"/>
- </h:commandLink>
- #{' '}
- <h:commandLink id="moreResults" value="More results" action="#{hotelSearch.nextPage}" rendered="#{hotelSearch.nextPageAvailable}">
- <f:ajax render=":searchResults" onevent="controlSpinner"/>
- </h:commandLink>
- --></ui:remove>
</h:form>
</div>
</h:panelGroup>
15 years, 6 months
Seam SVN: r13213 - branches/enterprise/JBPAPP_4_3_FP01/src/main/org/jboss/seam/contexts.
by seam-commits@lists.jboss.org
Author: manaRH
Date: 2010-06-17 07:32:38 -0400 (Thu, 17 Jun 2010)
New Revision: 13213
Modified:
branches/enterprise/JBPAPP_4_3_FP01/src/main/org/jboss/seam/contexts/ServerConversationContext.java
Log:
JBPAPP-4492 - back ported JBSEAM-3512
Modified: branches/enterprise/JBPAPP_4_3_FP01/src/main/org/jboss/seam/contexts/ServerConversationContext.java
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/src/main/org/jboss/seam/contexts/ServerConversationContext.java 2010-06-17 09:34:01 UTC (rev 13212)
+++ branches/enterprise/JBPAPP_4_3_FP01/src/main/org/jboss/seam/contexts/ServerConversationContext.java 2010-06-17 11:32:38 UTC (rev 13213)
@@ -289,12 +289,22 @@
}
removals.clear();
//add new objects
- for (Map.Entry<String, Object> entry: additions.entrySet()) {
- Object attribute = entry.getValue();
- passivate(attribute);
- session.put(getKey(entry.getKey()), attribute);
+ while (!additions.isEmpty())
+ {
+ // Copy the additions entries to a temporary variable, then
+ // clear additions - during passivation, further attributes may
+ // be set in the conversation context so we need to re-iterate
+ // through this process until all additions are passivated
+ Set<Map.Entry<String,Object>> entries = new HashSet<Map.Entry<String,Object>>(additions.entrySet());
+ additions.clear();
+
+ for (Map.Entry<String, Object> entry: entries)
+ {
+ Object attribute = entry.getValue();
+ passivate(attribute);
+ session.put(getKey(entry.getKey()), attribute);
+ }
}
- additions.clear();
}
else
{
15 years, 6 months
Seam SVN: r13212 - examples/trunk/booking-simplified/src/main/webapp/WEB-INF.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2010-06-17 05:34:01 -0400 (Thu, 17 Jun 2010)
New Revision: 13212
Modified:
examples/trunk/booking-simplified/src/main/webapp/WEB-INF/
Log:
ignores
Property changes on: examples/trunk/booking-simplified/src/main/webapp/WEB-INF
___________________________________________________________________
Name: svn:ignore
+ sun-web.xml
lib
15 years, 6 months
Seam SVN: r13211 - in examples/trunk/booking-simplified: src/main/java/org/jboss/seam/examples/booking and 13 other directories.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2010-06-17 05:33:29 -0400 (Thu, 17 Jun 2010)
New Revision: 13211
Added:
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/ChangePasswordValidator.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/ConfirmPasswordValidator.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationNotifier.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationNotifierBean.java
Removed:
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordConfirmValidator.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingEvent.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ConfirmedLiteral.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/controls/
Modified:
examples/trunk/booking-simplified/
examples/trunk/booking-simplified/pom.xml
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManagerBean.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Registrar.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/RegistrarBean.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgent.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgentBean.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistory.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistoryBean.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationDateRangeValidator.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/bootstrap/ApplicationSetupBean.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearchBean.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/Booking.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/User.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/User_.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/CreditCardExpiryYears.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/CreditCardReferenceProducer.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/faces/component/UIInputContainer.java
examples/trunk/booking-simplified/src/main/resources/messages.properties
examples/trunk/booking-simplified/src/main/webapp/WEB-INF/
examples/trunk/booking-simplified/src/main/webapp/WEB-INF/faces-config.xml
examples/trunk/booking-simplified/src/main/webapp/WEB-INF/fragments/account.xhtml
examples/trunk/booking-simplified/src/main/webapp/book.xhtml
examples/trunk/booking-simplified/src/main/webapp/home.xhtml
examples/trunk/booking-simplified/src/main/webapp/hotel.xhtml
examples/trunk/booking-simplified/src/main/webapp/password.xhtml
examples/trunk/booking-simplified/src/main/webapp/register.xhtml
examples/trunk/booking-simplified/src/main/webapp/resources/components/property/input.xhtml
examples/trunk/booking-simplified/src/test/java/org/jboss/seam/examples/booking/booking/BookingAgentTest.java
Log:
major cleanup
add email to user
use xval for registration form
fix bugs in UIInputContainer
add automatic ajax to UIInputContainer
Property changes on: examples/trunk/booking-simplified
___________________________________________________________________
Name: svn:ignore
- .settings
.classpath
.project
faces-config.NavData
nbactions*
target
+ .settings
.classpath
.project
faces-config.NavData
nbactions*
target
.pom.xml.swp
Modified: examples/trunk/booking-simplified/pom.xml
===================================================================
--- examples/trunk/booking-simplified/pom.xml 2010-06-17 01:01:35 UTC (rev 13210)
+++ examples/trunk/booking-simplified/pom.xml 2010-06-17 09:33:29 UTC (rev 13211)
@@ -108,7 +108,16 @@
</exclusions>
</dependency>
+ <!-- Bean Validation Implementation; provides portable constraints @NotEmpty, @Email and @Url -->
+ <!-- Hibernate Validator is the only JSR-303 implementation at the moment, so we can assume it's provided -->
<dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-validator</artifactId>
+ <version>4.0.0.GA</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<scope>provided</scope>
@@ -135,12 +144,14 @@
<scope>test</scope>
</dependency>
+ <!--
<dependency>
<groupId>org.codehaus.groovy.maven.runtime</groupId>
<artifactId>gmaven-runtime-1.6</artifactId>
<version>1.0</version>
<scope>test</scope>
</dependency>
+ -->
</dependencies>
@@ -153,13 +164,14 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
- <source>1.6</source>
- <target>1.6</target>
- <!-- don't waste time on generation -->
+ <source>1.5</source>
+ <target>1.5</target>
+ <!-- activate only when you need to generate the metamodel -->
<compilerArgument>-proc:none</compilerArgument>
</configuration>
</plugin>
+ <!--
<plugin>
<groupId>org.codehaus.groovy.maven</groupId>
<artifactId>gmaven-plugin</artifactId>
@@ -172,6 +184,7 @@
</execution>
</executions>
</plugin>
+ -->
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/ChangePasswordValidator.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/ChangePasswordValidator.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/ChangePasswordValidator.java 2010-06-17 09:33:29 UTC (rev 13211)
@@ -0,0 +1,59 @@
+package org.jboss.seam.examples.booking.account;
+
+import java.util.Map;
+import javax.enterprise.inject.Instance;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIInput;
+import javax.faces.context.FacesContext;
+import javax.faces.validator.FacesValidator;
+import javax.faces.validator.Validator;
+import javax.faces.validator.ValidatorException;
+import javax.inject.Inject;
+import org.jboss.seam.examples.booking.Bundles;
+import org.jboss.seam.examples.booking.model.User;
+import org.jboss.seam.faces.validation.InputField;
+import org.jboss.seam.international.status.builder.BundleKey;
+import org.jboss.seam.international.status.builder.BundleTemplateMessage;
+
+/**
+ * @author Dan Allen
+ */
+@FacesValidator(value = "changePasswordValidator")
+public class ChangePasswordValidator implements Validator
+ // extending throws an unsatisified dependency exception
+ //extends ConfirmPasswordValidator
+{
+ @Inject
+ private Instance<BundleTemplateMessage> messageBuilder;
+
+ @Inject
+ @Authenticated
+ private User currentUser;
+
+ @Inject
+ @InputField
+ private String currentPassword;
+
+ @Override
+ public void validate(FacesContext ctx, UIComponent form, Object value) throws ValidatorException
+ {
+ Map<String, UIInput> fieldMap = (Map<String, UIInput>) value;
+ if (currentUser.getPassword() != null && !currentUser.getPassword().equals(currentPassword))
+ {
+ /*
+ * This is an ugly way to put i18n in FacesMessages:
+ * https://jira.jboss.org/browse/SEAMFACES-24
+ */
+ throw new ValidatorException(
+ new FacesMessage(messageBuilder.get().text(
+ new BundleKey(Bundles.MESSAGES, "account.passwordNotConfirmed"))
+ .targets(fieldMap.get("oldPassword").getClientId())
+ .build().getText()));
+ }
+
+ // TODO enable when we can extend
+ //super.validate(ctx, form, value);
+ }
+
+}
Copied: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/ConfirmPasswordValidator.java (from rev 13210, examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordConfirmValidator.java)
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/ConfirmPasswordValidator.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/ConfirmPasswordValidator.java 2010-06-17 09:33:29 UTC (rev 13211)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.examples.booking.account;
+
+import javax.enterprise.inject.Instance;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.validator.FacesValidator;
+import javax.faces.validator.Validator;
+import javax.faces.validator.ValidatorException;
+import javax.inject.Inject;
+import org.jboss.seam.examples.booking.Bundles;
+
+import org.jboss.seam.faces.validation.InputField;
+import org.jboss.seam.international.status.builder.BundleKey;
+import org.jboss.seam.international.status.builder.BundleTemplateMessage;
+
+/**
+ * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
+ */
+@FacesValidator(value = "confirmPasswordValidator")
+public class ConfirmPasswordValidator implements Validator
+{
+ @Inject
+ private Instance<BundleTemplateMessage> messageBuilder;
+
+ @Inject
+ @InputField
+ private String newPassword;
+
+ @Inject
+ @InputField
+ private String confirmPassword;
+
+ public void validate(final FacesContext ctx, final UIComponent c, final Object value) throws ValidatorException
+ {
+ if (newPassword != null && !newPassword.equals(confirmPassword))
+ {
+ throw new ValidatorException(
+ new FacesMessage(messageBuilder.get().text(
+ new BundleKey(Bundles.MESSAGES, "account.passwordsDoNotMatch"))
+ .build().getText()));
+ }
+ }
+
+}
Deleted: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordConfirmValidator.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordConfirmValidator.java 2010-06-17 01:01:35 UTC (rev 13210)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordConfirmValidator.java 2010-06-17 09:33:29 UTC (rev 13211)
@@ -1,83 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.seam.examples.booking.account;
-
-import javax.faces.application.FacesMessage;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.validator.FacesValidator;
-import javax.faces.validator.Validator;
-import javax.faces.validator.ValidatorException;
-import javax.inject.Inject;
-import org.jboss.seam.examples.booking.Bundles;
-
-import org.jboss.seam.examples.booking.model.User;
-import org.jboss.seam.faces.validation.InputField;
-import org.jboss.seam.international.status.MessageFactory;
-import org.jboss.seam.international.status.builder.BundleKey;
-
-/**
- * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
- */
-@FacesValidator(value = "passwordConfirmValidator")
-public class PasswordConfirmValidator implements Validator
-{
- @Inject
- @Authenticated
- private User currentUser;
-
- @Inject
- private MessageFactory msg;
-
- @Inject
- @InputField
- private String oldPassword;
-
- @Inject
- @InputField
- private String newPassword;
-
- @Inject
- @InputField
- private String confirmNewPassword;
-
- public void validate(final FacesContext context, final UIComponent comp, final Object components) throws ValidatorException
- {
- if ((currentUser.getPassword() != null) && !currentUser.getPassword().equals(oldPassword))
- {
- /*
- * This is an ugly way to put i18n in FacesMessages:
- * https://jira.jboss.org/browse/SEAMFACES-24
- */
- throw new ValidatorException(
- new FacesMessage(msg.info(
- new BundleKey(Bundles.MESSAGES, "account.passwordNotConfirmed"))
- .build().getText()));
- }
-
- if ((newPassword != null) && !newPassword.equals(confirmNewPassword))
- {
- throw new ValidatorException(new FacesMessage(msg.info(new BundleKey(Bundles.MESSAGES, "account.passwordsDoNotMatch")).build().getText()));
- }
- }
-
-}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManagerBean.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManagerBean.java 2010-06-17 01:01:35 UTC (rev 13210)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManagerBean.java 2010-06-17 09:33:29 UTC (rev 13211)
@@ -58,7 +58,8 @@
public void changePassword()
{
em.merge(user);
- messages.info(new BundleKey(Bundles.MESSAGES, "account.passwordChanged")).textDefault("Password successfully updated.");
+ messages.info(new BundleKey(Bundles.MESSAGES, "account.passwordChanged"))
+ .textDefault("Password successfully updated.");
changed = true;
}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Registrar.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Registrar.java 2010-06-17 01:01:35 UTC (rev 13210)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Registrar.java 2010-06-17 09:33:29 UTC (rev 13211)
@@ -22,6 +22,7 @@
package org.jboss.seam.examples.booking.account;
import javax.ejb.Local;
+import javax.faces.component.UIInput;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.jboss.seam.examples.booking.model.User;
@@ -36,7 +37,7 @@
boolean isRegistrationInvalid();
- void notifyIfRegistrationIsInvalid(boolean validationFailed);
+ void notifyIfRegistrationIsInvalid();
User getNewUser();
@@ -47,4 +48,8 @@
String getConfirmPassword();
void setConfirmPassword(String password);
+
+ UIInput getUsernameInput();
+
+ void setUsernameInput(UIInput input);
}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/RegistrarBean.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/RegistrarBean.java 2010-06-17 01:01:35 UTC (rev 13210)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/RegistrarBean.java 2010-06-17 09:33:29 UTC (rev 13211)
@@ -24,13 +24,14 @@
import javax.ejb.Stateful;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.inject.Produces;
+import javax.faces.component.UIInput;
+import javax.faces.context.FacesContext;
import javax.inject.Inject;
import javax.inject.Named;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.jboss.seam.examples.booking.Bundles;
-import org.jboss.seam.examples.booking.controls.RegistrationFormControls;
import org.jboss.seam.examples.booking.model.User;
import org.jboss.seam.international.status.Messages;
import org.jboss.seam.international.status.builder.BundleKey;
@@ -39,8 +40,8 @@
* @author Dan Allen
*/
@Stateful
+@RequestScoped
@Named("registrar")
-@RequestScoped
public class RegistrarBean implements Registrar
{
@PersistenceContext
@@ -50,8 +51,10 @@
private Messages messages;
@Inject
- private RegistrationFormControls formControls;
+ private FacesContext facesContext;
+ private UIInput usernameInput;
+
private final User newUser = new User();
private String confirmPassword;
@@ -62,11 +65,14 @@
public void register()
{
- if (verifyPasswordsMatch() && verifyUsernameIsAvailable())
+ if (verifyUsernameIsAvailable())
{
registered = true;
em.persist(newUser);
- messages.info(new BundleKey(Bundles.MESSAGES, "registration.registered")).textDefault("You have been successfully registered as the user {0}!").textParams(newUser.getUsername());
+
+ messages.info(new BundleKey(Bundles.MESSAGES, "registration.registered"))
+ .textDefault("You have been successfully registered as the user {0}! You can now login.")
+ .textParams(newUser.getUsername());
}
else
{
@@ -79,19 +85,28 @@
return registrationInvalid;
}
- // TODO it would be nice to move the conditional to the UI but <f:event>
- // doesn't support if=""
- public void notifyIfRegistrationIsInvalid(final boolean validationFailed)
+ /**
+ * This method just shows another approach to adding a status message.
+ * <p>
+ * Invoked by:
+ * </p>
+ *
+ * <pre>
+ * <f:event type="preRenderView" listener="#{registrar.notifyIfRegistrationIsInvalid}"/>
+ * </pre>
+ */
+ public void notifyIfRegistrationIsInvalid()
{
- if (validationFailed || registrationInvalid)
+ if (facesContext.isValidationFailed() || registrationInvalid)
{
- messages.warn(new BundleKey(Bundles.MESSAGES, "registration.invalid")).textDefault("Invalid registration. Please correct the errors and try again.");
+ messages.warn(new BundleKey(Bundles.MESSAGES, "registration.invalid"))
+ .textDefault("Invalid registration. Please correct the errors and try again.");
}
}
- @Named("newUser")
+ @Produces
@RequestScoped
- @Produces
+ @Named
public User getNewUser()
{
return newUser;
@@ -112,19 +127,14 @@
this.confirmPassword = password;
}
- /**
- * Verify that the same password is entered twice.
- */
- private boolean verifyPasswordsMatch()
+ public UIInput getUsernameInput()
{
- if (!newUser.getPassword().equals(confirmPassword))
- {
- messages.warn(new BundleKey(Bundles.MESSAGES, "account.passwordsDoNotMatch")).textDefault("Passwords do not match. Please re-type your password.").targets(formControls.getConfirmPasswordControlId());
- confirmPassword = null;
- return false;
- }
+ return usernameInput;
+ }
- return true;
+ public void setUsernameInput(UIInput usernameInput)
+ {
+ this.usernameInput = usernameInput;
}
private boolean verifyUsernameIsAvailable()
@@ -132,10 +142,14 @@
User existing = em.find(User.class, newUser.getUsername());
if (existing != null)
{
- messages.warn(new BundleKey("messages", "account.usernameTaken")).textDefault("The username '{0}' is already taken. Please choose another username.").targets(formControls.getUsernameControlId()).textParams(newUser.getUsername());
+ messages.warn(new BundleKey("messages", "account.usernameTaken"))
+ .textDefault("The username '{0}' is already taken. Please choose another username.")
+ .targets(usernameInput.getClientId())
+ .textParams(newUser.getUsername());
return false;
}
return true;
}
+
}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgent.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgent.java 2010-06-17 01:01:35 UTC (rev 13210)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgent.java 2010-06-17 09:33:29 UTC (rev 13211)
@@ -42,8 +42,10 @@
void confirm();
- Hotel getHotelSelection();
+ void onBookingComplete(Booking booking);
+ Hotel getSelectedHotel();
+
Booking getBooking();
boolean isBookingValid();
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgentBean.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgentBean.java 2010-06-17 01:01:35 UTC (rev 13210)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgentBean.java 2010-06-17 09:33:29 UTC (rev 13211)
@@ -23,13 +23,11 @@
import static javax.persistence.PersistenceContextType.EXTENDED;
-import java.util.Calendar;
import javax.ejb.Stateful;
import javax.enterprise.context.ConversationScoped;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.inject.Produces;
-import javax.enterprise.inject.spi.BeanManager;
import javax.inject.Inject;
import javax.inject.Named;
import javax.persistence.EntityManager;
@@ -41,17 +39,21 @@
import org.jboss.seam.examples.booking.model.User;
import org.jboss.seam.faces.context.conversation.Begin;
import org.jboss.seam.faces.context.conversation.End;
-import org.jboss.seam.international.status.MessageFactory;
import org.jboss.seam.international.status.Messages;
import org.jboss.seam.international.status.builder.BundleKey;
import org.slf4j.Logger;
import com.ocpsoft.pretty.time.PrettyTime;
+import javax.enterprise.event.Event;
+import javax.enterprise.event.Observes;
+import javax.enterprise.event.TransactionPhase;
+import javax.enterprise.inject.Instance;
import org.jboss.seam.examples.booking.Bundles;
+import org.jboss.seam.international.status.builder.TemplateMessage;
-@Named("bookingAgent")
@Stateful
@ConversationScoped
+@Named("bookingAgent")
public class BookingAgentBean implements BookingAgent
{
@Inject
@@ -61,7 +63,7 @@
private EntityManager em;
@Inject
- private MessageFactory msg;
+ private Instance<TemplateMessage> messageBuilder;
@Inject
private Messages messages;
@@ -70,9 +72,8 @@
@Authenticated
private User user;
- // @Inject @Fires @Confirmed Event<BookingEvent> bookingConfirmedEvent;
- @Inject
- private BeanManager manager;
+ @Inject @Confirmed
+ private Event<Booking> bookingConfirmedEventSrc;
private Hotel hotelSelection;
@@ -87,21 +88,22 @@
hotelSelection = em.find(Hotel.class, id);
if (hotelSelection != null)
{
- log.info(msg.info("Selected the {0} in {1}").textParams(hotelSelection.getName(), hotelSelection.getCity()).build().getText());
+ log.info(messageBuilder.get().text("Selected the {0} in {1}")
+ .textParams(hotelSelection.getName(), hotelSelection.getCity()).build().getText());
}
}
public void bookHotel()
{
- booking = new Booking(hotelSelection, user);
- // QUESTION push logic into Booking?
- Calendar calendar = Calendar.getInstance();
- calendar.add(Calendar.DAY_OF_MONTH, 1);
- booking.setCheckinDate(calendar.getTime());
- calendar.add(Calendar.DAY_OF_MONTH, 1);
- booking.setCheckoutDate(calendar.getTime());
+ booking = new Booking(hotelSelection, user, 7, 2);
hotelSelection = null;
- messages.info(new BundleKey(Bundles.MESSAGES, "booking.initiated")).textDefault("You've initiated a booking at the {0}.").textParams(booking.getHotel().getName());
+
+ // for demo convenience
+ booking.setCreditCardNumber("1111222233334444");
+
+ messages.info(new BundleKey(Bundles.MESSAGES, "booking.initiated"))
+ .textDefault("You've initiated a booking at the {0}.")
+ .textParams(booking.getHotel().getName());
}
public void validate()
@@ -114,13 +116,7 @@
public void confirm()
{
em.persist(booking);
- // FIXME can't inject event object into bean with passivating scope
- manager.fireEvent(new BookingEvent(booking), ConfirmedLiteral.INSTANCE);
- log.info(msg.info("New booking at the {0} confirmed for {1}")
- .textParams(booking.getHotel().getName(), booking.getUser().getName()).build().getText());
- messages.info(new BundleKey(Bundles.MESSAGES, "booking.confirmed"))
- .textDefault("You're booked to stay at the {0} {1}.")
- .textParams(booking.getHotel().getName(), new PrettyTime().format(booking.getCheckinDate()));
+ bookingConfirmedEventSrc.fire(booking);
}
@End
@@ -130,6 +126,16 @@
hotelSelection = null;
}
+ public void onBookingComplete(@Observes(during = TransactionPhase.AFTER_SUCCESS)
+ @Confirmed final Booking booking)
+ {
+ log.info(messageBuilder.get().text("New booking at the {0} confirmed for {1}")
+ .textParams(booking.getHotel().getName(), booking.getUser().getName()).build().getText());
+ messages.info(new BundleKey(Bundles.MESSAGES, "booking.confirmed"))
+ .textDefault("You're booked to stay at the {0} {1}.")
+ .textParams(booking.getHotel().getName(), new PrettyTime().format(booking.getCheckinDate()));
+ }
+
@Produces
@Named
@ConversationScoped
@@ -141,7 +147,7 @@
@Produces
@Named("hotel")
@RequestScoped
- public Hotel getHotelSelection()
+ public Hotel getSelectedHotel()
{
return booking != null ? booking.getHotel() : hotelSelection;
}
Deleted: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingEvent.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingEvent.java 2010-06-17 01:01:35 UTC (rev 13210)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingEvent.java 2010-06-17 09:33:29 UTC (rev 13211)
@@ -1,46 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.seam.examples.booking.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;
- }
-}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistory.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistory.java 2010-06-17 01:01:35 UTC (rev 13210)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistory.java 2010-06-17 09:33:29 UTC (rev 13211)
@@ -35,5 +35,5 @@
void cancelBooking(Booking booking);
- void afterBookingConfirmed(BookingEvent bookingEvent);
+ void onBookingComplete(Booking booking);
}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistoryBean.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistoryBean.java 2010-06-17 01:01:35 UTC (rev 13210)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistoryBean.java 2010-06-17 09:33:29 UTC (rev 13211)
@@ -21,11 +21,14 @@
*/
package org.jboss.seam.examples.booking.booking;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
import java.util.List;
import javax.ejb.Stateful;
import javax.enterprise.context.SessionScoped;
import javax.enterprise.event.Observes;
+import javax.enterprise.event.Reception;
import javax.enterprise.event.TransactionPhase;
import javax.enterprise.inject.Instance;
import javax.enterprise.inject.Produces;
@@ -86,14 +89,19 @@
return bookingsForUser;
}
- public void afterBookingConfirmed(@Observes(during = TransactionPhase.AFTER_SUCCESS)
- @Confirmed final BookingEvent bookingEvent)
+ public void onBookingComplete(@Observes(during = TransactionPhase.AFTER_SUCCESS, notifyObserver = Reception.IF_EXISTS)
+ @Confirmed final Booking booking)
{
// optimization, save the db call
if (bookingsForUser != null)
{
- bookingsForUser.add(bookingEvent.getBooking());
+ log.info("Adding new booking to user's cached booking history");
+ bookingsForUser.add(booking);
}
+ else
+ {
+ log.info("User's booking history not loaded. Skipping cache update.");
+ }
}
public void cancelBooking(final Booking selectedBooking)
@@ -103,11 +111,15 @@
if (booking != null)
{
em.remove(booking);
- messages.info(new BundleKey(Bundles.MESSAGES, "booking.canceled")).textDefault("The booking at the {0} on {1,date} has been canceled.").textParams(selectedBooking.getHotel().getName(), selectedBooking.getCheckinDate());
+ messages.info(new BundleKey(Bundles.MESSAGES, "booking.canceled"))
+ .textDefault("The booking at the {0} on {1} has been canceled.")
+ .textParams(selectedBooking.getHotel().getName(),
+ DateFormat.getDateInstance(SimpleDateFormat.MEDIUM).format(selectedBooking.getCheckinDate()));
}
else
{
- messages.info(new BundleKey(Bundles.MESSAGES, "booking.doesNotExist")).textDefault("Our records indicate that the booking you selected has already been canceled.");
+ messages.info(new BundleKey(Bundles.MESSAGES, "booking.doesNotExist"))
+ .textDefault("Our records indicate that the booking you selected has already been canceled.");
}
bookingsForUser.remove(selectedBooking);
Deleted: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ConfirmedLiteral.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ConfirmedLiteral.java 2010-06-17 01:01:35 UTC (rev 13210)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ConfirmedLiteral.java 2010-06-17 09:33:29 UTC (rev 13211)
@@ -1,29 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, 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.
- */
-package org.jboss.seam.examples.booking.booking;
-
-import javax.enterprise.util.AnnotationLiteral;
-
-public class ConfirmedLiteral extends AnnotationLiteral<Confirmed> implements Confirmed
-{
- public static final Confirmed INSTANCE = new ConfirmedLiteral();
-}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationDateRangeValidator.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationDateRangeValidator.java 2010-06-17 01:01:35 UTC (rev 13210)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationDateRangeValidator.java 2010-06-17 09:33:29 UTC (rev 13211)
@@ -23,8 +23,11 @@
import java.util.Calendar;
import java.util.Date;
+import java.util.Map;
+import javax.enterprise.inject.Instance;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
+import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;
import javax.faces.validator.FacesValidator;
import javax.faces.validator.Validator;
@@ -32,8 +35,8 @@
import javax.inject.Inject;
import org.jboss.seam.examples.booking.Bundles;
import org.jboss.seam.faces.validation.InputField;
-import org.jboss.seam.international.status.MessageFactory;
import org.jboss.seam.international.status.builder.BundleKey;
+import org.jboss.seam.international.status.builder.BundleTemplateMessage;
/**
* A cross-field validator that validates the begin date
@@ -42,7 +45,8 @@
* @author Dan Allen
*/
@FacesValidator("reservationDateRangeValidator")
-public class ReservationDateRangeValidator implements Validator {
+public class ReservationDateRangeValidator implements Validator
+{
@Inject
@InputField
private Date beginDate;
@@ -52,28 +56,27 @@
private Date endDate;
@Inject
- private MessageFactory msg;
+ private Instance<BundleTemplateMessage> messageBuilder;
@Override
- public void validate(FacesContext ctx, UIComponent c, Object value) throws ValidatorException
+ public void validate(FacesContext ctx, UIComponent form, Object value) throws ValidatorException
{
+ Map<String, UIInput> fieldMap = (Map<String, UIInput>) value;
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_MONTH, -1);
if (beginDate.before(calendar.getTime()))
{
- String message = msg.info(new BundleKey(Bundles.MESSAGES, "booking.checkInNotFutureDate"))
- .textDefault("Check-in date must be in the future")
- // FIXME this information should come through via injection
- .targets("checkInDate:input")
+ String message = messageBuilder.get().text(new BundleKey(Bundles.MESSAGES, "booking.checkInNotFutureDate"))
+ // FIXME the component should come through via injection
+ .targets(fieldMap.get("beginDate").getClientId())
.build().getText();
throw new ValidatorException(new FacesMessage(message));
}
else if (!beginDate.before(endDate))
{
- String message = msg.info(new BundleKey(Bundles.MESSAGES, "booking.checkOutBeforeCheckIn"))
- .textDefault("Check-out date must be after check-in date")
- // FIXME this information should come through via injection
- .targets("checkOutDate:input")
+ String message = messageBuilder.get().text(new BundleKey(Bundles.MESSAGES, "booking.checkOutBeforeCheckIn"))
+ // FIXME the component should come through via injection
+ .targets(fieldMap.get("endDate").getClientId())
.build().getText();
throw new ValidatorException(new FacesMessage(message));
}
Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationNotifier.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationNotifier.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationNotifier.java 2010-06-17 09:33:29 UTC (rev 13211)
@@ -0,0 +1,8 @@
+package org.jboss.seam.examples.booking.booking;
+
+import org.jboss.seam.examples.booking.model.Booking;
+
+public interface ReservationNotifier
+{
+ void onBookingComplete(Booking booking);
+}
Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationNotifierBean.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationNotifierBean.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationNotifierBean.java 2010-06-17 09:33:29 UTC (rev 13211)
@@ -0,0 +1,19 @@
+package org.jboss.seam.examples.booking.booking;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.event.TransactionPhase;
+import javax.inject.Inject;
+import org.jboss.seam.examples.booking.model.Booking;
+import org.slf4j.Logger;
+
+public class ReservationNotifierBean implements ReservationNotifier
+{
+ @Inject
+ private Logger log;
+
+ public void onBookingComplete(@Observes(during = TransactionPhase.AFTER_SUCCESS)
+ @Confirmed final Booking booking)
+ {
+ log.info("In a real-world application, send e-mail containing reservation information to " + booking.getUser().getEmailWithName());
+ }
+}
\ No newline at end of file
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/bootstrap/ApplicationSetupBean.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/bootstrap/ApplicationSetupBean.java 2010-06-17 01:01:35 UTC (rev 13210)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/bootstrap/ApplicationSetupBean.java 2010-06-17 09:33:29 UTC (rev 13211)
@@ -55,11 +55,11 @@
public ApplicationSetupBean()
{
- users.add(new User("Dan Allen", "dan", "laurel"));
- users.add(new User("Pete Muir", "pete", "edinburgh"));
- users.add(new User("Lincoln Baxter III", "lincoln", "charlotte"));
- users.add(new User("Shane", "shane", "brisbane"));
- users.add(new User("Gavin King", "gavin", "mexico"));
+ users.add(new User("Dan Allen", "dan", "dan(a)example.com", "laurel"));
+ users.add(new User("Pete Muir", "pete", "pete(a)example.com", "edinburgh"));
+ users.add(new User("Lincoln Baxter III", "lincoln", "lincoln(a)example.com", "charlotte"));
+ users.add(new User("Shane Bryzak", "shane", "shane(a)example.com", "brisbane"));
+ users.add(new User("Gavin King", "gavin", "gavin(a)example.com", "mexico"));
hotels.add(new Hotel(129, 3, "Marriott Courtyard", "Tower Place, Buckhead", "Atlanta", "GA", "30305", "USA"));
hotels.add(new Hotel(84, 4, "Doubletree Atlanta-Buckhead", "3342 Peachtree Road NE", "Atlanta", "GA", "30326", "USA"));
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearchBean.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearchBean.java 2010-06-17 01:01:35 UTC (rev 13210)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearchBean.java 2010-06-17 09:33:29 UTC (rev 13211)
@@ -25,8 +25,8 @@
import java.util.List;
import javax.ejb.Stateful;
-import javax.enterprise.context.Dependent;
import javax.enterprise.context.SessionScoped;
+import javax.enterprise.inject.Instance;
import javax.enterprise.inject.Produces;
import javax.inject.Inject;
import javax.inject.Named;
@@ -38,12 +38,12 @@
import org.jboss.seam.examples.booking.model.Hotel;
import org.jboss.seam.examples.booking.model.Hotel_;
-import org.jboss.seam.international.status.MessageFactory;
+import org.jboss.seam.international.status.builder.TemplateMessage;
import org.slf4j.Logger;
-@Named("hotelSearch")
@Stateful
@SessionScoped
+@Named("hotelSearch")
public class HotelSearchBean implements HotelSearch
{
@Inject
@@ -56,7 +56,7 @@
private SearchCriteria criteria;
@Inject
- private MessageFactory msg;
+ private Instance<TemplateMessage> messageBuilder;
private boolean nextPageAvailable = false;
@@ -80,12 +80,9 @@
queryHotels(criteria);
}
- public @Produces
+ @Produces
@Named
- @Dependent
- // @RequestScoped // if enabled, variable doesn't get updated after the
- // action is executed w/o a redirect
- List<Hotel> getHotels()
+ public List<Hotel> getHotels()
{
return hotels;
}
@@ -128,7 +125,7 @@
{
hotels = results;
}
- log.info(msg.info("Found {0} hotel(s) matching search term [ {1} ] (limit {2})")
+ log.info(messageBuilder.get().text("Found {0} hotel(s) matching search term [ {1} ] (limit {2})")
.textParams(hotels.size(), criteria.getQuery(), criteria.getPageSize()).build().getText());
}
}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/Booking.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/Booking.java 2010-06-17 01:01:35 UTC (rev 13210)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/Booking.java 2010-06-17 09:33:29 UTC (rev 13211)
@@ -26,6 +26,7 @@
import java.io.Serializable;
import java.math.BigDecimal;
import java.text.DateFormat;
+import java.util.Calendar;
import java.util.Date;
import javax.enterprise.inject.Typed;
@@ -71,13 +72,15 @@
{
}
- public Booking(Hotel hotel, User user)
+ public Booking(Hotel hotel, User user, int daysFromNow, int nights)
{
this.hotel = hotel;
this.user = user;
this.creditCardName = user.getName();
this.smoking = false;
this.beds = 1;
+ setReservationDates(daysFromNow, nights);
+ creditCardExpiryMonth = Calendar.getInstance().get(Calendar.MONTH) + 1;
}
@Id
@@ -198,6 +201,12 @@
this.creditCardName = creditCardName;
}
+ /**
+ * The credit card expiration month, represented using a 1-based
+ * numeric value (i.e., Jan = 1, Feb = 2, ...).
+ *
+ * @return 1-based numeric month value
+ */
public int getCreditCardExpiryMonth()
{
return creditCardExpiryMonth;
@@ -208,6 +217,11 @@
this.creditCardExpiryMonth = creditCardExpiryMonth;
}
+ /**
+ * The credit card expiration year.
+ *
+ * @return numberic year value
+ */
public int getCreditCardExpiryYear()
{
return creditCardExpiryYear;
@@ -239,6 +253,24 @@
return (int) (checkoutDate.getTime() - checkinDate.getTime()) / 1000 / 60 / 60 / 24;
}
+ /**
+ * Initialize the check-in and check-out dates.
+ *
+ * @param daysFromNow Number of days the stay will begin from now
+ * @param nights Length of the stay in number of nights
+ */
+ public void setReservationDates(int daysFromNow, int nights)
+ {
+ Calendar refDate = Calendar.getInstance();
+ refDate.set(
+ refDate.get(Calendar.YEAR),
+ refDate.get(Calendar.MONTH),
+ refDate.get(Calendar.DAY_OF_MONTH) + daysFromNow, 0, 0, 0);
+ setCheckinDate(refDate.getTime());
+ refDate.add(Calendar.DAY_OF_MONTH, nights);
+ setCheckoutDate(refDate.getTime());
+ }
+
@Override
public String toString()
{
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/User.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/User.java 2010-06-17 01:01:35 UTC (rev 13210)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/User.java 2010-06-17 09:33:29 UTC (rev 13211)
@@ -27,9 +27,11 @@
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
+import javax.persistence.Transient;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
+import org.hibernate.validator.constraints.Email;
/**
* <p>
@@ -48,25 +50,27 @@
private String username;
private String password;
private String name;
+ private String email;
public User()
{
}
- public User(final String name, final String username)
+ public User(final String name, final String username, final String email)
{
this.name = name;
this.username = username;
+ this.email = email;
}
- public User(final String name, final String username, final String password)
+ public User(final String name, final String username, final String email, final String password)
{
- this(name, username);
+ this(name, username, email);
this.password = password;
}
@NotNull
- @Size(max = 100)
+ @Size(min = 1, max = 100)
public String getName()
{
return name;
@@ -103,6 +107,24 @@
this.username = username;
}
+ @NotNull
+ @Email
+ public String getEmail()
+ {
+ return email;
+ }
+
+ public void setEmail(final String email)
+ {
+ this.email = email;
+ }
+
+ @Transient
+ public String getEmailWithName()
+ {
+ return name + " <" + email + ">";
+ }
+
@Override
public String toString()
{
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/User_.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/User_.java 2010-06-17 01:01:35 UTC (rev 13210)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/User_.java 2010-06-17 09:33:29 UTC (rev 13211)
@@ -21,15 +21,16 @@
*/
package org.jboss.seam.examples.booking.model;
-import javax.persistence.metamodel.SingularAttribute;
-import javax.persistence.metamodel.StaticMetamodel;
+import javax.persistence.metamodel.SingularAttribute;
+import javax.persistence.metamodel.StaticMetamodel;
@StaticMetamodel(User.class)
public abstract class User_ {
+ public static volatile SingularAttribute<User, String> name;
public static volatile SingularAttribute<User, String> username;
- public static volatile SingularAttribute<User, String> name;
public static volatile SingularAttribute<User, String> password;
+ public static volatile SingularAttribute<User, String> email;
}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/CreditCardExpiryYears.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/CreditCardExpiryYears.java 2010-06-17 01:01:35 UTC (rev 13210)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/CreditCardExpiryYears.java 2010-06-17 09:33:29 UTC (rev 13211)
@@ -27,7 +27,6 @@
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Documented;
-import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/CreditCardReferenceProducer.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/CreditCardReferenceProducer.java 2010-06-17 01:01:35 UTC (rev 13210)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/CreditCardReferenceProducer.java 2010-06-17 09:33:29 UTC (rev 13211)
@@ -56,9 +56,9 @@
{
List<Integer> years = new ArrayList<Integer>(8);
int currentYear = Calendar.getInstance().get(Calendar.YEAR);
- for (int y = currentYear; y <= (currentYear + 8); y++)
+ for (int i = 0; i < 8; i++)
{
- years.add(y);
+ years.add(currentYear + i);
}
return years;
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/faces/component/UIInputContainer.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/faces/component/UIInputContainer.java 2010-06-17 01:01:35 UTC (rev 13210)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/faces/component/UIInputContainer.java 2010-06-17 09:33:29 UTC (rev 13211)
@@ -23,8 +23,10 @@
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import javax.el.ValueReference;
import javax.faces.FacesException;
@@ -34,9 +36,12 @@
import javax.faces.component.NamingContainer;
import javax.faces.component.UIComponent;
import javax.faces.component.UIComponentBase;
+import javax.faces.component.UIInput;
import javax.faces.component.UIMessage;
import javax.faces.component.UINamingContainer;
import javax.faces.component.UIViewRoot;
+import javax.faces.component.behavior.AjaxBehavior;
+import javax.faces.component.behavior.ClientBehavior;
import javax.faces.component.html.HtmlOutputLabel;
import javax.faces.context.FacesContext;
import javax.faces.validator.BeanValidator;
@@ -197,6 +202,8 @@
return "message";
}
+ private InputContainerElements elements;
+
@Override
public void encodeBegin(final FacesContext context) throws IOException
{
@@ -207,19 +214,15 @@
super.encodeBegin(context);
- InputContainerElements elements = scan(getFacet(UIComponent.COMPOSITE_FACET_NAME), null, context);
+ elements = scan(getFacet(UIComponent.COMPOSITE_FACET_NAME), context);
// assignIds(elements, context);
wire(elements, context);
getAttributes().put(getElementsAttributeName(), elements);
- if (elements.hasValidationError())
- {
- getAttributes().put(getInvalidAttributeName(), true);
- }
+ getAttributes().put(getInvalidAttributeName(), elements.hasValidationError());
- // set the required attribute, but only if the user didn't already assign
- // it
+ // set the required attribute, but only if the user didn't already assign it
if (!getAttributes().containsKey(getRequiredAttributeName()) && elements.hasRequiredInput())
{
getAttributes().put(getRequiredAttributeName(), true);
@@ -250,6 +253,16 @@
{
endContainerElement(context);
}
+
+ // temporary workaround for state saving bug; remove any ClientBehaviors added dynamically
+ for (EditableValueHolder i : elements.getInputs())
+ {
+ Map<String, List<ClientBehavior>> b = ((UIInput) i).getClientBehaviors();
+ for (String k : b.keySet())
+ {
+ b.get(k).clear();
+ }
+ }
}
protected void startContainerElement(final FacesContext context) throws IOException
@@ -304,11 +317,11 @@
*
* @return a composite object of the input container elements
*/
- protected InputContainerElements scan(final UIComponent component, InputContainerElements elements, final FacesContext context)
+ protected InputContainerElements scan(final UIComponent component, final FacesContext context)
{
if (elements == null)
{
- elements = new InputContainerElements();
+ elements = new InputContainerElements(getId(), getAttributes());
}
// NOTE we need to walk the tree ignoring rendered attribute because it's
@@ -329,9 +342,8 @@
// may need to walk smarter to ensure "element of least suprise"
for (UIComponent child : component.getChildren())
{
- scan(child, elements, context);
+ scan(child, context);
}
-
return elements;
}
@@ -447,6 +459,8 @@
public static class InputContainerElements
{
+ private String containerId;
+ private Map<String, Object> attributes;
private String propertyName;
private HtmlOutputLabel label;
private final List<EditableValueHolder> inputs = new ArrayList<EditableValueHolder>();
@@ -454,6 +468,12 @@
private boolean validationError = false;
private boolean requiredInput = false;
+ public InputContainerElements(final String containerId, final Map<String, Object> attributes)
+ {
+ this.containerId = containerId;
+ this.attributes = attributes;
+ }
+
public HtmlOutputLabel getLabel()
{
return label;
@@ -472,6 +492,17 @@
public void registerInput(final EditableValueHolder input, final Validator validator, final FacesContext context)
{
inputs.add(input);
+ if (Boolean.TRUE.equals(attributes.get("ajax")))
+ {
+ UIInput inputc = (UIInput) input;
+ Map<String, List<ClientBehavior>> behaviors = inputc.getClientBehaviors();
+ if (!behaviors.containsKey("blur"))
+ {
+ AjaxBehavior ajax = new AjaxBehavior();
+ ajax.setRender(Arrays.asList(containerId));
+ inputc.addClientBehavior("blur", ajax);
+ }
+ }
if (input.isRequired() || isRequiredByConstraint(input, validator, context))
{
requiredInput = true;
Modified: examples/trunk/booking-simplified/src/main/resources/messages.properties
===================================================================
--- examples/trunk/booking-simplified/src/main/resources/messages.properties 2010-06-17 01:01:35 UTC (rev 13210)
+++ examples/trunk/booking-simplified/src/main/resources/messages.properties 2010-06-17 09:33:29 UTC (rev 13211)
@@ -2,13 +2,13 @@
booking.checkInNotFutureDate=Check-in date must be a future date.
booking.checkOutBeforeCheckIn=Check-out date must be after check in date.
booking.confirmed=You're booked to stay at the {0} {1}.
-booking.canceled=Your booking at the {0} on {1,date} has been canceled.
+booking.canceled=Your booking at the {0} on {1} has been canceled.
booking.doesNotExist=Our records indicate that the booking you selected has already been canceled.
account.passwordChanged=Password successfully updated.
account.passwordNotConfirmed=Your current password was not valid. Please try again.
account.passwordsDoNotMatch=Passwords do not match. Please re-type the new password.
account.usernameTaken=The username '{0}' is already taken. Please choose another username.
-registration.registered=You have been successfully registered as the user {0}!
+registration.registered=You have been successfully registered as the user {0}! You may now login.
registration.invalid=Invalid registration. Please correct the errors and try again.
identity.loggedOut=You have successfully ended your session.
identity.loggedIn=You're signed in as {0}.
Property changes on: examples/trunk/booking-simplified/src/main/webapp/WEB-INF
___________________________________________________________________
Name: svn:ignore
- sun-web.xml
.faces-config.xml.jsfdia
lib
Modified: examples/trunk/booking-simplified/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/WEB-INF/faces-config.xml 2010-06-17 01:01:35 UTC (rev 13210)
+++ examples/trunk/booking-simplified/src/main/webapp/WEB-INF/faces-config.xml 2010-06-17 09:33:29 UTC (rev 13211)
@@ -105,7 +105,7 @@
<navigation-case>
<from-action>#{registrar.register}</from-action>
<if>#{registrar.registered}</if>
- <to-view-id>/account.xhtml</to-view-id>
+ <to-view-id>/home.xhtml</to-view-id>
<redirect/>
</navigation-case>
Modified: examples/trunk/booking-simplified/src/main/webapp/WEB-INF/fragments/account.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/WEB-INF/fragments/account.xhtml 2010-06-17 01:01:35 UTC (rev 13210)
+++ examples/trunk/booking-simplified/src/main/webapp/WEB-INF/fragments/account.xhtml 2010-06-17 09:33:29 UTC (rev 13211)
@@ -6,7 +6,8 @@
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://http://java.sun.com/jsf/composite/components/property">
+ <p:output label="Full name" value="#{currentUser.name}"/>
<p:output label="Username" value="#{currentUser.username}"/>
- <p:output label="Full name" value="#{currentUser.name}"/>
+ <p:output label="Email address" value="#{currentUser.email}"/>
</ui:composition>
Modified: examples/trunk/booking-simplified/src/main/webapp/book.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/book.xhtml 2010-06-17 01:01:35 UTC (rev 13210)
+++ examples/trunk/booking-simplified/src/main/webapp/book.xhtml 2010-06-17 09:33:29 UTC (rev 13211)
@@ -65,7 +65,7 @@
</h:selectOneMenu>
</p:input>
- <p:input id="creditCardExpiry" inputs="2">
+ <p:input id="creditCardExpiration" inputs="2">
<h:selectOneMenu id="month" value="#{booking.creditCardExpiryMonth}">
<f:selectItems value="#{months}" var="_month" itemValue="#{_month.number}" itemLabel="#{_month.shortName}"/>
</h:selectOneMenu>
Modified: examples/trunk/booking-simplified/src/main/webapp/home.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/home.xhtml 2010-06-17 01:01:35 UTC (rev 13210)
+++ examples/trunk/booking-simplified/src/main/webapp/home.xhtml 2010-06-17 09:33:29 UTC (rev 13211)
@@ -15,9 +15,9 @@
<p>
This sample application demonstrates how easy it is to develop stateful web applications using Java EE 6
- with portable Seam modules. Just register, login, and book a room to see the future of Java EE in action.
- Throughout the application you'll see popup links like the ones at the bottom of this page. Click them to
- see how the application works under the hood.
+ augmented with portable Seam modules. Just register, login, and book a room to see the future of Java EE in
+ action. Throughout the application you'll see notes in the sidebar that explain how this platform helps you
+ meet enterprise application requirements.
</p>
<p>
@@ -68,10 +68,6 @@
</div>
</fieldset>
</h:form>
-
- <h:panelGroup rendered="#{identity.loggedIn}">
- You are logged in.
- </h:panelGroup>
</ui:define>
</ui:composition>
Modified: examples/trunk/booking-simplified/src/main/webapp/hotel.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/hotel.xhtml 2010-06-17 01:01:35 UTC (rev 13210)
+++ examples/trunk/booking-simplified/src/main/webapp/hotel.xhtml 2010-06-17 09:33:29 UTC (rev 13211)
@@ -7,10 +7,10 @@
xmlns:s="http://jboss.org/seam/faces"
template="/WEB-INF/layout/template.xhtml">
- <f:metadata>
- <f:viewParam name="id" value="#{_hotel}" />
- <s:viewAction action="#{bookingAgent.selectHotel(_hotel)}" />
- </f:metadata>
+ <f:metadata>
+ <f:viewParam name="id" value="#{_hotelId}"/>
+ <s:viewAction action="#{bookingAgent.selectHotel(_hotelId)}"/>
+ </f:metadata>
<ui:define name="content">
Modified: examples/trunk/booking-simplified/src/main/webapp/password.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/password.xhtml 2010-06-17 01:01:35 UTC (rev 13210)
+++ examples/trunk/booking-simplified/src/main/webapp/password.xhtml 2010-06-17 09:33:29 UTC (rev 13211)
@@ -25,7 +25,7 @@
<fieldset>
<p:input id="current">
- <h:inputSecret id="password" value="#{currentUser.password}"/>
+ <h:inputSecret id="password" value="#{currentUser.password}"/>
</p:input>
<p:input id="new">
@@ -44,8 +44,10 @@
</fieldset>
- <s:validateForm validatorId="passwordConfirmValidator"
- fields="oldPassword=current:password newPassword=new:password confirmNewPassword=confirm:password"/>
+ <s:validateForm validatorId="changePasswordValidator"
+ fields="currentPassword=current:password"/>
+ <s:validateForm validatorId="confirmPasswordValidator"
+ fields="newPassword=new:password confirmPassword=confirm:password"/>
</h:form>
</div>
Modified: examples/trunk/booking-simplified/src/main/webapp/register.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/register.xhtml 2010-06-17 01:01:35 UTC (rev 13210)
+++ examples/trunk/booking-simplified/src/main/webapp/register.xhtml 2010-06-17 09:33:29 UTC (rev 13211)
@@ -4,13 +4,16 @@
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:s="http://jboss.org/seam/faces"
xmlns:p="http://http://java.sun.com/jsf/composite/components/property"
template="/WEB-INF/layout/template.xhtml">
<ui:param name="pageClass" value="home"/>
<ui:define name="metadata">
- <f:event type="preRenderView" listener="#{registrar.notifyIfRegistrationIsInvalid(facesContext.validationFailed)}"/>
+ <f:metadata>
+ <f:event type="preRenderView" listener="#{registrar.notifyIfRegistrationIsInvalid}"/>
+ </f:metadata>
</ui:define>
<ui:define name="content">
@@ -26,34 +29,31 @@
</div>
<h:form id="registrationForm" prependId="false">
+ <h:outputScript name="jsf.js" library="javax.faces" target="head"/>
+ <fieldset>
- <fieldset>
-
<p:input id="username">
<h:inputText id="input" value="#{newUser.username}"
- binding="#{registrationFormControls.username}">
+ binding="#{registrar.usernameInput}">
<f:ajax event="blur" render="username"/>
</h:inputText>
</p:input>
- <p:input id="name">
- <h:inputText id="input" value="#{newUser.name}">
- <f:ajax event="blur" render="name"/>
- </h:inputText>
+ <p:input id="name" ajax="true">
+ <h:inputText id="input" value="#{newUser.name}"/>
</p:input>
- <p:input id="password">
- <h:inputSecret id="input" value="#{newUser.password}" redisplay="true">
- <f:ajax event="blur" render="password"/>
- </h:inputSecret>
+ <p:input id="email" ajax="true">
+ <h:inputText id="input" value="#{newUser.email}"/>
</p:input>
- <p:input id="confirmPassword">
- <h:inputSecret id="input" value="#{registrar.confirmPassword}" redisplay="true"
- binding="#{registrationFormControls.confirmPassword}">
- <f:ajax event="blur" render="confirmPassword"/>
- </h:inputSecret>
+ <p:input id="password" ajax="true">
+ <h:inputSecret id="input" value="#{newUser.password}" redisplay="true"/>
</p:input>
+
+ <p:input id="confirmPassword" ajax="true">
+ <h:inputSecret id="input" value="#{registrar.confirmPassword}" redisplay="true"/>
+ </p:input>
<div class="buttonBox">
<h:commandButton id="register" value="Register" action="#{registrar.register}"/>
@@ -62,6 +62,10 @@
</div>
</fieldset>
+
+ <s:validateForm validatorId="confirmPasswordValidator"
+ fields="newPassword=password:input confirmPassword=confirmPassword:input"/>
+
</h:form>
</div>
Modified: examples/trunk/booking-simplified/src/main/webapp/resources/components/property/input.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/resources/components/property/input.xhtml 2010-06-17 01:01:35 UTC (rev 13210)
+++ examples/trunk/booking-simplified/src/main/webapp/resources/components/property/input.xhtml 2010-06-17 09:33:29 UTC (rev 13211)
@@ -10,6 +10,7 @@
<cc:interface componentType="org.jboss.seam.faces.InputContainer">
<cc:attribute name="label" required="true"/>
<cc:attribute name="required" required="false"/>
+ <cc:attribute name="ajax" required="false" default="false" type="java.lang.Boolean"/>
<cc:attribute name="inputs" required="false" default="1"/>
</cc:interface>
Modified: examples/trunk/booking-simplified/src/test/java/org/jboss/seam/examples/booking/booking/BookingAgentTest.java
===================================================================
--- examples/trunk/booking-simplified/src/test/java/org/jboss/seam/examples/booking/booking/BookingAgentTest.java 2010-06-17 01:01:35 UTC (rev 13210)
+++ examples/trunk/booking-simplified/src/test/java/org/jboss/seam/examples/booking/booking/BookingAgentTest.java 2010-06-17 09:33:29 UTC (rev 13211)
@@ -39,7 +39,7 @@
WebArchive war = ShrinkWrap.create("test.war", WebArchive.class)
.addPackage(Hotel.class.getPackage())
.addClasses(BookingAgent.class, BookingAgentBean.class, Confirmed.class,
- Authenticated.class, BookingEvent.class, NoOpLogger.class)
+ Authenticated.class, NoOpLogger.class)
.addLibraries(
MavenArtifactResolver.resolve("joda-time:joda-time:1.6"),
MavenArtifactResolver.resolve("org.jboss.seam.international:seam-international-api:3.0.0.Alpha1"),
15 years, 6 months
Seam SVN: r13210 - in examples/trunk/booking-simplified: src/main/java/org/jboss/seam/examples/booking and 14 other directories.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2010-06-16 21:01:35 -0400 (Wed, 16 Jun 2010)
New Revision: 13210
Added:
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/Bundles.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationDateRangeValidator.java
Removed:
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/controls/BookingFormControls.java
Modified:
examples/trunk/booking-simplified/pom.xml
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/AccountHolder.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/AccountHolderBean.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Authenticated.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordConfirmValidator.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManager.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManagerBean.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Registrar.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/RegistrarBean.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgent.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgentBean.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingEvent.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistory.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistoryBean.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/Confirmed.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ConfirmedLiteral.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/bootstrap/ApplicationSetup.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/bootstrap/ApplicationSetupBean.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/controls/RegistrationFormControls.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearch.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearchBean.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/SearchCriteria.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/Booking.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/Booking_.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/CreditCardType.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/Hotel.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/Hotel_.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/User.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/User_.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/CalendarReferenceProducer.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/CreditCardExpiryYears.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/CreditCardReferenceProducer.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/Month.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Authenticator.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/AuthenticatorBean.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Credentials.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Identity.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/MockCredentials.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/faces/component/UIInputContainer.java
examples/trunk/booking-simplified/src/main/resources/messages.properties
examples/trunk/booking-simplified/src/main/webapp/WEB-INF/faces-config.xml
examples/trunk/booking-simplified/src/main/webapp/account.xhtml
examples/trunk/booking-simplified/src/main/webapp/book.xhtml
examples/trunk/booking-simplified/src/main/webapp/confirm.xhtml
examples/trunk/booking-simplified/src/main/webapp/home.xhtml
examples/trunk/booking-simplified/src/main/webapp/hotel.xhtml
examples/trunk/booking-simplified/src/main/webapp/password.xhtml
examples/trunk/booking-simplified/src/main/webapp/search.xhtml
examples/trunk/booking-simplified/src/test/java/org/jboss/seam/examples/booking/booking/BookingAgentTest.java
examples/trunk/booking-simplified/src/test/java/org/jboss/seam/examples/booking/support/NoOpLogger.java
Log:
update license header
xval for booking
use constant for messages bundle name
cleanups
Modified: examples/trunk/booking-simplified/pom.xml
===================================================================
--- examples/trunk/booking-simplified/pom.xml 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/pom.xml 2010-06-17 01:01:35 UTC (rev 13210)
@@ -135,6 +135,13 @@
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.codehaus.groovy.maven.runtime</groupId>
+ <artifactId>gmaven-runtime-1.6</artifactId>
+ <version>1.0</version>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
<build>
@@ -154,6 +161,19 @@
</plugin>
<plugin>
+ <groupId>org.codehaus.groovy.maven</groupId>
+ <artifactId>gmaven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>testCompile</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<additionalBuildcommands>
Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/Bundles.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/Bundles.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/Bundles.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -0,0 +1,30 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.examples.booking;
+
+/**
+ * @author Dan Allen
+ */
+public interface Bundles
+{
+ static final String MESSAGES = "messages";
+}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/AccountHolder.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/AccountHolder.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/AccountHolder.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.seam.examples.booking.account;
import javax.ejb.Local;
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/AccountHolderBean.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/AccountHolderBean.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/AccountHolderBean.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.seam.examples.booking.account;
import javax.ejb.Stateful;
@@ -4,11 +25,9 @@
import javax.enterprise.context.SessionScoped;
import javax.enterprise.event.Observes;
import javax.enterprise.inject.Produces;
-import javax.inject.Inject;
import javax.inject.Named;
import org.jboss.seam.examples.booking.model.User;
-import org.slf4j.Logger;
/**
* @author Dan Allen
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Authenticated.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Authenticated.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Authenticated.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.seam.examples.booking.account;
import static java.lang.annotation.ElementType.FIELD;
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordConfirmValidator.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordConfirmValidator.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordConfirmValidator.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,4 +1,4 @@
-/*
+/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
@@ -28,6 +28,7 @@
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;
import javax.inject.Inject;
+import org.jboss.seam.examples.booking.Bundles;
import org.jboss.seam.examples.booking.model.User;
import org.jboss.seam.faces.validation.InputField;
@@ -36,7 +37,6 @@
/**
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
- *
*/
@FacesValidator(value = "passwordConfirmValidator")
public class PasswordConfirmValidator implements Validator
@@ -68,12 +68,15 @@
* This is an ugly way to put i18n in FacesMessages:
* https://jira.jboss.org/browse/SEAMFACES-24
*/
- throw new ValidatorException(new FacesMessage(msg.info(new BundleKey("messages", "account.passwordNotConfirmed")).build().getText()));
+ throw new ValidatorException(
+ new FacesMessage(msg.info(
+ new BundleKey(Bundles.MESSAGES, "account.passwordNotConfirmed"))
+ .build().getText()));
}
if ((newPassword != null) && !newPassword.equals(confirmNewPassword))
{
- throw new ValidatorException(new FacesMessage(msg.info(new BundleKey("messages", "account.passwordsDoNotMatch")).build().getText()));
+ throw new ValidatorException(new FacesMessage(msg.info(new BundleKey(Bundles.MESSAGES, "account.passwordsDoNotMatch")).build().getText()));
}
}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManager.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManager.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManager.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.seam.examples.booking.account;
import javax.ejb.Local;
@@ -5,7 +26,6 @@
import javax.validation.constraints.Size;
/**
- *
* @author Dan Allen
*/
@Local
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManagerBean.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManagerBean.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManagerBean.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.seam.examples.booking.account;
import javax.ejb.Stateful;
@@ -6,6 +27,7 @@
import javax.inject.Named;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
+import org.jboss.seam.examples.booking.Bundles;
import org.jboss.seam.examples.booking.model.User;
import org.jboss.seam.international.status.Messages;
@@ -36,7 +58,7 @@
public void changePassword()
{
em.merge(user);
- messages.info(new BundleKey("messages", "account.passwordChanged")).textDefault("Password successfully updated.");
+ messages.info(new BundleKey(Bundles.MESSAGES, "account.passwordChanged")).textDefault("Password successfully updated.");
changed = true;
}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Registrar.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Registrar.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Registrar.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.seam.examples.booking.account;
import javax.ejb.Local;
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/RegistrarBean.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/RegistrarBean.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/RegistrarBean.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.seam.examples.booking.account;
import javax.ejb.Stateful;
@@ -7,6 +28,7 @@
import javax.inject.Named;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
+import org.jboss.seam.examples.booking.Bundles;
import org.jboss.seam.examples.booking.controls.RegistrationFormControls;
import org.jboss.seam.examples.booking.model.User;
@@ -44,7 +66,7 @@
{
registered = true;
em.persist(newUser);
- messages.info(new BundleKey("messages", "registration.registered")).textDefault("You have been successfully registered as the user {0}!").textParams(newUser.getUsername());
+ messages.info(new BundleKey(Bundles.MESSAGES, "registration.registered")).textDefault("You have been successfully registered as the user {0}!").textParams(newUser.getUsername());
}
else
{
@@ -63,7 +85,7 @@
{
if (validationFailed || registrationInvalid)
{
- messages.warn(new BundleKey("messages", "registration.invalid")).textDefault("Invalid registration. Please correct the errors and try again.");
+ messages.warn(new BundleKey(Bundles.MESSAGES, "registration.invalid")).textDefault("Invalid registration. Please correct the errors and try again.");
}
}
@@ -97,7 +119,7 @@
{
if (!newUser.getPassword().equals(confirmPassword))
{
- messages.warn(new BundleKey("messages", "account.passwordsDoNotMatch")).textDefault("Passwords do not match. Please re-type your password.").targets(formControls.getConfirmPasswordControlId());
+ messages.warn(new BundleKey(Bundles.MESSAGES, "account.passwordsDoNotMatch")).textDefault("Passwords do not match. Please re-type your password.").targets(formControls.getConfirmPasswordControlId());
confirmPassword = null;
return false;
}
Property changes on: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking
___________________________________________________________________
Name: svn:ignore
+ .BookingAgentBean.java.swp
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgent.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgent.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgent.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2010, 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.
*
@@ -18,8 +18,6 @@
* 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;
@@ -38,7 +36,7 @@
void bookHotel();
- void validateBooking();
+ void validate();
void cancel();
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgentBean.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgentBean.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgentBean.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,6 +1,6 @@
-/*
+/*
* JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2010, 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.
*
@@ -18,8 +18,6 @@
* 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;
@@ -38,7 +36,6 @@
import javax.persistence.PersistenceContext;
import org.jboss.seam.examples.booking.account.Authenticated;
-import org.jboss.seam.examples.booking.controls.BookingFormControls;
import org.jboss.seam.examples.booking.model.Booking;
import org.jboss.seam.examples.booking.model.Hotel;
import org.jboss.seam.examples.booking.model.User;
@@ -50,6 +47,7 @@
import org.slf4j.Logger;
import com.ocpsoft.pretty.time.PrettyTime;
+import org.jboss.seam.examples.booking.Bundles;
@Named("bookingAgent")
@Stateful
@@ -69,9 +67,6 @@
private Messages messages;
@Inject
- private BookingFormControls formControls;
-
- @Inject
@Authenticated
private User user;
@@ -88,8 +83,7 @@
@Begin
public void selectHotel(final Long id)
{
- // NOTE get a fresh reference that's managed by the extended persistence
- // context
+ // NOTE get a fresh reference that's managed by the extended persistence context
hotelSelection = em.find(Hotel.class, id);
if (hotelSelection != null)
{
@@ -102,31 +96,18 @@
booking = new Booking(hotelSelection, user);
// QUESTION push logic into Booking?
Calendar calendar = Calendar.getInstance();
+ calendar.add(Calendar.DAY_OF_MONTH, 1);
booking.setCheckinDate(calendar.getTime());
calendar.add(Calendar.DAY_OF_MONTH, 1);
booking.setCheckoutDate(calendar.getTime());
hotelSelection = null;
- messages.info(new BundleKey("messages", "booking.initiated")).textDefault("You've initiated a booking at {0}.").textParams(booking.getHotel().getName());
+ messages.info(new BundleKey(Bundles.MESSAGES, "booking.initiated")).textDefault("You've initiated a booking at the {0}.").textParams(booking.getHotel().getName());
}
- public void validateBooking()
+ public void validate()
{
- Calendar calendar = Calendar.getInstance();
- calendar.add(Calendar.DAY_OF_MONTH, -1);
- if (booking.getCheckinDate().before(calendar.getTime()))
- {
- messages.info(new BundleKey("messages", "booking.checkInNotFutureDate")).textDefault("Check in date must be a future date").targets(formControls.getCheckinDateControlId());
- bookingValid = false;
- }
- else if (!booking.getCheckinDate().before(booking.getCheckoutDate()))
- {
- messages.info(new BundleKey("messages", "booking.checkOutBeforeCheckIn")).textDefault("Check out date must be after check in date").targets(formControls.getCheckoutDateControlId());
- bookingValid = false;
- }
- else
- {
- bookingValid = true;
- }
+ // if we got here, all validations passed
+ bookingValid = true;
}
@End
@@ -135,8 +116,11 @@
em.persist(booking);
// FIXME can't inject event object into bean with passivating scope
manager.fireEvent(new BookingEvent(booking), ConfirmedLiteral.INSTANCE);
- log.info(msg.info("New booking at the {0} confirmed for {1}").textParams(booking.getHotel().getName(), booking.getUser().getName()).build().getText());
- messages.info(new BundleKey("messages", "booking.confirmed")).textDefault("Booking confirmed.").textParams(new PrettyTime().format(booking.getCheckinDate()));
+ log.info(msg.info("New booking at the {0} confirmed for {1}")
+ .textParams(booking.getHotel().getName(), booking.getUser().getName()).build().getText());
+ messages.info(new BundleKey(Bundles.MESSAGES, "booking.confirmed"))
+ .textDefault("You're booked to stay at the {0} {1}.")
+ .textParams(booking.getHotel().getName(), new PrettyTime().format(booking.getCheckinDate()));
}
@End
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingEvent.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingEvent.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingEvent.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.seam.examples.booking.booking;
import org.jboss.seam.examples.booking.model.Booking;
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistory.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistory.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistory.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.seam.examples.booking.booking;
import java.util.List;
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistoryBean.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistoryBean.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistoryBean.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,6 +1,6 @@
-/*
+/*
* JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2010, 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.
*
@@ -18,8 +18,6 @@
* 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;
@@ -39,6 +37,7 @@
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.Root;
+import org.jboss.seam.examples.booking.Bundles;
import org.jboss.seam.examples.booking.account.Authenticated;
import org.jboss.seam.examples.booking.model.Booking;
@@ -104,11 +103,11 @@
if (booking != null)
{
em.remove(booking);
- messages.info(new BundleKey("messages", "booking.canceled")).textDefault("The booking at the {0} on {1,date} has been canceled.").textParams(selectedBooking.getHotel().getName(), selectedBooking.getCheckinDate());
+ messages.info(new BundleKey(Bundles.MESSAGES, "booking.canceled")).textDefault("The booking at the {0} on {1,date} has been canceled.").textParams(selectedBooking.getHotel().getName(), selectedBooking.getCheckinDate());
}
else
{
- messages.info(new BundleKey("messages", "booking.doesNotExist")).textDefault("Our records indicate that the booking you selected has already been canceled.");
+ messages.info(new BundleKey(Bundles.MESSAGES, "booking.doesNotExist")).textDefault("Our records indicate that the booking you selected has already been canceled.");
}
bookingsForUser.remove(selectedBooking);
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/Confirmed.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/Confirmed.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/Confirmed.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,6 +1,6 @@
-/*
+/*
* JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2010, 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.
*
@@ -18,8 +18,6 @@
* 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;
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ConfirmedLiteral.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ConfirmedLiteral.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ConfirmedLiteral.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,6 +1,6 @@
-/*
+/*
* JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2010, 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.
*
@@ -18,8 +18,6 @@
* 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;
Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationDateRangeValidator.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationDateRangeValidator.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationDateRangeValidator.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.examples.booking.booking;
+
+import java.util.Calendar;
+import java.util.Date;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.validator.FacesValidator;
+import javax.faces.validator.Validator;
+import javax.faces.validator.ValidatorException;
+import javax.inject.Inject;
+import org.jboss.seam.examples.booking.Bundles;
+import org.jboss.seam.faces.validation.InputField;
+import org.jboss.seam.international.status.MessageFactory;
+import org.jboss.seam.international.status.builder.BundleKey;
+
+/**
+ * A cross-field validator that validates the begin date
+ * is in the future and before the end date.
+ *
+ * @author Dan Allen
+ */
+@FacesValidator("reservationDateRangeValidator")
+public class ReservationDateRangeValidator implements Validator {
+ @Inject
+ @InputField
+ private Date beginDate;
+
+ @Inject
+ @InputField
+ private Date endDate;
+
+ @Inject
+ private MessageFactory msg;
+
+ @Override
+ public void validate(FacesContext ctx, UIComponent c, Object value) throws ValidatorException
+ {
+ Calendar calendar = Calendar.getInstance();
+ calendar.add(Calendar.DAY_OF_MONTH, -1);
+ if (beginDate.before(calendar.getTime()))
+ {
+ String message = msg.info(new BundleKey(Bundles.MESSAGES, "booking.checkInNotFutureDate"))
+ .textDefault("Check-in date must be in the future")
+ // FIXME this information should come through via injection
+ .targets("checkInDate:input")
+ .build().getText();
+ throw new ValidatorException(new FacesMessage(message));
+ }
+ else if (!beginDate.before(endDate))
+ {
+ String message = msg.info(new BundleKey(Bundles.MESSAGES, "booking.checkOutBeforeCheckIn"))
+ .textDefault("Check-out date must be after check-in date")
+ // FIXME this information should come through via injection
+ .targets("checkOutDate:input")
+ .build().getText();
+ throw new ValidatorException(new FacesMessage(message));
+ }
+ }
+
+}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/bootstrap/ApplicationSetup.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/bootstrap/ApplicationSetup.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/bootstrap/ApplicationSetup.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,4 +1,4 @@
-/*
+/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
@@ -26,7 +26,6 @@
/**
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
- *
*/
@Local
public interface ApplicationSetup
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/bootstrap/ApplicationSetupBean.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/bootstrap/ApplicationSetupBean.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/bootstrap/ApplicationSetupBean.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.seam.examples.booking.bootstrap;
import java.util.ArrayList;
Deleted: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/controls/BookingFormControls.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/controls/BookingFormControls.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/controls/BookingFormControls.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,52 +0,0 @@
-package org.jboss.seam.examples.booking.controls;
-
-import java.io.Serializable;
-
-import javax.enterprise.context.RequestScoped;
-import javax.inject.Named;
-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
- */
-@Named
-@RequestScoped
-public class BookingFormControls implements Serializable
-{
- 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();
- }
-}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/controls/RegistrationFormControls.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/controls/RegistrationFormControls.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/controls/RegistrationFormControls.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.seam.examples.booking.controls;
import java.io.Serializable;
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearch.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearch.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearch.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2010, 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.
*
@@ -18,8 +18,6 @@
* 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;
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearchBean.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearchBean.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearchBean.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,6 +1,6 @@
-/*
+/*
* JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2010, 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.
*
@@ -18,8 +18,6 @@
* 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;
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/SearchCriteria.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/SearchCriteria.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/SearchCriteria.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,6 +1,6 @@
-/*
+/*
* JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2010, 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.
*
@@ -18,8 +18,6 @@
* 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;
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/Booking.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/Booking.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/Booking.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2010, 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.
*
@@ -18,8 +18,6 @@
* 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.model;
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/Booking_.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/Booking_.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/Booking_.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.seam.examples.booking.model;
import java.util.Date;
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/CreditCardType.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/CreditCardType.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/CreditCardType.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.seam.examples.booking.model;
public enum CreditCardType
@@ -6,4 +27,4 @@
MasterCard,
AMEX,
Discover
-}
\ No newline at end of file
+}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/Hotel.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/Hotel.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/Hotel.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2010, 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.
*
@@ -18,8 +18,6 @@
* 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.model;
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/Hotel_.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/Hotel_.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/Hotel_.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.seam.examples.booking.model;
import java.math.BigDecimal;
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/User.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/User.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/User.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2010, 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.
*
@@ -18,8 +18,6 @@
* 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.model;
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/User_.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/User_.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/User_.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.seam.examples.booking.model;
import javax.persistence.metamodel.SingularAttribute;
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/CalendarReferenceProducer.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/CalendarReferenceProducer.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/CalendarReferenceProducer.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.seam.examples.booking.reference;
import java.text.DateFormat;
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/CreditCardExpiryYears.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/CreditCardExpiryYears.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/CreditCardExpiryYears.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.seam.examples.booking.reference;
import static java.lang.annotation.ElementType.FIELD;
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/CreditCardReferenceProducer.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/CreditCardReferenceProducer.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/CreditCardReferenceProducer.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.seam.examples.booking.reference;
import java.util.ArrayList;
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/Month.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/Month.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/Month.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.seam.examples.booking.reference;
/**
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Authenticator.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Authenticator.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Authenticator.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.seam.examples.booking.security;
import javax.ejb.Local;
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/AuthenticatorBean.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/AuthenticatorBean.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/AuthenticatorBean.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.seam.examples.booking.security;
import javax.ejb.Stateless;
@@ -5,6 +26,7 @@
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
+import org.jboss.seam.examples.booking.Bundles;
import org.jboss.seam.examples.booking.account.Authenticated;
import org.jboss.seam.examples.booking.model.User;
@@ -42,7 +64,7 @@
log.info("Logging in " + credentials.getUsername());
if ((credentials.getUsername() == null) || (credentials.getPassword() == null))
{
- messages.info(new BundleKey("messages", "identity.loginFailed"));
+ messages.info(new BundleKey(Bundles.MESSAGES, "identity.loginFailed"));
return false;
}
@@ -50,12 +72,12 @@
if ((user != null) && user.getPassword().equals(credentials.getPassword()))
{
loginEventSrc.fire(user);
- messages.info(new BundleKey("messages", "identity.loggedIn"), user.getName());
+ messages.info(new BundleKey(Bundles.MESSAGES, "identity.loggedIn"), user.getName());
return true;
}
else
{
- messages.info(new BundleKey("messages", "identity.loginFailed"));
+ messages.info(new BundleKey(Bundles.MESSAGES, "identity.loginFailed"));
return false;
}
}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Credentials.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Credentials.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Credentials.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.seam.examples.booking.security;
public interface Credentials {
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Identity.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Identity.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Identity.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,4 +1,4 @@
-/*
+/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/MockCredentials.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/MockCredentials.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/MockCredentials.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,4 +1,4 @@
-/*
+/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/faces/component/UIInputContainer.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/faces/component/UIInputContainer.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/faces/component/UIInputContainer.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,4 +1,4 @@
-/*
+/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
Modified: examples/trunk/booking-simplified/src/main/resources/messages.properties
===================================================================
--- examples/trunk/booking-simplified/src/main/resources/messages.properties 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/resources/messages.properties 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,8 +1,8 @@
-booking.initiated=You've initiated a booking at {0}.
-booking.checkInNotFutureDate=Check in date must be a future date.
-booking.checkOutBeforeCheckIn=Check out date must be after check in date.
-booking.confirmed=You're booked! Check in is {0}.
-booking.canceled=The booking at the {0} on {1,date} has been canceled.
+booking.initiated=You've initiated a booking at the {0}.
+booking.checkInNotFutureDate=Check-in date must be a future date.
+booking.checkOutBeforeCheckIn=Check-out date must be after check in date.
+booking.confirmed=You're booked to stay at the {0} {1}.
+booking.canceled=Your booking at the {0} on {1,date} has been canceled.
booking.doesNotExist=Our records indicate that the booking you selected has already been canceled.
account.passwordChanged=Password successfully updated.
account.passwordNotConfirmed=Your current password was not valid. Please try again.
@@ -10,6 +10,6 @@
account.usernameTaken=The username '{0}' is already taken. Please choose another username.
registration.registered=You have been successfully registered as the user {0}!
registration.invalid=Invalid registration. Please correct the errors and try again.
-identity.loggedOut=You have successfully logged out.
-identity.loggedIn=You've logged in as {0}.
+identity.loggedOut=You have successfully ended your session.
+identity.loggedIn=You're signed in as {0}.
identity.loginFailed=Invalid username or password.
Modified: examples/trunk/booking-simplified/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/WEB-INF/faces-config.xml 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/webapp/WEB-INF/faces-config.xml 2010-06-17 01:01:35 UTC (rev 13210)
@@ -79,7 +79,7 @@
<from-view-id>/book.xhtml</from-view-id>
<navigation-case>
- <from-action>#{bookingAgent.validateBooking}</from-action>
+ <from-action>#{bookingAgent.validate}</from-action>
<if>#{bookingAgent.bookingValid}</if>
<to-view-id>/confirm.xhtml</to-view-id>
<redirect/>
Modified: examples/trunk/booking-simplified/src/main/webapp/account.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/account.xhtml 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/webapp/account.xhtml 2010-06-17 01:01:35 UTC (rev 13210)
@@ -29,6 +29,7 @@
<ui:define name="sidebar">
+ <!--
<h1>Producing variables</h1>
<p>
You shouldn't need to write accessor methods (getters and setters) on a backing bean just to get at your data.
@@ -43,6 +44,7 @@
What happens when this page loads?
</a>
</p>
+ -->
</ui:define>
Modified: examples/trunk/booking-simplified/src/main/webapp/book.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/book.xhtml 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/webapp/book.xhtml 2010-06-17 01:01:35 UTC (rev 13210)
@@ -25,14 +25,14 @@
<h:form id="bookingForm">
<fieldset>
- <p:input id="checkinDate" label="Check-in date">
- <h:inputText id="input" value="#{booking.checkinDate}" binding="#{bookingFormControls.checkinDate}">
+ <p:input id="checkInDate">
+ <h:inputText id="input" value="#{booking.checkinDate}">
<f:convertDateTime type="date" pattern="MM/dd/yyyy"/>
</h:inputText>
</p:input>
- <p:input id="checkoutDate" label="Check-out date">
- <h:inputText id="input" value="#{booking.checkoutDate}" binding="#{bookingFormControls.checkoutDate}">
+ <p:input id="checkOutDate">
+ <h:inputText id="input" value="#{booking.checkoutDate}">
<f:convertDateTime type="date" pattern="MM/dd/yyyy"/>
</h:inputText>
</p:input>
@@ -57,30 +57,33 @@
</p:input>
<p:input id="creditCardNumber" inputs="2">
- <h:inputText id="input" value="#{booking.creditCardNumber}"/>
+ <h:inputText id="number" value="#{booking.creditCardNumber}"/>
#{' '}
- <h:selectOneMenu id="input2" value="#{booking.creditCardType}">
+ <h:selectOneMenu id="type" value="#{booking.creditCardType}">
<f:selectItem itemValue="#{null}" itemLabel="Select..." noSelectionOption="true"/>
<f:selectItems value="#{creditCardTypes}" var="_type" itemValue="#{_type}"/>
</h:selectOneMenu>
</p:input>
<p:input id="creditCardExpiry" inputs="2">
- <h:selectOneMenu id="input" value="#{booking.creditCardExpiryMonth}">
+ <h:selectOneMenu id="month" value="#{booking.creditCardExpiryMonth}">
<f:selectItems value="#{months}" var="_month" itemValue="#{_month.number}" itemLabel="#{_month.shortName}"/>
</h:selectOneMenu>
- <h:selectOneMenu id="input2" value="#{booking.creditCardExpiryYear}">
+ <h:selectOneMenu id="year" value="#{booking.creditCardExpiryYear}">
<f:selectItems value="#{creditCardExpiryYears}" var="_year" itemValue="#{_year}"/>
</h:selectOneMenu>
</p:input>
<div class="buttonBox">
- <h:commandButton id="proceed" value="Proceed" action="#{bookingAgent.validateBooking}"/>
+ <h:commandButton id="proceed" value="Proceed" action="#{bookingAgent.validate}"/>
#{' '}
<h:commandButton id="cancel" value="Cancel" action="#{bookingAgent.cancel}" immediate="true"/>
</div>
</fieldset>
+
+ <s:validateForm validatorId="reservationDateRangeValidator"
+ fields="beginDate=checkInDate:input endDate=checkOutDate:input"/>
</h:form>
</div>
@@ -88,6 +91,7 @@
<ui:define name="sidebar">
+ <!--
<h1>Workspace management</h1>
<p>
As you can see, Seam makes it easy to work in multiple windows or multiple browser tabs. But you can even
@@ -98,8 +102,8 @@
<a href="#" onclick="window.open('exp/workspaceExp.html','exp','width=752,height=500,scrollbars=yes');">
How does the workspace list work?
</a>
-
</p>
+ -->
</ui:define>
Modified: examples/trunk/booking-simplified/src/main/webapp/confirm.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/confirm.xhtml 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/webapp/confirm.xhtml 2010-06-17 01:01:35 UTC (rev 13210)
@@ -50,6 +50,7 @@
</ui:define>
<ui:define name="sidebar">
+ <!--
<h1>Back button navigation</h1>
<p>
When you click "Confirm", the new booking is written to the database,
@@ -64,6 +65,7 @@
What happens when the conversation ends?
</a>
</p>
+ -->
</ui:define>
</ui:composition>
Modified: examples/trunk/booking-simplified/src/main/webapp/home.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/home.xhtml 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/webapp/home.xhtml 2010-06-17 01:01:35 UTC (rev 13210)
@@ -14,15 +14,17 @@
<h1>About this example application</h1>
<p>
- This sample application demonstrates how easy it is to develop stateful web applications using JBoss Seam.
- Just register, login, and book a room to see Seam in action. Throughout the application you'll see popup
- links like the ones at the bottom of this page. Click them to see how the application works under the hood.
+ This sample application demonstrates how easy it is to develop stateful web applications using Java EE 6
+ with portable Seam modules. Just register, login, and book a room to see the future of Java EE in action.
+ Throughout the application you'll see popup links like the ones at the bottom of this page. Click them to
+ see how the application works under the hood.
</p>
<p>
Note: Please do NOT enter personal information or your credit card number in this sample application.
</p>
+ <!--
<p>
<a href="#" onclick="window.open('exp/introExp.html','exp','width=752,height=500,scrollbars=yes');">
What is Seam?
@@ -34,6 +36,7 @@
What happens when I login?
</a>
</p>
+ -->
</div>
</ui:define>
@@ -42,7 +45,7 @@
<h:form id="login" rendered="#{not identity.loggedIn}">
<fieldset>
<div>
- <h:outputLabel for="username" value="Login name"/>
+ <h:outputLabel for="username" value="Username"/>
<h:inputText id="username" value="#{credentials.username}" style="width: 175px;"/>
<div class="errors"><h:message for="username"/></div>
</div>
@@ -51,7 +54,7 @@
<h:inputSecret id="password" value="#{credentials.password}" style="width: 175px;"/>
</div>
<div class="errors"><h:messages id="messages" globalOnly="true"/></div>
- <div class="buttonBox"><h:commandButton id="login" action="#{identity.login}" value="Account Login"/></div>
+ <div class="buttonBox"><h:commandButton id="login" action="#{identity.login}" value="Login"/></div>
<div class="notes"><h:link id="register" outcome="/register.xhtml" value="Register New User"/></div>
<div class="subnotes">
Or use a demo account:
Modified: examples/trunk/booking-simplified/src/main/webapp/hotel.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/hotel.xhtml 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/webapp/hotel.xhtml 2010-06-17 01:01:35 UTC (rev 13210)
@@ -15,7 +15,7 @@
<ui:define name="content">
<div class="section">
- <h1>View Hotel</h1>
+ <h1>Hotel Details</h1>
</div>
<div class="section">
Modified: examples/trunk/booking-simplified/src/main/webapp/password.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/password.xhtml 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/webapp/password.xhtml 2010-06-17 01:01:35 UTC (rev 13210)
@@ -24,7 +24,7 @@
<fieldset>
- <p:input id="old">
+ <p:input id="current">
<h:inputSecret id="password" value="#{currentUser.password}"/>
</p:input>
@@ -45,7 +45,7 @@
</fieldset>
<s:validateForm validatorId="passwordConfirmValidator"
- fields="oldPassword=old:password newPassword=new:password confirmNewPassword=confirm:password"/>
+ fields="oldPassword=current:password newPassword=new:password confirmNewPassword=confirm:password"/>
</h:form>
</div>
Modified: examples/trunk/booking-simplified/src/main/webapp/search.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/search.xhtml 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/main/webapp/search.xhtml 2010-06-17 01:01:35 UTC (rev 13210)
@@ -34,13 +34,11 @@
<h1>Search Hotels</h1>
<h:form id="searchForm" prependId="false">
- <fieldset>
- <h:inputText id="query" value="#{searchCriteria.query}" style="width: 165px;">
+ <fieldset>
+ <h:inputText id="query" value="#{searchCriteria.query}" style="width: 165px;" autocomplete="off">
<f:ajax event="keyup" listener="#{hotelSearch.find}" render=":searchResults" onevent="controlSpinner"/>
</h:inputText>
#{' '}
- <h:outputLabel id="lblPageSize" for="pageSize" value="View:"/>
- #{' '}
<h:selectOneMenu id="pageSize" value="#{searchCriteria.pageSize}">
<f:ajax listener="#{hotelSearch.find}" render=":searchResults" onevent="controlSpinner"/>
<f:selectItem itemLabel="5 hotels per page" itemValue="5"/>
@@ -154,6 +152,7 @@
<ui:define name="sidebar">
+ <!--
<h1>State management in Seam</h1>
<p>
State in Seam is <em>contextual</em>. When you click "Find Hotels", the application
@@ -171,6 +170,7 @@
How does the search page work?
</a>
</p>
+ -->
</ui:define>
Modified: examples/trunk/booking-simplified/src/test/java/org/jboss/seam/examples/booking/booking/BookingAgentTest.java
===================================================================
--- examples/trunk/booking-simplified/src/test/java/org/jboss/seam/examples/booking/booking/BookingAgentTest.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/test/java/org/jboss/seam/examples/booking/booking/BookingAgentTest.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -14,7 +14,6 @@
import org.jboss.arquillian.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.seam.examples.booking.account.Authenticated;
-import org.jboss.seam.examples.booking.controls.BookingFormControls;
import org.jboss.seam.examples.booking.model.Booking;
import org.jboss.seam.examples.booking.model.CreditCardType;
import org.jboss.seam.examples.booking.model.Hotel;
@@ -37,7 +36,16 @@
@Deployment
public static Archive<?> createTestArchive()
{
- WebArchive war = ShrinkWrap.create("test.war", WebArchive.class).addPackage(Hotel.class.getPackage()).addClasses(BookingAgent.class, BookingAgentBean.class, Confirmed.class, Authenticated.class, BookingEvent.class, BookingFormControls.class, NoOpLogger.class).addLibraries(MavenArtifactResolver.resolve("joda-time:joda-time:1.6"), MavenArtifactResolver.resolve("org.jboss.seam.international:seam-international-api:3.0.0.Alpha1"), MavenArtifactResolver.resolve("org.jboss.seam.international:seam-international:3.0.0.Alpha1")).addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml").addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml");
+ WebArchive war = ShrinkWrap.create("test.war", WebArchive.class)
+ .addPackage(Hotel.class.getPackage())
+ .addClasses(BookingAgent.class, BookingAgentBean.class, Confirmed.class,
+ Authenticated.class, BookingEvent.class, NoOpLogger.class)
+ .addLibraries(
+ MavenArtifactResolver.resolve("joda-time:joda-time:1.6"),
+ MavenArtifactResolver.resolve("org.jboss.seam.international:seam-international-api:3.0.0.Alpha1"),
+ MavenArtifactResolver.resolve("org.jboss.seam.international:seam-international:3.0.0.Alpha1"))
+ .addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml")
+ .addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml");
return war;
}
Modified: examples/trunk/booking-simplified/src/test/java/org/jboss/seam/examples/booking/support/NoOpLogger.java
===================================================================
--- examples/trunk/booking-simplified/src/test/java/org/jboss/seam/examples/booking/support/NoOpLogger.java 2010-06-16 22:50:28 UTC (rev 13209)
+++ examples/trunk/booking-simplified/src/test/java/org/jboss/seam/examples/booking/support/NoOpLogger.java 2010-06-17 01:01:35 UTC (rev 13210)
@@ -1,4 +1,4 @@
-/*
+/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
15 years, 6 months
Seam SVN: r13209 - in examples/trunk/booking-simplified/src/main: resources and 1 other directory.
by seam-commits@lists.jboss.org
Author: lincolnthree
Date: 2010-06-16 18:50:28 -0400 (Wed, 16 Jun 2010)
New Revision: 13209
Modified:
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgentBean.java
examples/trunk/booking-simplified/src/main/resources/messages.properties
Log:
Added prettytime on confirmation :)
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgentBean.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgentBean.java 2010-06-16 22:32:02 UTC (rev 13208)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgentBean.java 2010-06-16 22:50:28 UTC (rev 13209)
@@ -49,6 +49,8 @@
import org.jboss.seam.international.status.builder.BundleKey;
import org.slf4j.Logger;
+import com.ocpsoft.pretty.time.PrettyTime;
+
@Named("bookingAgent")
@Stateful
@ConversationScoped
@@ -86,7 +88,8 @@
@Begin
public void selectHotel(final Long id)
{
- // NOTE get a fresh reference that's managed by the extended persistence context
+ // NOTE get a fresh reference that's managed by the extended persistence
+ // context
hotelSelection = em.find(Hotel.class, id);
if (hotelSelection != null)
{
@@ -133,7 +136,7 @@
// FIXME can't inject event object into bean with passivating scope
manager.fireEvent(new BookingEvent(booking), ConfirmedLiteral.INSTANCE);
log.info(msg.info("New booking at the {0} confirmed for {1}").textParams(booking.getHotel().getName(), booking.getUser().getName()).build().getText());
- messages.info(new BundleKey("messages", "booking.confirmed")).textDefault("Booking confirmed.");
+ messages.info(new BundleKey("messages", "booking.confirmed")).textDefault("Booking confirmed.").textParams(new PrettyTime().format(booking.getCheckinDate()));
}
@End
Modified: examples/trunk/booking-simplified/src/main/resources/messages.properties
===================================================================
--- examples/trunk/booking-simplified/src/main/resources/messages.properties 2010-06-16 22:32:02 UTC (rev 13208)
+++ examples/trunk/booking-simplified/src/main/resources/messages.properties 2010-06-16 22:50:28 UTC (rev 13209)
@@ -1,7 +1,7 @@
booking.initiated=You've initiated a booking at {0}.
booking.checkInNotFutureDate=Check in date must be a future date.
booking.checkOutBeforeCheckIn=Check out date must be after check in date.
-booking.confirmed=You're booked!
+booking.confirmed=You're booked! Check in is {0}.
booking.canceled=The booking at the {0} on {1,date} has been canceled.
booking.doesNotExist=Our records indicate that the booking you selected has already been canceled.
account.passwordChanged=Password successfully updated.
15 years, 6 months
Seam SVN: r13208 - in modules/faces/branches/exception_handling: api/src/main/java/org/jboss/seam/faces and 5 other directories.
by seam-commits@lists.jboss.org
Author: lightguard
Date: 2010-06-16 18:32:02 -0400 (Wed, 16 Jun 2010)
New Revision: 13208
Added:
modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/faces/exceptionhandling/
modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/faces/exceptionhandling/FacesState.java
modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/ExceptionHandlerComparator.java
modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/MethodParameterTypeHelper.java
modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/StateImpl.java
modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/faces/exceptionhandling/FacesStateImpl.java
modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/BaseExceptionHandler.java
modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/BaseExceptionHandlerTest.java
modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/ExceptionExceptionHandler.java
modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/ExceptionHandlerComparatorTest.java
modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/MultipleHandlerTest.java
modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/NullPointerExceptionHandler.java
modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/UnsupportedOperationExceptionHandlerTest.java
Removed:
modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/exceptionhandling/FacesState.java
modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/FacesStateImpl.java
modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/ExceptionHandlerTest.java
modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/ThrowExceptionRenderer.java
Modified:
modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/exceptionhandling/HandlerChain.java
modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/faces/context/FlashContext.java
modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/ExceptionHandlerExecutor.java
modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/HandlerChainImpl.java
modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/faces/exceptionhandling/SeamExceptionHandler.java
modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/UnsupportedOperationExceptionHandler.java
Log:
Seperating the base impl and api.
HandlerChain changed from next to end.
Base implementation is decently tested.
Deleted: modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/exceptionhandling/FacesState.java
===================================================================
--- modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/exceptionhandling/FacesState.java 2010-06-16 22:24:06 UTC (rev 13207)
+++ modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/exceptionhandling/FacesState.java 2010-06-16 22:32:02 UTC (rev 13208)
@@ -1,43 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.seam.exceptionhandling;
-
-import javax.faces.context.FacesContext;
-
-/**
- * Java Server Faces implementation of {@link State}.
- */
-public interface FacesState extends State
-{
- /**
- * @return the currently active Faces Context object
- */
- FacesContext getFacesContext();
-
- /**
- * Convenience method to facilitate navigation to a view id in an
- * {@link ExceptionHandler}.
- * @param viewId JSF view to navigate
- */
- void navigate(String viewId);
-}
Modified: modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/exceptionhandling/HandlerChain.java
===================================================================
--- modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/exceptionhandling/HandlerChain.java 2010-06-16 22:24:06 UTC (rev 13207)
+++ modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/exceptionhandling/HandlerChain.java 2010-06-16 22:32:02 UTC (rev 13208)
@@ -28,7 +28,9 @@
public interface HandlerChain
{
/**
- * Continue with the chain.
+ * End execution of the chain.
+ * Calling this method will immediately stop executing the handler chain, leaving any
+ * handlers left in the chain as uncalled.
*/
- void next();
+ void end();
}
Modified: modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/faces/context/FlashContext.java
===================================================================
--- modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/faces/context/FlashContext.java 2010-06-16 22:24:06 UTC (rev 13207)
+++ modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/faces/context/FlashContext.java 2010-06-16 22:32:02 UTC (rev 13208)
@@ -23,10 +23,9 @@
package org.jboss.seam.faces.context;
/**
- * A context that lives from Restore View to the next Render Response.
- *
+ * A context that lives from Restore View to the end Render Response.
+ *
* @author <a href="mailto:lincolnbaxter@gmail.com>Lincoln Baxter, III</a>
- *
*/
public interface FlashContext
{
Copied: modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/faces/exceptionhandling/FacesState.java (from rev 13077, modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/exceptionhandling/FacesState.java)
===================================================================
--- modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/faces/exceptionhandling/FacesState.java (rev 0)
+++ modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/faces/exceptionhandling/FacesState.java 2010-06-16 22:32:02 UTC (rev 13208)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.seam.faces.exceptionhandling;
+
+import org.jboss.seam.exceptionhandling.State;
+
+import javax.faces.context.FacesContext;
+
+/**
+ * Java Server Faces implementation of {@link org.jboss.seam.exceptionhandling.State}.
+ */
+public interface FacesState extends State
+{
+ /**
+ * @return the currently active Faces Context object
+ */
+ FacesContext getFacesContext();
+
+ /**
+ * Convenience method to facilitate navigation to a view id in an
+ * {@link org.jboss.seam.exceptionhandling.ExceptionHandler}.
+ *
+ * @param viewId JSF view to navigate
+ */
+ void navigate(String viewId);
+}
Property changes on: modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/faces/exceptionhandling/FacesState.java
___________________________________________________________________
Name: svn:mime-type
+ text/x-java-source
Name: svn:keywords
+ Author Date Id Revision URL
Name: svn:eol-style
+ native
Added: modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/ExceptionHandlerComparator.java
===================================================================
--- modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/ExceptionHandlerComparator.java (rev 0)
+++ modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/ExceptionHandlerComparator.java 2010-06-16 22:32:02 UTC (rev 13208)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.seam.exceptionhandling;
+
+import java.util.Comparator;
+
+/**
+ * Comparator to sort exception handlers according to priority (highest number first) then
+ * by class hierarchy of the Exception types being handled (most specific first).
+ */
+public class ExceptionHandlerComparator implements Comparator<ExceptionHandler>
+{
+ /**
+ * Compares its two arguments for order. Returns a negative integer,
+ * zero, or a positive integer as the first argument is less than, equal
+ * to, or greater than the second.<p>
+ * <p/>
+ * In the foregoing description, the notation
+ * <tt>sgn(</tt><i>expression</i><tt>)</tt> designates the mathematical
+ * <i>signum</i> function, which is defined to return one of <tt>-1</tt>,
+ * <tt>0</tt>, or <tt>1</tt> according to whether the value of
+ * <i>expression</i> is negative, zero or positive.<p>
+ * <p/>
+ * The implementor must ensure that <tt>sgn(compare(x, y)) ==
+ * -sgn(compare(y, x))</tt> for all <tt>x</tt> and <tt>y</tt>. (This
+ * implies that <tt>compare(x, y)</tt> must throw an exception if and only
+ * if <tt>compare(y, x)</tt> throws an exception.)<p>
+ * <p/>
+ * The implementor must also ensure that the relation is transitive:
+ * <tt>((compare(x, y)>0) && (compare(y, z)>0))</tt> implies
+ * <tt>compare(x, z)>0</tt>.<p>
+ * <p/>
+ * Finally, the implementor must ensure that <tt>compare(x, y)==0</tt>
+ * implies that <tt>sgn(compare(x, z))==sgn(compare(y, z))</tt> for all
+ * <tt>z</tt>.<p>
+ * <p/>
+ * It is generally the case, but <i>not</i> strictly required that
+ * <tt>(compare(x, y)==0) == (x.equals(y))</tt>. Generally speaking,
+ * any comparator that violates this condition should clearly indicate
+ * this fact. The recommended language is "Note: this comparator
+ * imposes orderings that are inconsistent with equals."
+ *
+ * @param lhs the first object to be compared.
+ * @param rhs the second object to be compared.
+ * @return a negative integer, zero, or a positive integer as the
+ * first argument is less than, equal to, or greater than the
+ * second.
+ * @throws ClassCastException if the arguments' types prevent them from
+ * being compared by this comparator.
+ */
+ public int compare(ExceptionHandler lhs, ExceptionHandler rhs)
+ {
+ if (lhs.getPriority() == rhs.getPriority())
+ {
+ final MethodParameterTypeHelper lhsTypes = new MethodParameterTypeHelper(lhs);
+ final MethodParameterTypeHelper rhsTypes = new MethodParameterTypeHelper(rhs);
+
+ if (lhsTypes.equals(rhsTypes))
+ {
+ return 0;
+ }
+ // the right hand side is the same or a sub type of left hand side
+ // In other words lhs is a parent type and show go later in the list
+ for (Class type : rhsTypes.getExceptionTypes())
+ {
+ if (lhsTypes.getExceptionTypes().contains(type))
+ {
+ return 1;
+ }
+ }
+ return -1;
+ }
+ return rhs.getPriority() - lhs.getPriority();
+ }
+}
Property changes on: modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/ExceptionHandlerComparator.java
___________________________________________________________________
Name: svn:mime-type
+ text/x-java-source
Name: svn:keywords
+ Author Date Id Revision URL
Name: svn:eol-style
+ native
Modified: modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/ExceptionHandlerExecutor.java
===================================================================
--- modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/ExceptionHandlerExecutor.java 2010-06-16 22:24:06 UTC (rev 13207)
+++ modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/ExceptionHandlerExecutor.java 2010-06-16 22:32:02 UTC (rev 13208)
@@ -38,62 +38,72 @@
{
/**
* Observes the event, finds the correct exception handler(s) and invokes them.
+ *
* @param event Event Payload
*/
@SuppressWarnings("unchecked")
public void executeHandlers(@Observes ExceptionEvent event)
{
final HandlerChain chain = new HandlerChainImpl();
- final Throwable exception = event.getException();
+ final Stack<Throwable> unwrappedExceptions = new Stack<Throwable>();
final State state = event.getState();
final BeanManager beanManager = state.getBeanManager();
- ExceptionHandler bean;
- final List<ExceptionHandler> beans = this.getContextualExceptionHandlerInstances(beanManager);
+ final Set<ExceptionHandler> validHandlers = new TreeSet<ExceptionHandler>(new ExceptionHandlerComparator());
+ final List<ExceptionHandler> allHandlers = this.getContextualExceptionHandlerInstances(beanManager);
+ Throwable exception = event.getException();
+ MethodParameterTypeHelper methodParameterTypeHelper;
+
+ do
+ {
+ unwrappedExceptions.push(exception);
+ }
+ while ((exception = exception.getCause()) != null);
+
// Finding the correct exception handlers using reflection based on the method
// to determine if it's the correct
+ for (ExceptionHandler handler : allHandlers)
+ {
+ methodParameterTypeHelper = new MethodParameterTypeHelper(handler);
- // TODO: Uwrap the exception
- for (Iterator<ExceptionHandler> iter = beans.iterator(); iter.hasNext();)
- {
- bean = iter.next();
- try
+ for (Throwable unwrapped : unwrappedExceptions)
{
- // TODO: search for type hierarchy as well.
- bean.getClass().getMethod("handle", HandlerChain.class, state.getClass().getInterfaces()[0], exception.getClass());
+ if (methodParameterTypeHelper.containsExceptionTypeOrSubType(unwrapped.getClass())
+ && methodParameterTypeHelper.containsStateTypeOrSubType(state.getClass()))
+ {
+ validHandlers.add(handler);
+ }
}
- catch (NoSuchMethodException e)
- {
- iter.remove();
- }
}
- // TODO: if priorities are the same look for type hierarchy
- Collections.sort(beans, new Comparator<ExceptionHandler>()
+ for (ExceptionHandler exceptionHandler : validHandlers)
{
- public int compare(ExceptionHandler lhs, ExceptionHandler rhs)
+ exceptionHandler.handle(chain, state, exception);
+ event.setExceptionHandled(true);
+
+ if (((HandlerChainImpl) chain).isChainEnd())
{
- return lhs.getPriority() - rhs.getPriority();
+ break;
}
- });
-
- for (ExceptionHandler handler : beans)
- {
- handler.handle(chain, state, exception);
- event.setExceptionHandled(true);
}
}
+ /**
+ * Method taken from Seam faces BeanManagerUtils.
+ *
+ * @param manager BeanManager instance
+ * @return List of instantiated found by the bean manager
+ */
@SuppressWarnings("unchecked")
- private <T> List<T> getContextualExceptionHandlerInstances(BeanManager manager)
+ private List<ExceptionHandler> getContextualExceptionHandlerInstances(BeanManager manager)
{
- List<T> result = new ArrayList<T>();
+ List<ExceptionHandler> result = new ArrayList<ExceptionHandler>();
for (Bean<?> bean : manager.getBeans(ExceptionHandler.class))
{
- CreationalContext<T> context = (CreationalContext<T>) manager.createCreationalContext(bean);
+ CreationalContext<ExceptionHandler> context = (CreationalContext<ExceptionHandler>) manager.createCreationalContext(bean);
if (context != null)
{
- result.add((T) manager.getReference(bean, ExceptionHandler.class, context));
+ result.add((ExceptionHandler) manager.getReference(bean, ExceptionHandler.class, context));
}
}
return result;
Deleted: modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/FacesStateImpl.java
===================================================================
--- modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/FacesStateImpl.java 2010-06-16 22:24:06 UTC (rev 13207)
+++ modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/FacesStateImpl.java 2010-06-16 22:32:02 UTC (rev 13208)
@@ -1,77 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.seam.exceptionhandling;
-
-import javax.enterprise.inject.spi.BeanManager;
-import javax.faces.application.NavigationHandler;
-import javax.faces.context.FacesContext;
-import javax.inject.Inject;
-
-public class FacesStateImpl implements FacesState
-{
- private BeanManager beanManager;
-
- private FacesContext facesContext;
-
- private NavigationHandler navigationHandler;
-
- public FacesStateImpl(BeanManager beanManager, FacesContext facesContext)
- {
- this.beanManager = beanManager;
- this.facesContext = facesContext;
- this.navigationHandler = facesContext.getApplication().getNavigationHandler();
- }
-
- /**
- * @return the currently active Faces Context object
- */
- public FacesContext getFacesContext()
- {
- return this.facesContext;
- }
-
- /**
- * Convenience method to facilitate navigation to a view id in an
- * {@link ExceptionHandler}.
- *
- * @param viewId JSF view to navigate
- */
- public void navigate(String viewId)
- {
- String currentViewId = null;
-
- if (this.facesContext.getViewRoot() != null)
- {
- currentViewId = this.facesContext.getViewRoot().getViewId();
- }
- this.navigationHandler.handleNavigation(this.facesContext, currentViewId, viewId);
- }
-
- /**
- * @return current BeanManager.
- */
- public BeanManager getBeanManager()
- {
- return this.beanManager;
- }
-}
Modified: modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/HandlerChainImpl.java
===================================================================
--- modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/HandlerChainImpl.java 2010-06-16 22:24:06 UTC (rev 13207)
+++ modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/HandlerChainImpl.java 2010-06-16 22:32:02 UTC (rev 13208)
@@ -22,23 +22,30 @@
package org.jboss.seam.exceptionhandling;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.inject.Inject;
-
+/**
+ * Implementation of the {@link HandlerChain} interface.
+ * Provides a package private method to check if the chain
+ * needs to end.
+ */
public class HandlerChainImpl implements HandlerChain
{
- private boolean continueChain;
+ private boolean chainEnd;
/**
- * Continue with the chain.
+ * End execution of the chain.
+ * Calling this method will immediately stop executing the handler chain, leaving any
+ * handlers left in the chain as uncalled.
*/
- public void next()
+ public void end()
{
- this.continueChain = true;
+ this.chainEnd = false;
}
- boolean isContinueChain()
+ /**
+ * @return flag indicating if the chain should continue execution
+ */
+ boolean isChainEnd()
{
- return this.continueChain;
+ return this.chainEnd;
}
}
Added: modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/MethodParameterTypeHelper.java
===================================================================
--- modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/MethodParameterTypeHelper.java (rev 0)
+++ modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/MethodParameterTypeHelper.java 2010-06-16 22:32:02 UTC (rev 13208)
@@ -0,0 +1,157 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.seam.exceptionhandling;
+
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Helper to encapsulate reflection code for finding parameter types on the handler method.
+ */
+final public class MethodParameterTypeHelper
+{
+ private Set<Class> exceptionTypes;
+ private Set<Class> stateTypes;
+
+ /**
+ * Constructor.
+ *
+ * @param handler Handler for which this helper is constructed
+ */
+ public MethodParameterTypeHelper(ExceptionHandler handler)
+ {
+ final Method[] methods = handler.getClass().getMethods();
+ this.exceptionTypes = new HashSet<Class>();
+ this.stateTypes = new HashSet<Class>();
+
+ for (Method m : methods)
+ {
+ if ("handle".equals(m.getName()))
+ {
+ this.stateTypes.add(m.getParameterTypes()[1]);
+ this.exceptionTypes.add(m.getParameterTypes()[2]);
+ }
+ }
+
+ // Cleanup base types if needed
+ if (this.stateTypes.size() > 1)
+ {
+ this.stateTypes.remove(State.class);
+ }
+
+ if (this.exceptionTypes.size() > 1)
+ {
+ this.exceptionTypes.remove(Throwable.class);
+ }
+ }
+
+ /**
+ * @return Unmodifiable collection of exception types found in the handle method(s).
+ */
+ public Collection<Class> getExceptionTypes()
+ {
+ return Collections.unmodifiableCollection(exceptionTypes);
+ }
+
+ /**
+ * @return Unmodifiable collection of exception types found in the handle method(s).
+ */
+ public Collection<Class> getStateTypes()
+ {
+ return Collections.unmodifiableCollection(stateTypes);
+ }
+
+ /**
+ * Looks for the given type or super types in the exception type collection.
+ *
+ * @param type type (or super types of) to search for
+ * @return flag indicating if the type or super types of that type are found
+ */
+ public boolean containsExceptionTypeOrSubType(Class type)
+ {
+ return this.containsTypeOrSubType(this.exceptionTypes, type);
+ }
+
+ /**
+ * Looks for the given type or super types in the state type collection.
+ *
+ * @param type type (or super types of) to search for
+ * @return flag indicating if the type or super types of that type are found
+ */
+ public boolean containsStateTypeOrSubType(Class type)
+ {
+ return this.containsTypeOrSubType(this.stateTypes, type);
+ }
+
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ MethodParameterTypeHelper that = (MethodParameterTypeHelper) o;
+
+ return this.exceptionTypes.equals(that.exceptionTypes) && this.stateTypes.equals(that.stateTypes);
+ }
+
+ public int hashCode()
+ {
+ int result = exceptionTypes != null ? exceptionTypes.hashCode() : 5;
+ result = 73 * result + (stateTypes != null ? stateTypes.hashCode() : 5);
+ return result;
+ }
+
+ /**
+ * Looks for the given type or super types in the given collection.
+ *
+ * @param types Collection to search
+ * @param type type (or super types of) to search for
+ * @return flag indicating if the type or super types of that type are found
+ */
+ @SuppressWarnings("unchecked")
+ private boolean containsTypeOrSubType(Collection<Class> types, Class type)
+ {
+ if (types.contains(type))
+ {
+ return true;
+ }
+
+ for (Class t : types)
+ {
+ if (t.isAssignableFrom(type))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+}
Property changes on: modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/MethodParameterTypeHelper.java
___________________________________________________________________
Name: svn:mime-type
+ text/x-java-source
Name: svn:keywords
+ Author Date Id Revision URL
Name: svn:eol-style
+ native
Added: modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/StateImpl.java
===================================================================
--- modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/StateImpl.java (rev 0)
+++ modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/StateImpl.java 2010-06-16 22:32:02 UTC (rev 13208)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.seam.exceptionhandling;
+
+import javax.enterprise.inject.spi.BeanManager;
+
+/**
+ * Basic {@link State} implementation.
+ */
+public class StateImpl implements State
+{
+ private BeanManager beanManager;
+
+ /**
+ * Constructor
+ *
+ * @param beanManager instance of {@link BeanManager}.
+ */
+ public StateImpl(BeanManager beanManager)
+ {
+ this.beanManager = beanManager;
+ }
+
+ /**
+ * @return current BeanManager.
+ */
+ public BeanManager getBeanManager()
+ {
+ return this.beanManager;
+ }
+}
Property changes on: modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/StateImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/x-java-source
Name: svn:keywords
+ Author Date Id Revision URL
Name: svn:eol-style
+ native
Copied: modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/faces/exceptionhandling/FacesStateImpl.java (from rev 13167, modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/FacesStateImpl.java)
===================================================================
--- modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/faces/exceptionhandling/FacesStateImpl.java (rev 0)
+++ modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/faces/exceptionhandling/FacesStateImpl.java 2010-06-16 22:32:02 UTC (rev 13208)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.seam.faces.exceptionhandling;
+
+import org.jboss.seam.exceptionhandling.StateImpl;
+
+import javax.enterprise.inject.spi.BeanManager;
+import javax.faces.application.NavigationHandler;
+import javax.faces.context.FacesContext;
+
+public class FacesStateImpl extends StateImpl implements FacesState
+{
+
+ private FacesContext facesContext;
+
+ private NavigationHandler navigationHandler;
+
+ public FacesStateImpl(BeanManager beanManager, FacesContext facesContext)
+ {
+ super(beanManager);
+ this.facesContext = facesContext;
+ this.navigationHandler = facesContext.getApplication().getNavigationHandler();
+ }
+
+ /**
+ * @return the currently active Faces Context object
+ */
+ public FacesContext getFacesContext()
+ {
+ return this.facesContext;
+ }
+
+ /**
+ * Convenience method to facilitate navigation to a view id in an
+ * {@link org.jboss.seam.exceptionhandling.ExceptionHandler}.
+ *
+ * @param viewId JSF view to navigate
+ */
+ public void navigate(String viewId)
+ {
+ String currentViewId = null;
+
+ if (this.facesContext.getViewRoot() != null)
+ {
+ currentViewId = this.facesContext.getViewRoot().getViewId();
+ }
+ this.navigationHandler.handleNavigation(this.facesContext, currentViewId, viewId);
+ }
+
+}
Property changes on: modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/faces/exceptionhandling/FacesStateImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/x-java-source
Name: svn:keywords
+ Author Date Id Revision URL
Name: svn:eol-style
+ native
Modified: modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/faces/exceptionhandling/SeamExceptionHandler.java
===================================================================
--- modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/faces/exceptionhandling/SeamExceptionHandler.java 2010-06-16 22:24:06 UTC (rev 13207)
+++ modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/faces/exceptionhandling/SeamExceptionHandler.java 2010-06-16 22:32:02 UTC (rev 13208)
@@ -23,29 +23,18 @@
package org.jboss.seam.faces.exceptionhandling;
import org.jboss.seam.exceptionhandling.ExceptionEvent;
-import org.jboss.seam.exceptionhandling.FacesState;
-import org.jboss.seam.exceptionhandling.FacesStateImpl;
import org.jboss.seam.exceptionhandling.HandlerChain;
-import org.jboss.seam.faces.util.BeanManagerUtils;
import org.jboss.weld.extensions.beanManager.BeanManagerAccessor;
-import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.event.Event;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
-import javax.enterprise.util.TypeLiteral;
import javax.faces.FacesException;
-import javax.faces.context.*;
import javax.faces.context.ExceptionHandler;
+import javax.faces.context.ExceptionHandlerWrapper;
+import javax.faces.context.FacesContext;
import javax.faces.event.ExceptionQueuedEvent;
import javax.inject.Inject;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
import java.util.Iterator;
-import java.util.List;
import java.util.Set;
public class SeamExceptionHandler extends ExceptionHandlerWrapper
Added: modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/BaseExceptionHandler.java
===================================================================
--- modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/BaseExceptionHandler.java (rev 0)
+++ modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/BaseExceptionHandler.java 2010-06-16 22:32:02 UTC (rev 13208)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.seam.exceptionhandling;
+
+import org.joda.time.DateTime;
+
+public class BaseExceptionHandler
+{
+ protected boolean handleCalled;
+ protected boolean callEnd;
+ protected DateTime timeCalled;
+
+ public boolean isHandleCalled()
+ {
+ return this.handleCalled;
+ }
+
+ public void shouldCallEnd(boolean callEnd)
+ {
+ this.callEnd = callEnd;
+ }
+
+ public DateTime getTimeCalled()
+ {
+ return this.timeCalled;
+ }
+
+ /**
+ * Method called to execute logic for an uncaught exception.
+ *
+ * @param chain Chain object used to continue handling chain
+ * @param state container for any useful application state
+ * @param e uncaught exception
+ */
+ public void baseHandle(HandlerChain chain, State state, Throwable e)
+ {
+ this.timeCalled = new DateTime();
+ this.handleCalled = true;
+
+ if (this.callEnd)
+ {
+ chain.end();
+ }
+ }
+}
Property changes on: modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/BaseExceptionHandler.java
___________________________________________________________________
Name: svn:mime-type
+ text/x-java-source
Name: svn:keywords
+ Author Date Id Revision URL
Name: svn:eol-style
+ native
Added: modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/BaseExceptionHandlerTest.java
===================================================================
--- modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/BaseExceptionHandlerTest.java (rev 0)
+++ modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/BaseExceptionHandlerTest.java 2010-06-16 22:32:02 UTC (rev 13208)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.seam.exceptionhandling;
+
+import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
+
+public class BaseExceptionHandlerTest
+{
+ @Inject
+ protected BeanManager beanManager;
+}
Property changes on: modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/BaseExceptionHandlerTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/x-java-source
Name: svn:keywords
+ Author Date Id Revision URL
Name: svn:eol-style
+ native
Added: modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/ExceptionExceptionHandler.java
===================================================================
--- modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/ExceptionExceptionHandler.java (rev 0)
+++ modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/ExceptionExceptionHandler.java 2010-06-16 22:32:02 UTC (rev 13208)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.seam.exceptionhandling;
+
+import javax.enterprise.context.RequestScoped;
+
+@RequestScoped
+public class ExceptionExceptionHandler extends BaseExceptionHandler implements ExceptionHandler<Exception, State>
+{
+ /**
+ * @return the numeric priority of this handler in relationship to
+ * other handlers, 1 being top priority
+ */
+ public int getPriority()
+ {
+ return 0; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ /**
+ * Method called to execute logic for an uncaught exception.
+ *
+ * @param chain Chain object used to continue handling chain
+ * @param state container for any useful application state
+ * @param e uncaught exception
+ */
+ public void handle(HandlerChain chain, State state, Exception e)
+ {
+ super.baseHandle(chain, state, e);
+ }
+}
Property changes on: modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/ExceptionExceptionHandler.java
___________________________________________________________________
Name: svn:mime-type
+ text/x-java-source
Name: svn:keywords
+ Author Date Id Revision URL
Name: svn:eol-style
+ native
Added: modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/ExceptionHandlerComparatorTest.java
===================================================================
--- modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/ExceptionHandlerComparatorTest.java (rev 0)
+++ modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/ExceptionHandlerComparatorTest.java 2010-06-16 22:32:02 UTC (rev 13208)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.seam.exceptionhandling;
+
+import org.junit.Test;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+
+public class ExceptionHandlerComparatorTest
+{
+ @Test
+ public void testHandlersCalledInCorrectOrder()
+ {
+ NullPointerExceptionHandler nullPointerExceptionHandler = new NullPointerExceptionHandler();
+ ExceptionExceptionHandler exceptionExceptionHandler = new ExceptionExceptionHandler();
+ UnsupportedOperationExceptionHandler unsupportedOperationExceptionHandler = new UnsupportedOperationExceptionHandler();
+ List<? extends ExceptionHandler<? extends Exception, State>> handlerList;
+ handlerList = Arrays.asList(nullPointerExceptionHandler, exceptionExceptionHandler, unsupportedOperationExceptionHandler);
+
+ Collections.sort(handlerList, new ExceptionHandlerComparator());
+
+ assertEquals(unsupportedOperationExceptionHandler, handlerList.get(0));
+ assertEquals(nullPointerExceptionHandler, handlerList.get(1));
+ assertEquals(exceptionExceptionHandler, handlerList.get(2));
+ }
+
+ @Test
+ public void testHandlersCalledInCorrectOrder2()
+ {
+ NullPointerExceptionHandler nullPointerExceptionHandler = new NullPointerExceptionHandler();
+ ExceptionExceptionHandler exceptionExceptionHandler = new ExceptionExceptionHandler();
+ UnsupportedOperationExceptionHandler unsupportedOperationExceptionHandler = new UnsupportedOperationExceptionHandler();
+ List<? extends ExceptionHandler<? extends Exception, State>> handlerList;
+ handlerList = Arrays.asList(nullPointerExceptionHandler, unsupportedOperationExceptionHandler, exceptionExceptionHandler);
+
+ Collections.sort(handlerList, new ExceptionHandlerComparator());
+
+ assertEquals(unsupportedOperationExceptionHandler, handlerList.get(0));
+ assertEquals(nullPointerExceptionHandler, handlerList.get(1));
+ assertEquals(exceptionExceptionHandler, handlerList.get(2));
+ }
+}
Property changes on: modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/ExceptionHandlerComparatorTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/x-java-source
Name: svn:keywords
+ Author Date Id Revision URL
Name: svn:eol-style
+ native
Deleted: modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/ExceptionHandlerTest.java
===================================================================
--- modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/ExceptionHandlerTest.java 2010-06-16 22:24:06 UTC (rev 13207)
+++ modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/ExceptionHandlerTest.java 2010-06-16 22:32:02 UTC (rev 13208)
@@ -1,100 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.seam.exceptionhandling;
-
-import org.jboss.arquillian.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.seam.faces.environment.FacesContextProducer;
-import org.jboss.seam.faces.environment.MockFacesContext;
-import org.jboss.seam.faces.exceptionhandling.SeamExceptionHandler;
-import org.jboss.seam.faces.exceptionhandling.SeamExceptionHandlerFactory;
-import org.jboss.shrinkwrap.api.Archive;
-import org.jboss.shrinkwrap.api.ArchivePaths;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.JavaArchive;
-import org.jboss.shrinkwrap.impl.base.asset.ByteArrayAsset;
-import org.jboss.test.faces.mock.MockFacesEnvironment;
-import org.jboss.test.faces.mock.application.MockApplication;
-import org.jboss.test.faces.mock.application.MockNavigationHandler;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import javax.enterprise.inject.Instance;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.faces.application.NavigationHandler;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIComponentBase;
-import javax.faces.context.ExceptionHandlerFactory;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.inject.Inject;
-
-import java.io.IOException;
-
-import static org.easymock.EasyMock.expect;
-import static org.junit.Assert.assertTrue;
-
-(a)RunWith(Arquillian.class)
-public class ExceptionHandlerTest
-{
- @Inject
- private SeamExceptionHandler seamHandler;
-
- @Inject
- private UnsupportedOperationExceptionHandler handler;
-
- @Inject
- private BeanManager beanManager;
-
- private MockFacesEnvironment environment;
-
- @Deployment
- public static Archive<?> createTestArchive()
- {
- return ShrinkWrap.create("test.jar", JavaArchive.class)
- .addClasses(UnsupportedOperationExceptionHandler.class, SeamExceptionHandler.class,
- ExceptionHandlerExecutor.class)
- .addManifestResource(new ByteArrayAsset(new byte[0]), ArchivePaths.create("beans.xml"));
- }
-
- @Before
- public void setup()
- {
- this.environment = MockFacesEnvironment.createEnvironment().withApplication();
-
- expect(this.environment.getApplication().getNavigationHandler())
- .andStubReturn(this.environment.createMock(NavigationHandler.class));
-
- this.environment.replay();
- }
-
- @Test
- public void testHandlerIsCalled() throws IOException
- {
- ExceptionEvent event = new ExceptionEvent(new UnsupportedOperationException(), new FacesStateImpl(this.beanManager, this.environment.getFacesContext()));
- this.beanManager.fireEvent(event);
- assertTrue(this.handler.isHandleCalled());
- assertTrue(event.isExceptionHandled());
- }
-}
Added: modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/MultipleHandlerTest.java
===================================================================
--- modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/MultipleHandlerTest.java (rev 0)
+++ modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/MultipleHandlerTest.java 2010-06-16 22:32:02 UTC (rev 13208)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.seam.exceptionhandling;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.impl.base.asset.ByteArrayAsset;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.inject.Inject;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+(a)RunWith(Arquillian.class)
+public class MultipleHandlerTest extends BaseExceptionHandlerTest
+{
+ @Inject
+ private UnsupportedOperationExceptionHandler unsupportedOperationExceptionHandler;
+
+ @Inject
+ private ExceptionExceptionHandler exceptionExceptionHandler;
+
+ @Inject
+ private NullPointerExceptionHandler nullPointerExceptionHandler;
+
+ @Deployment
+ public static Archive<?> createTestArchive()
+ {
+ return ShrinkWrap.create("test.jar", JavaArchive.class)
+ .addClasses(UnsupportedOperationExceptionHandler.class, ExceptionExceptionHandler.class,
+ ExceptionHandlerExecutor.class, NullPointerExceptionHandler.class)
+ .addManifestResource(new ByteArrayAsset(new byte[0]), ArchivePaths.create("beans.xml"));
+ }
+
+ @Test
+ public void testAllValidHandlersCalled()
+ {
+ ExceptionEvent event = new ExceptionEvent(new UnsupportedOperationException(), new StateImpl(this.beanManager));
+ this.beanManager.fireEvent(event);
+
+ assertTrue(this.unsupportedOperationExceptionHandler.isHandleCalled());
+ assertTrue(this.exceptionExceptionHandler.isHandleCalled());
+ assertFalse(this.nullPointerExceptionHandler.isHandleCalled());
+ }
+}
Property changes on: modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/MultipleHandlerTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/x-java-source
Name: svn:keywords
+ Author Date Id Revision URL
Name: svn:eol-style
+ native
Added: modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/NullPointerExceptionHandler.java
===================================================================
--- modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/NullPointerExceptionHandler.java (rev 0)
+++ modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/NullPointerExceptionHandler.java 2010-06-16 22:32:02 UTC (rev 13208)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.seam.exceptionhandling;
+
+import javax.enterprise.context.RequestScoped;
+
+@RequestScoped
+public class NullPointerExceptionHandler extends BaseExceptionHandler implements ExceptionHandler<NullPointerException, State>
+{
+ /**
+ * @return the numeric priority of this handler in relationship to
+ * other handlers, 1 being top priority
+ */
+ public int getPriority()
+ {
+ return 0; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ /**
+ * Method called to execute logic for an uncaught exception.
+ *
+ * @param chain Chain object used to continue handling chain
+ * @param state container for any useful application state
+ * @param e uncaught exception
+ */
+ public void handle(HandlerChain chain, State state, NullPointerException e)
+ {
+ super.baseHandle(chain, state, e);
+ }
+}
Property changes on: modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/NullPointerExceptionHandler.java
___________________________________________________________________
Name: svn:mime-type
+ text/x-java-source
Name: svn:keywords
+ Author Date Id Revision URL
Name: svn:eol-style
+ native
Deleted: modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/ThrowExceptionRenderer.java
===================================================================
--- modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/ThrowExceptionRenderer.java 2010-06-16 22:24:06 UTC (rev 13207)
+++ modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/ThrowExceptionRenderer.java 2010-06-16 22:32:02 UTC (rev 13208)
@@ -1,52 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.seam.exceptionhandling;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.render.Renderer;
-import java.io.IOException;
-
-public class ThrowExceptionRenderer extends Renderer
-{
- /**
- * <p>Render the beginning specified {@link javax.faces.component.UIComponent} to the
- * output stream or writer associated with the response we are creating.
- * If the conversion attempted in a previous call to
- * <code>getConvertedValue()</code> for this component failed, the state
- * information saved during execution
- * of <code>decode()</code> should be used to reproduce the incorrect
- * input.</p>
- *
- * @param context {@link javax.faces.context.FacesContext} for the request we are processing
- * @param component {@link javax.faces.component.UIComponent} to be rendered
- * @throws java.io.IOException if an input/output error occurs while rendering
- * @throws NullPointerException if <code>context</code>
- * or <code>component</code> is null
- */
- @Override
- public void encodeBegin(FacesContext context, UIComponent component) throws IOException
- {
- throw new UnsupportedOperationException();
- }
-}
Modified: modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/UnsupportedOperationExceptionHandler.java
===================================================================
--- modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/UnsupportedOperationExceptionHandler.java 2010-06-16 22:24:06 UTC (rev 13207)
+++ modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/UnsupportedOperationExceptionHandler.java 2010-06-16 22:32:02 UTC (rev 13208)
@@ -25,9 +25,8 @@
import javax.enterprise.context.RequestScoped;
@RequestScoped
-public class UnsupportedOperationExceptionHandler implements ExceptionHandler<UnsupportedOperationException, FacesState>
+public class UnsupportedOperationExceptionHandler extends BaseExceptionHandler implements ExceptionHandler<UnsupportedOperationException, State>
{
- private boolean handleCalled;
/**
* @return the numeric priority of this handler in relationship to
@@ -35,7 +34,7 @@
*/
public int getPriority()
{
- return 0; //To change body of implemented methods use File | Settings | File Templates.
+ return 1; //To change body of implemented methods use File | Settings | File Templates.
}
/**
@@ -45,13 +44,8 @@
* @param state container for any useful application state
* @param e uncaught exception
*/
- public void handle(HandlerChain chain, FacesState state, UnsupportedOperationException e)
+ public void handle(HandlerChain chain, State state, UnsupportedOperationException e)
{
- this.handleCalled = true;
+ super.baseHandle(chain, state, e);
}
-
- public boolean isHandleCalled()
- {
- return this.handleCalled;
- }
}
Copied: modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/UnsupportedOperationExceptionHandlerTest.java (from rev 13167, modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/ExceptionHandlerTest.java)
===================================================================
--- modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/UnsupportedOperationExceptionHandlerTest.java (rev 0)
+++ modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/UnsupportedOperationExceptionHandlerTest.java 2010-06-16 22:32:02 UTC (rev 13208)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.seam.exceptionhandling;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.impl.base.asset.ByteArrayAsset;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.inject.Inject;
+import java.io.IOException;
+
+import static org.junit.Assert.assertTrue;
+
+(a)RunWith(Arquillian.class)
+public class UnsupportedOperationExceptionHandlerTest extends BaseExceptionHandlerTest
+{
+ @Inject
+ private UnsupportedOperationExceptionHandler handler;
+
+ @Deployment
+ public static Archive<?> createTestArchive()
+ {
+ return ShrinkWrap.create("test.jar", JavaArchive.class)
+ .addClasses(UnsupportedOperationExceptionHandler.class, ExceptionHandlerExecutor.class)
+ .addManifestResource(new ByteArrayAsset(new byte[0]), ArchivePaths.create("beans.xml"));
+ }
+
+ @Test
+ public void testHandlerIsCalled() throws IOException
+ {
+ this.handler.shouldCallEnd(true); // Set so I can reuse this handler in different tests
+ ExceptionEvent event = new ExceptionEvent(new UnsupportedOperationException(), new StateImpl(this.beanManager));
+ this.beanManager.fireEvent(event);
+
+ assertTrue(this.handler.isHandleCalled());
+ assertTrue(event.isExceptionHandled());
+ }
+}
Property changes on: modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/UnsupportedOperationExceptionHandlerTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/x-java-source
Name: svn:keywords
+ Author Date Id Revision URL
Name: svn:eol-style
+ native
15 years, 6 months
Seam SVN: r13207 - in examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking: booking and 1 other directories.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2010-06-16 18:24:06 -0400 (Wed, 16 Jun 2010)
New Revision: 13207
Modified:
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManagerBean.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgentBean.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearchBean.java
Log:
cleanup
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManagerBean.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManagerBean.java 2010-06-16 22:20:40 UTC (rev 13206)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManagerBean.java 2010-06-16 22:24:06 UTC (rev 13207)
@@ -7,7 +7,6 @@
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
-import org.jboss.seam.examples.booking.controls.RegistrationFormControls;
import org.jboss.seam.examples.booking.model.User;
import org.jboss.seam.international.status.Messages;
import org.jboss.seam.international.status.builder.BundleKey;
@@ -27,9 +26,6 @@
private Messages messages;
@Inject
- private RegistrationFormControls formControls;
-
- @Inject
@Authenticated
private User user;
@@ -42,8 +38,6 @@
em.merge(user);
messages.info(new BundleKey("messages", "account.passwordChanged")).textDefault("Password successfully updated.");
changed = true;
- // messages.error(new BundleKey("messages",
- // "account.passwordsDoNotMatch")).textDefault("Passwords do not match. Please re-type the new password.");
}
public boolean isChanged()
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgentBean.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgentBean.java 2010-06-16 22:20:40 UTC (rev 13206)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgentBean.java 2010-06-16 22:24:06 UTC (rev 13207)
@@ -61,7 +61,7 @@
private EntityManager em;
@Inject
- private MessageFactory mf;
+ private MessageFactory msg;
@Inject
private Messages messages;
@@ -90,7 +90,7 @@
hotelSelection = em.find(Hotel.class, id);
if (hotelSelection != null)
{
- log.info(mf.info("Selected the {0} in {1}").textParams(hotelSelection.getName(), hotelSelection.getCity()).build().getText());
+ log.info(msg.info("Selected the {0} in {1}").textParams(hotelSelection.getName(), hotelSelection.getCity()).build().getText());
}
}
@@ -132,7 +132,7 @@
em.persist(booking);
// FIXME can't inject event object into bean with passivating scope
manager.fireEvent(new BookingEvent(booking), ConfirmedLiteral.INSTANCE);
- log.info(mf.info("New booking at the {0} confirmed for {1}").textParams(booking.getHotel().getName(), booking.getUser().getName()).build().getText());
+ log.info(msg.info("New booking at the {0} confirmed for {1}").textParams(booking.getHotel().getName(), booking.getUser().getName()).build().getText());
messages.info(new BundleKey("messages", "booking.confirmed")).textDefault("Booking confirmed.");
}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearchBean.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearchBean.java 2010-06-16 22:20:40 UTC (rev 13206)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearchBean.java 2010-06-16 22:24:06 UTC (rev 13207)
@@ -58,7 +58,7 @@
private SearchCriteria criteria;
@Inject
- private MessageFactory mf;
+ private MessageFactory msg;
private boolean nextPageAvailable = false;
@@ -130,7 +130,7 @@
{
hotels = results;
}
- log.info(mf.info("Found {0} hotel(s) matching search term [ {1} ] (limit {2})")
+ log.info(msg.info("Found {0} hotel(s) matching search term [ {1} ] (limit {2})")
.textParams(hotels.size(), criteria.getQuery(), criteria.getPageSize()).build().getText());
}
}
15 years, 6 months
Seam SVN: r13206 - examples/trunk/booking-simplified/src/main/webapp.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2010-06-16 18:20:40 -0400 (Wed, 16 Jun 2010)
New Revision: 13206
Modified:
examples/trunk/booking-simplified/src/main/webapp/confirm.xhtml
Log:
short name for conversation
Modified: examples/trunk/booking-simplified/src/main/webapp/confirm.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/confirm.xhtml 2010-06-16 22:16:42 UTC (rev 13205)
+++ examples/trunk/booking-simplified/src/main/webapp/confirm.xhtml 2010-06-16 22:20:40 UTC (rev 13206)
@@ -38,7 +38,7 @@
<h:commandButton id="confirm" value="Confirm" action="#{bookingAgent.confirm}"/>
#{' '}
<h:button id="revise" value="Revise" outcome="/book.xhtml">
- <f:param name="cid" value="#{javax.context.conversation.id}"/>
+ <f:param name="cid" value="#{conversation.id}"/>
</h:button>
#{' '}
<h:commandButton id="cancel" value="Cancel" action="#{bookingAgent.cancel}" immediate="true"/>
15 years, 6 months
Seam SVN: r13205 - examples/trunk/booking-simplified/src/main/java/org/jboss/seam/faces/component.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2010-06-16 18:16:42 -0400 (Wed, 16 Jun 2010)
New Revision: 13205
Modified:
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/faces/component/UIInputContainer.java
Log:
smarter name creation
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/faces/component/UIInputContainer.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/faces/component/UIInputContainer.java 2010-06-16 22:09:52 UTC (rev 13204)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/faces/component/UIInputContainer.java 2010-06-16 22:16:42 UTC (rev 13205)
@@ -276,7 +276,26 @@
protected String generateLabel(final InputContainerElements elements, final FacesContext context)
{
String name = getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX) ? elements.getPropertyName(context) : getId();
- return name.substring(0, 1).toUpperCase() + name.substring(1);
+ StringBuilder builder = new StringBuilder(name.length());
+ boolean first = true;
+ for (char c : name.toCharArray())
+ {
+ if (first)
+ {
+ builder.append(Character.toUpperCase(c));
+ first = false;
+ }
+ else if (Character.isUpperCase(c))
+ {
+ builder.append(" ");
+ builder.append(Character.toLowerCase(c));
+ }
+ else
+ {
+ builder.append(c);
+ }
+ }
+ return builder.toString();
}
/**
15 years, 6 months