Seam SVN: r13224 - in examples/trunk/booking-simplified/src/main: webapp and 4 other directories.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2010-06-17 17:12:01 -0400 (Thu, 17 Jun 2010)
New Revision: 13224
Added:
examples/trunk/booking-simplified/src/main/webapp/resources/components/model/
examples/trunk/booking-simplified/src/main/webapp/resources/components/model/displayAccount.xhtml
examples/trunk/booking-simplified/src/main/webapp/resources/components/model/displayHotel.xhtml
Removed:
examples/trunk/booking-simplified/src/main/webapp/WEB-INF/fragments/
Modified:
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/faces/component/UIInputContainer.java
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/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/output.xhtml
Log:
replace fragments with composite components
bug fixes to UIInputContainer
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 19:34:31 UTC (rev 13223)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/faces/component/UIInputContainer.java 2010-06-17 21:12:01 UTC (rev 13224)
@@ -42,6 +42,7 @@
import javax.faces.component.UIViewRoot;
import javax.faces.component.behavior.AjaxBehavior;
import javax.faces.component.behavior.ClientBehavior;
+import javax.faces.component.behavior.ClientBehaviorHolder;
import javax.faces.component.html.HtmlOutputLabel;
import javax.faces.context.FacesContext;
import javax.faces.validator.BeanValidator;
@@ -268,10 +269,13 @@
// 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())
+ if (i instanceof ClientBehaviorHolder)
{
- b.get(k).clear();
+ Map<String, List<ClientBehavior>> b = ((ClientBehaviorHolder) i).getClientBehaviors();
+ for (String k : b.keySet())
+ {
+ b.get(k).clear();
+ }
}
}
}
@@ -503,21 +507,24 @@
public void registerInput(final EditableValueHolder input, final Validator validator, final FacesContext context)
{
inputs.add(input);
- UIInput inputc = (UIInput) input;
- String ajaxEvent = (String) attributes.get(getAjaxAttributeName());
- if (ajaxEvent != null && (ajaxEvent.equalsIgnoreCase("default")))
+ if (input instanceof ClientBehaviorHolder)
{
- ajaxEvent = inputc.getDefaultEventName();
- }
- if (ajaxEvent != null)
- {
- Map<String, List<ClientBehavior>> behaviors = inputc.getClientBehaviors();
- if (!behaviors.containsKey(ajaxEvent))
+ ClientBehaviorHolder bh = (ClientBehaviorHolder) input;
+ String ajaxEvent = (String) attributes.get(getAjaxAttributeName());
+ if (ajaxEvent != null && (ajaxEvent.equalsIgnoreCase("default")))
{
- AjaxBehavior ajax = new AjaxBehavior();
- ajax.setRender(Arrays.asList(containerId));
- inputc.addClientBehavior(ajaxEvent.toLowerCase(), ajax);
+ ajaxEvent = bh.getDefaultEventName();
}
+ if (ajaxEvent != null)
+ {
+ Map<String, List<ClientBehavior>> behaviors = bh.getClientBehaviors();
+ if (!behaviors.containsKey(ajaxEvent))
+ {
+ AjaxBehavior ajax = new AjaxBehavior();
+ ajax.setRender(Arrays.asList(containerId));
+ bh.addClientBehavior(ajaxEvent.toLowerCase(), ajax);
+ }
+ }
}
if (input.isRequired() || isRequiredByConstraint(input, validator, context))
{
@@ -569,13 +576,21 @@
return false;
}
- // NOTE believe it or not, getValueReference on ValueExpression is
- // broken, so we have to do it ourselves
- ValueReference vref = new ValueExpressionAnalyzer(((UIComponent) input).getValueExpression("value")).getValueReference(context.getELContext());
- PropertyDescriptor d = validator.getConstraintsForClass(vref.getBase().getClass()).getConstraintsForProperty((String) vref.getProperty());
+ ValueReference vref = buildValueReference(input, context);
+ String property = (String) vref.getProperty();
+ // optimization, though not sitting right
+ if (propertyName != null)
+ {
+ propertyName = property;
+ }
+ PropertyDescriptor d = validator.getConstraintsForClass(vref.getBase().getClass()).getConstraintsForProperty(property);
return (d != null) && d.hasConstraints();
}
+ /**
+ * Gets the name of the property bound to the first input, or null if there
+ * are no inputs present.
+ */
public String getPropertyName(final FacesContext context)
{
if (propertyName != null)
@@ -588,10 +603,17 @@
return null;
}
- propertyName = (String) new ValueExpressionAnalyzer(((UIComponent) inputs.get(0)).getValueExpression("value")).getValueReference(context.getELContext()).getProperty();
+ propertyName = buildValueReference(inputs.get(0), context).getProperty().toString();
return propertyName;
}
+ private ValueReference buildValueReference(final EditableValueHolder input, final FacesContext context)
+ {
+ // NOTE believe it or not, getValueReference on ValueExpression is broken, so we have to do it ourselves
+ return new ValueExpressionAnalyzer(((UIComponent) input).getValueExpression("value"))
+ .getValueReference(context.getELContext());
+ }
+
public void wire(final FacesContext context)
{
int numInputs = inputs.size();
Modified: examples/trunk/booking-simplified/src/main/webapp/account.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/account.xhtml 2010-06-17 19:34:31 UTC (rev 13223)
+++ examples/trunk/booking-simplified/src/main/webapp/account.xhtml 2010-06-17 21:12:01 UTC (rev 13224)
@@ -4,6 +4,7 @@
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:m="http://http://java.sun.com/jsf/composite/components/model"
template="/WEB-INF/layout/template.xhtml">
<ui:define name="content">
@@ -18,7 +19,7 @@
<h:messages id="messages" globalOnly="true"/>
</div>
- <ui:include src="/WEB-INF/fragments/account.xhtml"/>
+ <m:displayAccount value="#{currentUser}" showEmail="true"/>
<div class="buttonBox">
<h:button id="changePassword" value="Change password" outcome="/password.xhtml"/>
Modified: examples/trunk/booking-simplified/src/main/webapp/book.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/book.xhtml 2010-06-17 19:34:31 UTC (rev 13223)
+++ examples/trunk/booking-simplified/src/main/webapp/book.xhtml 2010-06-17 21:12:01 UTC (rev 13224)
@@ -5,6 +5,7 @@
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:s="http://jboss.org/seam/faces"
+ xmlns:m="http://http://java.sun.com/jsf/composite/components/model"
xmlns:p="http://http://java.sun.com/jsf/composite/components/property"
template="/WEB-INF/layout/template.xhtml">
@@ -18,7 +19,7 @@
<h:messages id="messages" globalOnly="true"/>
</div>
- <ui:include src="/WEB-INF/fragments/hotel.xhtml"/>
+ <m:displayHotel value="#{hotel}"/>
<div style="clear: both;"/>
Modified: examples/trunk/booking-simplified/src/main/webapp/confirm.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/confirm.xhtml 2010-06-17 19:34:31 UTC (rev 13223)
+++ examples/trunk/booking-simplified/src/main/webapp/confirm.xhtml 2010-06-17 21:12:01 UTC (rev 13224)
@@ -4,6 +4,7 @@
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:m="http://http://java.sun.com/jsf/composite/components/model"
xmlns:p="http://http://java.sun.com/jsf/composite/components/property"
template="/WEB-INF/layout/template.xhtml">
@@ -15,7 +16,7 @@
<div class="section">
- <ui:include src="/WEB-INF/fragments/hotel.xhtml"/>
+ <m:displayHotel value="#{hotel}"/>
<p:output label="Total payment" value="#{booking.total}">
<f:convertNumber for="output" type="currency" currencySymbol="$"/>
Modified: examples/trunk/booking-simplified/src/main/webapp/hotel.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/hotel.xhtml 2010-06-17 19:34:31 UTC (rev 13223)
+++ examples/trunk/booking-simplified/src/main/webapp/hotel.xhtml 2010-06-17 21:12:01 UTC (rev 13224)
@@ -5,6 +5,7 @@
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:s="http://jboss.org/seam/faces"
+ xmlns:m="http://java.sun.com/jsf/composite/components/model"
template="/WEB-INF/layout/template.xhtml">
<f:metadata>
@@ -19,7 +20,7 @@
</div>
<div class="section">
- <ui:include src="/WEB-INF/fragments/hotel.xhtml"/>
+ <m:displayHotel value="#{hotel}"/>
<div class="buttonBox">
<h:panelGroup rendered="#{not identity.loggedIn}">
Modified: examples/trunk/booking-simplified/src/main/webapp/password.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/password.xhtml 2010-06-17 19:34:31 UTC (rev 13223)
+++ examples/trunk/booking-simplified/src/main/webapp/password.xhtml 2010-06-17 21:12:01 UTC (rev 13224)
@@ -26,7 +26,7 @@
<p:input id="current">
<h:inputSecret id="password" value="#{currentUser.password}">
- <f:validator validatorId="currentPasswordValidator" />
+ <f:validator validatorId="currentPasswordValidator"/>
</h:inputSecret>
</p:input>
Modified: examples/trunk/booking-simplified/src/main/webapp/register.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/register.xhtml 2010-06-17 19:34:31 UTC (rev 13223)
+++ examples/trunk/booking-simplified/src/main/webapp/register.xhtml 2010-06-17 21:12:01 UTC (rev 13224)
@@ -5,7 +5,7 @@
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"
+ xmlns:prop="http://http://java.sun.com/jsf/composite/components/property"
template="/WEB-INF/layout/template.xhtml">
<ui:param name="pageClass" value="home"/>
@@ -29,9 +29,9 @@
</div>
<h:form id="registrationForm" prependId="false">
- <h:outputScript name="jsf.js" library="javax.faces" target="head"/>
<fieldset>
+ <!-- manually append Ajax behavior -->
<p:input id="username">
<h:inputText id="input" value="#{newUser.username}"
binding="#{registrar.usernameInput}">
@@ -39,6 +39,7 @@
</h:inputText>
</p:input>
+ <!-- automatically append Ajax behavior -->
<p:input id="name" ajax="true">
<h:inputText id="input" value="#{newUser.name}"/>
</p:input>
Added: examples/trunk/booking-simplified/src/main/webapp/resources/components/model/displayAccount.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/resources/components/model/displayAccount.xhtml (rev 0)
+++ examples/trunk/booking-simplified/src/main/webapp/resources/components/model/displayAccount.xhtml 2010-06-17 21:12:01 UTC (rev 13224)
@@ -0,0 +1,19 @@
+<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:p="http://http://java.sun.com/jsf/composite/components/property"
+ xmlns:cc="http://java.sun.com/jsf/composite">
+
+ <cc:interface>
+ <cc:attribute name="value" required="true"/>
+ <cc:attribute name="showEmail" required="false" default="false"/>
+ </cc:interface>
+
+ <cc:implementation>
+ <p:output label="Full name" value="#{cc.attrs.value.name}"/>
+ <p:output label="Username" value="#{cc.attrs.value.username}"/>
+ <p:output label="Email address" value="#{cc.attrs.value.email}" rendered="#{not cc.attrs.showEmail}"/>
+ </cc:implementation>
+
+</ui:composition>
Added: examples/trunk/booking-simplified/src/main/webapp/resources/components/model/displayHotel.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/resources/components/model/displayHotel.xhtml (rev 0)
+++ examples/trunk/booking-simplified/src/main/webapp/resources/components/model/displayHotel.xhtml 2010-06-17 21:12:01 UTC (rev 13224)
@@ -0,0 +1,29 @@
+<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:p="http://http://java.sun.com/jsf/composite/components/property"
+ xmlns:cc="http://java.sun.com/jsf/composite">
+
+ <cc:interface>
+ <cc:attribute name="value" required="true"/>
+ </cc:interface>
+
+ <cc:implementation>
+ <p:output label="Name" value="#{cc.attrs.value.name}"/>
+ <p:output label="Address" value="#{cc.attrs.value.address}"/>
+ <p:output label="City" value="#{cc.attrs.value.city}"/>
+ <p:output label="State" value="#{cc.attrs.value.state}"/>
+ <p:output label="Zip" value="#{cc.attrs.value.zip}"/>
+ <p:output label="Country" value="#{cc.attrs.value.country}"/>
+ <p:output label="Class" override="true">
+ <h:graphicImage value="/img/#{cc.attrs.value.stars}-star.gif" style="padding-top: 4px;"/>
+ </p:output>
+ <p:output label="Nightly rate" value="#{cc.attrs.value.price}">
+ <f:convertNumber for="output" type="currency" currencySymbol="$"/>
+ </p:output>
+ </cc:implementation>
+
+</ui:composition>
Modified: examples/trunk/booking-simplified/src/main/webapp/resources/components/property/output.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/resources/components/property/output.xhtml 2010-06-17 19:34:31 UTC (rev 13223)
+++ examples/trunk/booking-simplified/src/main/webapp/resources/components/property/output.xhtml 2010-06-17 21:12:01 UTC (rev 13224)
@@ -10,7 +10,7 @@
<cc:interface>
<cc:attribute name="label" required="true"/>
<cc:attribute name="value" required="false"/>
- <cc:attribute name="override" required="false" default="false"/>
+ <cc:attribute name="verbatim" required="false" default="false"/>
</cc:interface>
<cc:implementation>
@@ -18,8 +18,8 @@
<span class="label">#{cc.attrs.label}:</span>
<span class="output">
<c:choose>
- <c:when test="#{cc.attrs.override}"><cc:insertChildren/></c:when>
- <c:otherwise><h:outputText id="output" value="#{cc.attrs.value}"><cc:insertChildren/></h:outputText></c:otherwise>
+ <c:when test="#{cc.attrs.verbatim}"><cc:insertChildren/></c:when>
+ <c:otherwise><h:outputText value="#{cc.attrs.value}"><cc:insertChildren/></h:outputText></c:otherwise>
</c:choose>
</span>
</div>
14 years, 4 months
Seam SVN: r13223 - examples/trunk/booking-simplified/src/main/webapp/WEB-INF.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2010-06-17 15:34:31 -0400 (Thu, 17 Jun 2010)
New Revision: 13223
Modified:
examples/trunk/booking-simplified/src/main/webapp/WEB-INF/beans.xml
Log:
comment
Modified: examples/trunk/booking-simplified/src/main/webapp/WEB-INF/beans.xml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/WEB-INF/beans.xml 2010-06-17 19:33:32 UTC (rev 13222)
+++ examples/trunk/booking-simplified/src/main/webapp/WEB-INF/beans.xml 2010-06-17 19:34:31 UTC (rev 13223)
@@ -11,5 +11,6 @@
<alternatives>
<class>org.jboss.seam.examples.booking.bootstrap.ApplicationInitializer</class>
</alternatives>
- <i18n:DefaultLocaleProducer defaultLocaleKey="de"/>
+ <!-- not being set -->
+ <i18n:DefaultLocaleProducer defaultLocaleKey="en"/>
</beans>
14 years, 4 months
Seam SVN: r13222 - examples/trunk/booking-simplified/src/main/webapp/WEB-INF.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2010-06-17 15:33:32 -0400 (Thu, 17 Jun 2010)
New Revision: 13222
Modified:
examples/trunk/booking-simplified/src/main/webapp/WEB-INF/beans.xml
Log:
set default locale
Modified: examples/trunk/booking-simplified/src/main/webapp/WEB-INF/beans.xml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/WEB-INF/beans.xml 2010-06-17 19:03:11 UTC (rev 13221)
+++ examples/trunk/booking-simplified/src/main/webapp/WEB-INF/beans.xml 2010-06-17 19:33:32 UTC (rev 13222)
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:i18n="urn:java:org.jboss.seam.international.locale"
xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
@@ -10,4 +11,5 @@
<alternatives>
<class>org.jboss.seam.examples.booking.bootstrap.ApplicationInitializer</class>
</alternatives>
+ <i18n:DefaultLocaleProducer defaultLocaleKey="de"/>
</beans>
14 years, 4 months
Seam SVN: r13221 - in examples/trunk/booking-simplified/src/main/java/org/jboss/seam: examples/booking/booking and 2 other directories.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2010-06-17 15:03:11 -0400 (Thu, 17 Jun 2010)
New Revision: 13221
Modified:
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/CurrentPasswordValidator.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ConfirmedLiteral.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationNotifier.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/i18n/DefaultBundleKey.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/faces/status/MessagesAdapter.java
Log:
license headers
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/CurrentPasswordValidator.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/CurrentPasswordValidator.java 2010-06-17 18:58:34 UTC (rev 13220)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/CurrentPasswordValidator.java 2010-06-17 19:03:11 UTC (rev 13221)
@@ -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.enterprise.inject.Instance;
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-17 18:58:34 UTC (rev 13220)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ConfirmedLiteral.java 2010-06-17 19:03:11 UTC (rev 13221)
@@ -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 javax.enterprise.util.AnnotationLiteral;
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationNotifier.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationNotifier.java 2010-06-17 18:58:34 UTC (rev 13220)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationNotifier.java 2010-06-17 19:03:11 UTC (rev 13221)
@@ -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 javax.ejb.ActivationConfigProperty;
@@ -31,4 +52,4 @@
}
}
-}
\ No newline at end of file
+}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/i18n/DefaultBundleKey.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/i18n/DefaultBundleKey.java 2010-06-17 18:58:34 UTC (rev 13220)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/i18n/DefaultBundleKey.java 2010-06-17 19:03:11 UTC (rev 13221)
@@ -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.i18n;
import org.jboss.seam.international.status.builder.BundleKey;
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/faces/status/MessagesAdapter.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/faces/status/MessagesAdapter.java 2010-06-17 18:58:34 UTC (rev 13220)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/faces/status/MessagesAdapter.java 2010-06-17 19:03:11 UTC (rev 13221)
@@ -19,7 +19,6 @@
* 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.status;
import java.io.Serializable;
14 years, 4 months
Seam SVN: r13220 - examples/trunk/booking-simplified.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2010-06-17 14:58:34 -0400 (Thu, 17 Jun 2010)
New Revision: 13220
Modified:
examples/trunk/booking-simplified/pom.xml
Log:
rename context path to booking
Modified: examples/trunk/booking-simplified/pom.xml
===================================================================
--- examples/trunk/booking-simplified/pom.xml 2010-06-17 18:55:44 UTC (rev 13219)
+++ examples/trunk/booking-simplified/pom.xml 2010-06-17 18:58:34 UTC (rev 13220)
@@ -170,7 +170,7 @@
<build>
<defaultGoal>package</defaultGoal>
- <finalName>${project.artifactId}</finalName>
+ <finalName>booking</finalName>
<plugins>
<plugin>
14 years, 4 months
Seam SVN: r13219 - in examples/trunk/booking-simplified: src/main/java/org/jboss/seam/examples/booking and 5 other directories.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2010-06-17 14:55:44 -0400 (Thu, 17 Jun 2010)
New Revision: 13219
Added:
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ConfirmedLiteral.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationNotifier.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/i18n/
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/i18n/DefaultBundleKey.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Credentials.java
Removed:
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/Bundles.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationNotifier.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationNotifierBean.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Credentials.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/MockCredentials.java
Modified:
examples/trunk/booking-simplified/
examples/trunk/booking-simplified/pom.xml
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Authenticated.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/ConfirmPasswordValidator.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/CurrentPasswordValidator.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManager.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Registrar.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgent.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistory.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationDateRangeValidator.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Authenticator.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Identity.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/faces/component/UIInputContainer.java
Log:
switch to DefaultBundleKey
cleanups
Property changes on: examples/trunk/booking-simplified
___________________________________________________________________
Name: svn:ignore
- .settings
.classpath
.project
faces-config.NavData
nbactions*
target
.pom.xml.swp
+ .settings
.classpath
.project
faces-config.NavData
nbactions*
target
Modified: examples/trunk/booking-simplified/pom.xml
===================================================================
--- examples/trunk/booking-simplified/pom.xml 2010-06-17 17:41:30 UTC (rev 13218)
+++ examples/trunk/booking-simplified/pom.xml 2010-06-17 18:55:44 UTC (rev 13219)
@@ -92,6 +92,19 @@
</dependency>
<dependency>
+ <groupId>org.jboss.seam.jms</groupId>
+ <artifactId>seam-jms-api</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.seam.jms</groupId>
+ <artifactId>seam-jms</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
<groupId>com.ocpsoft</groupId>
<artifactId>prettyfaces-jsf2</artifactId>
<version>3.0.1</version>
Deleted: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/Bundles.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/Bundles.java 2010-06-17 17:41:30 UTC (rev 13218)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/Bundles.java 2010-06-17 18:55:44 UTC (rev 13219)
@@ -1,30 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.seam.examples.booking;
-
-/**
- * @author Dan Allen
- */
-public interface Bundles
-{
- static final String MESSAGES = "messages";
-}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Authenticated.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Authenticated.java 2010-06-17 17:41:30 UTC (rev 13218)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Authenticated.java 2010-06-17 18:55:44 UTC (rev 13219)
@@ -28,7 +28,6 @@
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Documented;
-import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/ConfirmPasswordValidator.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/ConfirmPasswordValidator.java 2010-06-17 17:41:30 UTC (rev 13218)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/ConfirmPasswordValidator.java 2010-06-17 18:55:44 UTC (rev 13219)
@@ -30,15 +30,14 @@
import javax.faces.validator.ValidatorException;
import javax.inject.Inject;
-import org.jboss.seam.examples.booking.Bundles;
+import org.jboss.seam.examples.booking.i18n.DefaultBundleKey;
import org.jboss.seam.faces.validation.InputField;
-import org.jboss.seam.international.status.builder.BundleKey;
import org.jboss.seam.international.status.builder.BundleTemplateMessage;
/**
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
*/
-@FacesValidator(value = "confirmPasswordValidator")
+@FacesValidator("confirmPasswordValidator")
public class ConfirmPasswordValidator implements Validator
{
@Inject
@@ -58,7 +57,7 @@
{
throw new ValidatorException(
new FacesMessage(messageBuilder.get().text(
- new BundleKey(Bundles.MESSAGES, "account.passwordsDoNotMatch"))
+ new DefaultBundleKey("account.passwordsDoNotMatch"))
.build().getText()));
}
}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/CurrentPasswordValidator.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/CurrentPasswordValidator.java 2010-06-17 17:41:30 UTC (rev 13218)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/CurrentPasswordValidator.java 2010-06-17 18:55:44 UTC (rev 13219)
@@ -9,15 +9,14 @@
import javax.faces.validator.ValidatorException;
import javax.inject.Inject;
-import org.jboss.seam.examples.booking.Bundles;
+import org.jboss.seam.examples.booking.i18n.DefaultBundleKey;
import org.jboss.seam.examples.booking.model.User;
-import org.jboss.seam.international.status.builder.BundleKey;
import org.jboss.seam.international.status.builder.BundleTemplateMessage;
/**
* @author Dan Allen
*/
-@FacesValidator(value = "currentPasswordValidator")
+@FacesValidator("currentPasswordValidator")
public class CurrentPasswordValidator implements Validator
{
@Inject
@@ -37,7 +36,7 @@
* This is an ugly way to put i18n in FacesMessages: https://jira.jboss.org/browse/SEAMFACES-24
*/
throw new ValidatorException(new FacesMessage(msg.get().text(
- new BundleKey(Bundles.MESSAGES, "account.passwordNotConfirmed")).build()
+ new DefaultBundleKey("account.passwordNotConfirmed")).build()
.getText()));
}
}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManager.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManager.java 2010-06-17 17:41:30 UTC (rev 13218)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManager.java 2010-06-17 18:55:44 UTC (rev 13219)
@@ -22,25 +22,22 @@
package org.jboss.seam.examples.booking.account;
import javax.ejb.Stateful;
-import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Model;
import javax.inject.Inject;
-import javax.inject.Named;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
-import org.jboss.seam.examples.booking.Bundles;
+import org.jboss.seam.examples.booking.i18n.DefaultBundleKey;
import org.jboss.seam.examples.booking.model.User;
import org.jboss.seam.international.status.Messages;
-import org.jboss.seam.international.status.builder.BundleKey;
/**
* @author Dan Allen
*/
-@Named
@Stateful
-@RequestScoped
+@Model
public class PasswordManager
{
@PersistenceContext
@@ -62,7 +59,7 @@
public void changePassword()
{
em.merge(user);
- messages.info(new BundleKey(Bundles.MESSAGES, "account.passwordChanged")).textDefault("Password successfully updated.");
+ messages.info(new DefaultBundleKey("account.passwordChanged")).textDefault("Password successfully updated.");
changed = true;
}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Registrar.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Registrar.java 2010-06-17 17:41:30 UTC (rev 13218)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Registrar.java 2010-06-17 18:55:44 UTC (rev 13219)
@@ -23,6 +23,7 @@
import javax.ejb.Stateful;
import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Model;
import javax.enterprise.inject.Produces;
import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;
@@ -33,7 +34,7 @@
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
-import org.jboss.seam.examples.booking.Bundles;
+import org.jboss.seam.examples.booking.i18n.DefaultBundleKey;
import org.jboss.seam.examples.booking.model.User;
import org.jboss.seam.international.status.Messages;
import org.jboss.seam.international.status.builder.BundleKey;
@@ -41,9 +42,8 @@
/**
* @author Dan Allen
*/
-@Named
@Stateful
-@RequestScoped
+@Model
public class Registrar
{
@PersistenceContext
@@ -74,7 +74,7 @@
registered = true;
em.persist(newUser);
- messages.info(new BundleKey(Bundles.MESSAGES, "registration.registered")).textDefault("You have been successfully registered as the user {0}! You can now login.").textParams(newUser.getUsername());
+ messages.info(new DefaultBundleKey("registration.registered")).textDefault("You have been successfully registered as the user {0}! You can now login.").textParams(newUser.getUsername());
}
else
{
@@ -101,7 +101,7 @@
{
if (facesContext.isValidationFailed() || registrationInvalid)
{
- messages.warn(new BundleKey(Bundles.MESSAGES, "registration.invalid")).textDefault("Invalid registration. Please correct the errors and try again.");
+ messages.warn(new DefaultBundleKey("registration.invalid")).textDefault("Invalid registration. Please correct the errors and try again.");
}
}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgent.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgent.java 2010-06-17 17:41:30 UTC (rev 13218)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgent.java 2010-06-17 18:55:44 UTC (rev 13219)
@@ -36,7 +36,6 @@
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
-import org.jboss.seam.examples.booking.Bundles;
import org.jboss.seam.examples.booking.account.Authenticated;
import org.jboss.seam.examples.booking.model.Booking;
import org.jboss.seam.examples.booking.model.Hotel;
@@ -44,15 +43,18 @@
import org.jboss.seam.faces.context.conversation.Begin;
import org.jboss.seam.faces.context.conversation.End;
import org.jboss.seam.international.status.Messages;
-import org.jboss.seam.international.status.builder.BundleKey;
import org.jboss.seam.international.status.builder.TemplateMessage;
import org.slf4j.Logger;
import com.ocpsoft.pretty.time.PrettyTime;
+import org.jboss.seam.examples.booking.i18n.DefaultBundleKey;
+/**
+ * @author Dan Allen
+ */
+@Named
@Stateful
@ConversationScoped
-@Named
public class BookingAgent
{
@Inject
@@ -101,7 +103,7 @@
// for demo convenience
booking.setCreditCardNumber("1111222233334444");
- messages.info(new BundleKey(Bundles.MESSAGES, "booking.initiated")).textDefault("You've initiated a booking at the {0}.").textParams(booking.getHotel().getName());
+ messages.info(new DefaultBundleKey("booking.initiated")).textDefault("You've initiated a booking at the {0}.").textParams(booking.getHotel().getName());
}
public void validate()
@@ -127,7 +129,7 @@
public void onBookingComplete(@Observes(during = TransactionPhase.AFTER_SUCCESS) @Confirmed final Booking booking)
{
log.info(messageBuilder.get().text("New booking at the {0} confirmed for {1}").textParams(booking.getHotel().getName(), booking.getUser().getName()).build().getText());
- messages.info(new BundleKey(Bundles.MESSAGES, "booking.confirmed")).textDefault("You're booked to stay at the {0} {1}.").textParams(booking.getHotel().getName(), new PrettyTime().format(booking.getCheckinDate()));
+ messages.info(new DefaultBundleKey("booking.confirmed")).textDefault("You're booked to stay at the {0} {1}.").textParams(booking.getHotel().getName(), new PrettyTime().format(booking.getCheckinDate()));
}
@Produces
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistory.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistory.java 2010-06-17 17:41:30 UTC (rev 13218)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistory.java 2010-06-17 18:55:44 UTC (rev 13219)
@@ -40,16 +40,15 @@
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.Root;
-import org.jboss.seam.examples.booking.Bundles;
import org.jboss.seam.examples.booking.account.Authenticated;
+import org.jboss.seam.examples.booking.i18n.DefaultBundleKey;
import org.jboss.seam.examples.booking.model.Booking;
import org.jboss.seam.examples.booking.model.Booking_;
import org.jboss.seam.examples.booking.model.User;
import org.jboss.seam.examples.booking.model.User_;
import org.jboss.seam.examples.booking.security.Identity;
import org.jboss.seam.international.status.Messages;
-import org.jboss.seam.international.status.builder.BundleKey;
import org.slf4j.Logger;
/**
@@ -111,14 +110,14 @@
if (booking != null)
{
em.remove(booking);
- messages.info(new BundleKey(Bundles.MESSAGES, "booking.canceled"))
+ messages.info(new DefaultBundleKey("booking.canceled"))
.textDefault("The booking at the {0} on {1} has been canceled.")
.textParams(selectedBooking.getHotel().getName(),
DateFormat.getDateInstance(SimpleDateFormat.MEDIUM).format(selectedBooking.getCheckinDate()));
}
else
{
- messages.info(new BundleKey(Bundles.MESSAGES, "booking.doesNotExist"))
+ messages.info(new DefaultBundleKey("booking.doesNotExist"))
.textDefault("Our records indicate that the booking you selected has already been canceled.");
}
Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ConfirmedLiteral.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ConfirmedLiteral.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ConfirmedLiteral.java 2010-06-17 18:55:44 UTC (rev 13219)
@@ -0,0 +1,8 @@
+package org.jboss.seam.examples.booking.booking;
+
+import javax.enterprise.util.AnnotationLiteral;
+
+public class ConfirmedLiteral extends AnnotationLiteral<Confirmed> implements Confirmed
+{
+ public static final ConfirmedLiteral INSTANCE = new ConfirmedLiteral();
+}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationDateRangeValidator.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationDateRangeValidator.java 2010-06-17 17:41:30 UTC (rev 13218)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationDateRangeValidator.java 2010-06-17 18:55:44 UTC (rev 13219)
@@ -35,9 +35,8 @@
import javax.faces.validator.ValidatorException;
import javax.inject.Inject;
-import org.jboss.seam.examples.booking.Bundles;
+import org.jboss.seam.examples.booking.i18n.DefaultBundleKey;
import org.jboss.seam.faces.validation.InputField;
-import org.jboss.seam.international.status.builder.BundleKey;
import org.jboss.seam.international.status.builder.BundleTemplateMessage;
/**
@@ -67,14 +66,14 @@
calendar.add(Calendar.DAY_OF_MONTH, -1);
if (beginDate.before(calendar.getTime()))
{
- String message = messageBuilder.get().text(new BundleKey(Bundles.MESSAGES, "booking.checkInNotFutureDate"))
+ String message = messageBuilder.get().text(new DefaultBundleKey("booking.checkInNotFutureDate"))
// FIXME the component should come through via injection
.targets(fieldMap.get("beginDate").getClientId()).build().getText();
throw new ValidatorException(new FacesMessage(message));
}
else if (!beginDate.before(endDate))
{
- String message = messageBuilder.get().text(new BundleKey(Bundles.MESSAGES, "booking.checkOutBeforeCheckIn"))
+ String message = messageBuilder.get().text(new DefaultBundleKey("booking.checkOutBeforeCheckIn"))
// FIXME the component should come through via injection
.targets(fieldMap.get("endDate").getClientId()).build().getText();
throw new ValidatorException(new FacesMessage(message));
Deleted: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationNotifier.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationNotifier.java 2010-06-17 17:41:30 UTC (rev 13218)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationNotifier.java 2010-06-17 18:55:44 UTC (rev 13219)
@@ -1,8 +0,0 @@
-package org.jboss.seam.examples.booking.booking;
-
-import org.jboss.seam.examples.booking.model.Booking;
-
-public interface ReservationNotifier
-{
- void onBookingComplete(Booking booking);
-}
Copied: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationNotifier.java (from rev 13215, examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationNotifierBean.java)
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationNotifier.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationNotifier.java 2010-06-17 18:55:44 UTC (rev 13219)
@@ -0,0 +1,34 @@
+package org.jboss.seam.examples.booking.booking;
+
+import javax.ejb.ActivationConfigProperty;
+import javax.ejb.MessageDriven;
+import javax.inject.Inject;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.ObjectMessage;
+import org.jboss.seam.examples.booking.model.Booking;
+import org.slf4j.Logger;
+
+//@MessageDriven(activationConfig = {
+// @ActivationConfigProperty(propertyName = "destination", propertyValue = "jms/BookingTopic"),
+// @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic")
+//})
+public class ReservationNotifier implements MessageListener
+{
+ @Inject
+ private Logger log;
+
+ public void onMessage(Message message)
+ {
+ try
+ {
+ Booking booking = (Booking) ((ObjectMessage) message).getObject();
+ log.info("In a real-world application, send e-mail containing reservation information to " + booking.getUser().getEmailWithName());
+ } catch (JMSException ex)
+ {
+ log.error("Error reading booking from topic");
+ }
+ }
+
+}
\ No newline at end of file
Deleted: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationNotifierBean.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationNotifierBean.java 2010-06-17 17:41:30 UTC (rev 13218)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationNotifierBean.java 2010-06-17 18:55:44 UTC (rev 13219)
@@ -1,19 +0,0 @@
-package org.jboss.seam.examples.booking.booking;
-
-import javax.enterprise.event.Observes;
-import javax.enterprise.event.TransactionPhase;
-import javax.inject.Inject;
-import org.jboss.seam.examples.booking.model.Booking;
-import org.slf4j.Logger;
-
-public class ReservationNotifierBean implements ReservationNotifier
-{
- @Inject
- private Logger log;
-
- public void onBookingComplete(@Observes(during = TransactionPhase.AFTER_SUCCESS)
- @Confirmed final Booking booking)
- {
- log.info("In a real-world application, send e-mail containing reservation information to " + booking.getUser().getEmailWithName());
- }
-}
\ No newline at end of file
Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/i18n/DefaultBundleKey.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/i18n/DefaultBundleKey.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/i18n/DefaultBundleKey.java 2010-06-17 18:55:44 UTC (rev 13219)
@@ -0,0 +1,16 @@
+package org.jboss.seam.examples.booking.i18n;
+
+import org.jboss.seam.international.status.builder.BundleKey;
+
+/**
+ * @author Dan Allen
+ */
+public class DefaultBundleKey extends BundleKey {
+
+ public static final String DEFAULT_BUNDLE_NAME = "messages";
+
+ public DefaultBundleKey(String key)
+ {
+ super(DEFAULT_BUNDLE_NAME, key);
+ }
+}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Authenticator.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Authenticator.java 2010-06-17 17:41:30 UTC (rev 13218)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Authenticator.java 2010-06-17 18:55:44 UTC (rev 13219)
@@ -27,11 +27,10 @@
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
-import org.jboss.seam.examples.booking.Bundles;
import org.jboss.seam.examples.booking.account.Authenticated;
+import org.jboss.seam.examples.booking.i18n.DefaultBundleKey;
import org.jboss.seam.examples.booking.model.User;
import org.jboss.seam.international.status.Messages;
-import org.jboss.seam.international.status.builder.BundleKey;
import org.slf4j.Logger;
/**
@@ -64,7 +63,7 @@
log.info("Logging in " + credentials.getUsername());
if ((credentials.getUsername() == null) || (credentials.getPassword() == null))
{
- messages.info(new BundleKey(Bundles.MESSAGES, "identity.loginFailed"));
+ messages.info(new DefaultBundleKey("identity.loginFailed"));
return false;
}
@@ -72,12 +71,12 @@
if ((user != null) && user.getPassword().equals(credentials.getPassword()))
{
loginEventSrc.fire(user);
- messages.info(new BundleKey(Bundles.MESSAGES, "identity.loggedIn"), user.getName());
+ messages.info(new DefaultBundleKey("identity.loggedIn"), user.getName());
return true;
}
else
{
- messages.info(new BundleKey(Bundles.MESSAGES, "identity.loginFailed"));
+ messages.info(new DefaultBundleKey("identity.loginFailed"));
return false;
}
}
Deleted: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Credentials.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Credentials.java 2010-06-17 17:41:30 UTC (rev 13218)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Credentials.java 2010-06-17 18:55:44 UTC (rev 13219)
@@ -1,29 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.seam.examples.booking.security;
-
-public interface Credentials {
- String getUsername();
- void setUsername(String username);
- String getPassword();
- void setPassword(String password);
-}
Copied: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Credentials.java (from rev 13218, examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/MockCredentials.java)
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Credentials.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Credentials.java 2010-06-17 18:55:44 UTC (rev 13219)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.examples.booking.security;
+
+import java.io.Serializable;
+
+import javax.enterprise.context.SessionScoped;
+import javax.inject.Named;
+
+/**
+ * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
+ */
+@Named
+@SessionScoped
+public class Credentials implements Serializable
+{
+ private String username;
+ private String password;
+
+ public String getUsername()
+ {
+ return username;
+ }
+
+ public void setUsername(final String username)
+ {
+ this.username = username;
+ }
+
+ public String getPassword()
+ {
+ return password;
+ }
+
+ public void setPassword(final String password)
+ {
+ this.password = password;
+ }
+}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Identity.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Identity.java 2010-06-17 17:41:30 UTC (rev 13218)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Identity.java 2010-06-17 18:55:44 UTC (rev 13219)
@@ -32,7 +32,7 @@
/**
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
*/
-@Named("identity")
+@Named
@SessionScoped
public class Identity implements Serializable
{
Deleted: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/MockCredentials.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/MockCredentials.java 2010-06-17 17:41:30 UTC (rev 13218)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/MockCredentials.java 2010-06-17 18:55:44 UTC (rev 13219)
@@ -1,58 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.seam.examples.booking.security;
-
-import java.io.Serializable;
-
-import javax.enterprise.context.SessionScoped;
-import javax.inject.Named;
-
-/**
- * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
- */
-@Named("credentials")
-@SessionScoped
-public class MockCredentials implements Credentials, Serializable
-{
- private String username;
- private String password;
-
- public String getUsername()
- {
- return username;
- }
-
- public void setUsername(final String username)
- {
- this.username = username;
- }
-
- public String getPassword()
- {
- return password;
- }
-
- public void setPassword(final String password)
- {
- this.password = password;
- }
-}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/faces/component/UIInputContainer.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/faces/component/UIInputContainer.java 2010-06-17 17:41:30 UTC (rev 13218)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/faces/component/UIInputContainer.java 2010-06-17 18:55:44 UTC (rev 13219)
@@ -182,6 +182,17 @@
return "enclose";
}
+ /**
+ * The name of the composite component attribute that indicates whether
+ * the AjaxBehavior should be added to inputs in this container and
+ * which event to fire on. If the value is default, then the default
+ * event for the input component will be used.
+ */
+ public String getAjaxAttributeName()
+ {
+ return "ajax";
+ }
+
public String getContainerElementName()
{
return "div";
@@ -457,7 +468,7 @@
}
}
- public static class InputContainerElements
+ public class InputContainerElements
{
private String containerId;
private Map<String, Object> attributes;
@@ -492,15 +503,20 @@
public void registerInput(final EditableValueHolder input, final Validator validator, final FacesContext context)
{
inputs.add(input);
- if (Boolean.TRUE.equals(attributes.get("ajax")))
+ UIInput inputc = (UIInput) input;
+ String ajaxEvent = (String) attributes.get(getAjaxAttributeName());
+ if (ajaxEvent != null && (ajaxEvent.equalsIgnoreCase("default")))
{
- UIInput inputc = (UIInput) input;
+ ajaxEvent = inputc.getDefaultEventName();
+ }
+ if (ajaxEvent != null)
+ {
Map<String, List<ClientBehavior>> behaviors = inputc.getClientBehaviors();
- if (!behaviors.containsKey("blur"))
+ if (!behaviors.containsKey(ajaxEvent))
{
AjaxBehavior ajax = new AjaxBehavior();
ajax.setRender(Arrays.asList(containerId));
- inputc.addClientBehavior("blur", ajax);
+ inputc.addClientBehavior(ajaxEvent.toLowerCase(), ajax);
}
}
if (input.isRequired() || isRequiredByConstraint(input, validator, context))
14 years, 4 months
Seam SVN: r13218 - in examples/trunk/booking-simplified/src: main/java/org/jboss/seam/examples/booking/booking and 6 other directories.
by seam-commits@lists.jboss.org
Author: lincolnthree
Date: 2010-06-17 13:41:30 -0400 (Thu, 17 Jun 2010)
New Revision: 13218
Added:
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/CurrentPasswordValidator.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManager.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Registrar.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgent.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistory.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/bootstrap/ApplicationInitializer.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/security/Authenticator.java
Removed:
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/ChangePasswordValidator.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/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/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/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/security/Authenticator.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/AuthenticatorBean.java
Modified:
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/ConfirmPasswordValidator.java
examples/trunk/booking-simplified/src/main/webapp/WEB-INF/beans.xml
examples/trunk/booking-simplified/src/main/webapp/password.xhtml
examples/trunk/booking-simplified/src/test/java/org/jboss/seam/examples/booking/booking/BookingAgentTest.java
Log:
Removed @Local interfaces - updated Password Validators
Deleted: 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-17 15:15:54 UTC (rev 13217)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/AccountHolder.java 2010-06-17 17:41:30 UTC (rev 13218)
@@ -1,40 +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.ejb.Local;
-import org.jboss.seam.examples.booking.model.User;
-
-/**
- * The <strong>AccountProducer</strong> produces the object that
- * represents the current user's account information. The account
- * information is represented by the {@link User} entity.
- *
- * @author Dan Allen
- */
-@Local
-public interface AccountHolder
-{
- User getCurrentAccount();
-
- void onLogin(User user);
-}
Copied: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/AccountHolder.java (from rev 13217, 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/AccountHolder.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/AccountHolder.java 2010-06-17 17:41:30 UTC (rev 13218)
@@ -0,0 +1,53 @@
+/*
+ * 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;
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Produces;
+import javax.inject.Named;
+
+import org.jboss.seam.examples.booking.model.User;
+
+/**
+ * @author Dan Allen
+ */
+@Stateful
+@SessionScoped
+public class AccountHolder
+{
+ private User currentUser;
+
+ @Produces
+ @Authenticated
+ @Named("currentUser")
+ public User getCurrentAccount()
+ {
+ return currentUser;
+ }
+
+ public void onLogin(@Observes @Authenticated User user)
+ {
+ currentUser = user;
+ }
+}
Deleted: 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-17 15:15:54 UTC (rev 13217)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/AccountHolderBean.java 2010-06-17 17:41:30 UTC (rev 13218)
@@ -1,53 +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.ejb.Stateful;
-import javax.enterprise.context.SessionScoped;
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.Produces;
-import javax.inject.Named;
-
-import org.jboss.seam.examples.booking.model.User;
-
-/**
- * @author Dan Allen
- */
-@Stateful
-@SessionScoped
-public class AccountHolderBean implements AccountHolder
-{
- private User currentUser;
-
- @Produces
- @Authenticated
- @Named("currentUser")
- public User getCurrentAccount()
- {
- return currentUser;
- }
-
- public void onLogin(@Observes @Authenticated User user)
- {
- currentUser = user;
- }
-}
Deleted: 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 2010-06-17 15:15:54 UTC (rev 13217)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/ChangePasswordValidator.java 2010-06-17 17:41:30 UTC (rev 13218)
@@ -1,56 +0,0 @@
-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;
-
- public void validate(final FacesContext ctx, final UIComponent form, final 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);
- }
-
-}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/ConfirmPasswordValidator.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/ConfirmPasswordValidator.java 2010-06-17 15:15:54 UTC (rev 13217)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/ConfirmPasswordValidator.java 2010-06-17 17:41:30 UTC (rev 13218)
@@ -29,8 +29,8 @@
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;
@@ -54,11 +54,11 @@
public void validate(final FacesContext ctx, final UIComponent c, final Object value) throws ValidatorException
{
- if (newPassword != null && !newPassword.equals(confirmPassword))
+ if ((newPassword != null) && !newPassword.equals(confirmPassword))
{
throw new ValidatorException(
- new FacesMessage(messageBuilder.get().text(
- new BundleKey(Bundles.MESSAGES, "account.passwordsDoNotMatch"))
+ new FacesMessage(messageBuilder.get().text(
+ new BundleKey(Bundles.MESSAGES, "account.passwordsDoNotMatch"))
.build().getText()));
}
}
Copied: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/CurrentPasswordValidator.java (from rev 13217, 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/CurrentPasswordValidator.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/CurrentPasswordValidator.java 2010-06-17 17:41:30 UTC (rev 13218)
@@ -0,0 +1,45 @@
+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.examples.booking.model.User;
+import org.jboss.seam.international.status.builder.BundleKey;
+import org.jboss.seam.international.status.builder.BundleTemplateMessage;
+
+/**
+ * @author Dan Allen
+ */
+@FacesValidator(value = "currentPasswordValidator")
+public class CurrentPasswordValidator implements Validator
+{
+ @Inject
+ private Instance<BundleTemplateMessage> msg;
+
+ @Inject
+ @Authenticated
+ private User currentUser;
+
+ @SuppressWarnings("unchecked")
+ public void validate(final FacesContext ctx, final UIComponent comp, final Object value) throws ValidatorException
+ {
+ String currentPassword = (String) 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(msg.get().text(
+ new BundleKey(Bundles.MESSAGES, "account.passwordNotConfirmed")).build()
+ .getText()));
+ }
+ }
+
+}
Deleted: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManager.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManager.java 2010-06-17 15:15:54 UTC (rev 13217)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManager.java 2010-06-17 17:41:30 UTC (rev 13218)
@@ -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.examples.booking.account;
-
-import javax.ejb.Local;
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Size;
-
-/**
- * @author Dan Allen
- */
-@Local
-public interface PasswordManager
-{
- void changePassword();
-
- boolean isChanged();
-
- void setConfirmPassword(String password);
-
- @NotNull
- @Size(min = 5, max = 15)
- String getConfirmPassword();
-}
Copied: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManager.java (from rev 13217, 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/PasswordManager.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManager.java 2010-06-17 17:41:30 UTC (rev 13218)
@@ -0,0 +1,83 @@
+/*
+ * 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;
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+import org.jboss.seam.examples.booking.Bundles;
+import org.jboss.seam.examples.booking.model.User;
+import org.jboss.seam.international.status.Messages;
+import org.jboss.seam.international.status.builder.BundleKey;
+
+/**
+ * @author Dan Allen
+ */
+@Named
+@Stateful
+@RequestScoped
+public class PasswordManager
+{
+ @PersistenceContext
+ private EntityManager em;
+
+ @Inject
+ private Messages messages;
+
+ @Inject
+ @Authenticated
+ private User user;
+
+ @NotNull
+ @Size(min = 5, max = 15)
+ private String confirmPassword;
+
+ private boolean changed;
+
+ public void changePassword()
+ {
+ em.merge(user);
+ messages.info(new BundleKey(Bundles.MESSAGES, "account.passwordChanged")).textDefault("Password successfully updated.");
+ changed = true;
+ }
+
+ public boolean isChanged()
+ {
+ return changed;
+ }
+
+ public void setConfirmPassword(final String password)
+ {
+ this.confirmPassword = password;
+ }
+
+ public String getConfirmPassword()
+ {
+ return this.confirmPassword;
+ }
+}
Deleted: 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 15:15:54 UTC (rev 13217)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManagerBean.java 2010-06-17 17:41:30 UTC (rev 13218)
@@ -1,80 +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.ejb.Stateful;
-import javax.enterprise.context.RequestScoped;
-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.model.User;
-import org.jboss.seam.international.status.Messages;
-import org.jboss.seam.international.status.builder.BundleKey;
-
-/**
- * @author Dan Allen
- */
-@Named("passwordManager")
-@Stateful
-@RequestScoped
-public class PasswordManagerBean implements PasswordManager
-{
- @PersistenceContext
- private EntityManager em;
-
- @Inject
- private Messages messages;
-
- @Inject
- @Authenticated
- private User user;
-
- private String confirmPassword;
-
- private boolean changed;
-
- public void changePassword()
- {
- em.merge(user);
- messages.info(new BundleKey(Bundles.MESSAGES, "account.passwordChanged"))
- .textDefault("Password successfully updated.");
- changed = true;
- }
-
- public boolean isChanged()
- {
- return changed;
- }
-
- public void setConfirmPassword(final String password)
- {
- this.confirmPassword = password;
- }
-
- public String getConfirmPassword()
- {
- return this.confirmPassword;
- }
-}
Deleted: 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 15:15:54 UTC (rev 13217)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Registrar.java 2010-06-17 17:41:30 UTC (rev 13218)
@@ -1,55 +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.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;
-
-/**
- * @author Dan Allen
- */
-@Local
-public interface Registrar
-{
- void register();
-
- boolean isRegistrationInvalid();
-
- void notifyIfRegistrationIsInvalid();
-
- User getNewUser();
-
- boolean isRegistered();
-
- @NotNull
- @Size(min = 5, max = 15)
- String getConfirmPassword();
-
- void setConfirmPassword(String password);
-
- UIInput getUsernameInput();
-
- void setUsernameInput(UIInput input);
-}
Copied: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Registrar.java (from rev 13217, 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/Registrar.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Registrar.java 2010-06-17 17:41:30 UTC (rev 13218)
@@ -0,0 +1,153 @@
+/*
+ * 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;
+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 javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+import org.jboss.seam.examples.booking.Bundles;
+import org.jboss.seam.examples.booking.model.User;
+import org.jboss.seam.international.status.Messages;
+import org.jboss.seam.international.status.builder.BundleKey;
+
+/**
+ * @author Dan Allen
+ */
+@Named
+@Stateful
+@RequestScoped
+public class Registrar
+{
+ @PersistenceContext
+ private EntityManager em;
+
+ @Inject
+ private Messages messages;
+
+ @Inject
+ private FacesContext facesContext;
+
+ private UIInput usernameInput;
+
+ private final User newUser = new User();
+
+ @NotNull
+ @Size(min = 5, max = 15)
+ private String confirmPassword;
+
+ private boolean registered;
+
+ private boolean registrationInvalid;
+
+ public void register()
+ {
+ 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}! You can now login.").textParams(newUser.getUsername());
+ }
+ else
+ {
+ registrationInvalid = true;
+ }
+ }
+
+ public boolean isRegistrationInvalid()
+ {
+ return registrationInvalid;
+ }
+
+ /**
+ * 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 (facesContext.isValidationFailed() || registrationInvalid)
+ {
+ messages.warn(new BundleKey(Bundles.MESSAGES, "registration.invalid")).textDefault("Invalid registration. Please correct the errors and try again.");
+ }
+ }
+
+ @Produces
+ @RequestScoped
+ @Named
+ public User getNewUser()
+ {
+ return newUser;
+ }
+
+ public boolean isRegistered()
+ {
+ return registered;
+ }
+
+ public String getConfirmPassword()
+ {
+ return confirmPassword;
+ }
+
+ public void setConfirmPassword(final String password)
+ {
+ this.confirmPassword = password;
+ }
+
+ public UIInput getUsernameInput()
+ {
+ return usernameInput;
+ }
+
+ public void setUsernameInput(final UIInput usernameInput)
+ {
+ this.usernameInput = usernameInput;
+ }
+
+ private boolean verifyUsernameIsAvailable()
+ {
+ 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(usernameInput.getClientId()).textParams(newUser.getUsername());
+ return false;
+ }
+
+ return true;
+ }
+
+}
Deleted: 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 15:15:54 UTC (rev 13217)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/RegistrarBean.java 2010-06-17 17:41:30 UTC (rev 13218)
@@ -1,155 +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.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.model.User;
-import org.jboss.seam.international.status.Messages;
-import org.jboss.seam.international.status.builder.BundleKey;
-
-/**
- * @author Dan Allen
- */
-@Stateful
-@RequestScoped
-@Named("registrar")
-public class RegistrarBean implements Registrar
-{
- @PersistenceContext
- private EntityManager em;
-
- @Inject
- private Messages messages;
-
- @Inject
- private FacesContext facesContext;
-
- private UIInput usernameInput;
-
- private final User newUser = new User();
-
- private String confirmPassword;
-
- private boolean registered;
-
- private boolean registrationInvalid;
-
- public void register()
- {
- 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}! You can now login.")
- .textParams(newUser.getUsername());
- }
- else
- {
- registrationInvalid = true;
- }
- }
-
- public boolean isRegistrationInvalid()
- {
- return registrationInvalid;
- }
-
- /**
- * 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 (facesContext.isValidationFailed() || registrationInvalid)
- {
- messages.warn(new BundleKey(Bundles.MESSAGES, "registration.invalid"))
- .textDefault("Invalid registration. Please correct the errors and try again.");
- }
- }
-
- @Produces
- @RequestScoped
- @Named
- public User getNewUser()
- {
- return newUser;
- }
-
- public boolean isRegistered()
- {
- return registered;
- }
-
- public String getConfirmPassword()
- {
- return confirmPassword;
- }
-
- public void setConfirmPassword(final String password)
- {
- this.confirmPassword = password;
- }
-
- public UIInput getUsernameInput()
- {
- return usernameInput;
- }
-
- public void setUsernameInput(UIInput usernameInput)
- {
- this.usernameInput = usernameInput;
- }
-
- private boolean verifyUsernameIsAvailable()
- {
- 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(usernameInput.getClientId())
- .textParams(newUser.getUsername());
- return false;
- }
-
- return true;
- }
-
-}
Deleted: 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 15:15:54 UTC (rev 13217)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgent.java 2010-06-17 17:41:30 UTC (rev 13218)
@@ -1,52 +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.ejb.Local;
-
-import org.jboss.seam.examples.booking.model.Booking;
-import org.jboss.seam.examples.booking.model.Hotel;
-
-/**
- * @author Dan Allen
- */
-@Local
-public interface BookingAgent
-{
- void selectHotel(Long hotelId);
-
- void bookHotel();
-
- void validate();
-
- void cancel();
-
- void confirm();
-
- void onBookingComplete(Booking booking);
-
- Hotel getSelectedHotel();
-
- Booking getBooking();
-
- boolean isBookingValid();
-}
Copied: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgent.java (from rev 13217, 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/BookingAgent.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgent.java 2010-06-17 17:41:30 UTC (rev 13218)
@@ -0,0 +1,153 @@
+/*
+ * 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 static javax.persistence.PersistenceContextType.EXTENDED;
+
+import javax.ejb.Stateful;
+import javax.enterprise.context.ConversationScoped;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.event.Event;
+import javax.enterprise.event.Observes;
+import javax.enterprise.event.TransactionPhase;
+import javax.enterprise.inject.Instance;
+import javax.enterprise.inject.Produces;
+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.account.Authenticated;
+import org.jboss.seam.examples.booking.model.Booking;
+import org.jboss.seam.examples.booking.model.Hotel;
+import org.jboss.seam.examples.booking.model.User;
+import org.jboss.seam.faces.context.conversation.Begin;
+import org.jboss.seam.faces.context.conversation.End;
+import org.jboss.seam.international.status.Messages;
+import org.jboss.seam.international.status.builder.BundleKey;
+import org.jboss.seam.international.status.builder.TemplateMessage;
+import org.slf4j.Logger;
+
+import com.ocpsoft.pretty.time.PrettyTime;
+
+@Stateful
+@ConversationScoped
+@Named
+public class BookingAgent
+{
+ @Inject
+ private Logger log;
+
+ @PersistenceContext(type = EXTENDED)
+ private EntityManager em;
+
+ @Inject
+ private Instance<TemplateMessage> messageBuilder;
+
+ @Inject
+ private Messages messages;
+
+ @Inject
+ @Authenticated
+ private User user;
+
+ @Inject
+ @Confirmed
+ private Event<Booking> bookingConfirmedEventSrc;
+
+ private Hotel hotelSelection;
+
+ private Booking booking;
+
+ private boolean bookingValid;
+
+ @Begin
+ public void selectHotel(final Long id)
+ {
+ // NOTE get a fresh reference that's managed by the extended persistence
+ // context
+ hotelSelection = em.find(Hotel.class, id);
+ if (hotelSelection != null)
+ {
+ 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, 7, 2);
+ hotelSelection = null;
+
+ // 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()
+ {
+ // if we got here, all validations passed
+ bookingValid = true;
+ }
+
+ @End
+ public void confirm()
+ {
+ em.persist(booking);
+ bookingConfirmedEventSrc.fire(booking);
+ }
+
+ @End
+ public void cancel()
+ {
+ booking = null;
+ 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
+ public Booking getBooking()
+ {
+ return booking;
+ }
+
+ @Produces
+ @Named("hotel")
+ @RequestScoped
+ public Hotel getSelectedHotel()
+ {
+ return booking != null ? booking.getHotel() : hotelSelection;
+ }
+
+ public boolean isBookingValid()
+ {
+ return bookingValid;
+ }
+}
Deleted: 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 15:15:54 UTC (rev 13217)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgentBean.java 2010-06-17 17:41:30 UTC (rev 13218)
@@ -1,159 +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 static javax.persistence.PersistenceContextType.EXTENDED;
-
-
-import javax.ejb.Stateful;
-import javax.enterprise.context.ConversationScoped;
-import javax.enterprise.context.RequestScoped;
-import javax.enterprise.inject.Produces;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-
-import org.jboss.seam.examples.booking.account.Authenticated;
-import org.jboss.seam.examples.booking.model.Booking;
-import org.jboss.seam.examples.booking.model.Hotel;
-import org.jboss.seam.examples.booking.model.User;
-import org.jboss.seam.faces.context.conversation.Begin;
-import org.jboss.seam.faces.context.conversation.End;
-import org.jboss.seam.international.status.Messages;
-import org.jboss.seam.international.status.builder.BundleKey;
-import org.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;
-
-@Stateful
-@ConversationScoped
-@Named("bookingAgent")
-public class BookingAgentBean implements BookingAgent
-{
- @Inject
- private Logger log;
-
- @PersistenceContext(type = EXTENDED)
- private EntityManager em;
-
- @Inject
- private Instance<TemplateMessage> messageBuilder;
-
- @Inject
- private Messages messages;
-
- @Inject
- @Authenticated
- private User user;
-
- @Inject @Confirmed
- private Event<Booking> bookingConfirmedEventSrc;
-
- private Hotel hotelSelection;
-
- private Booking booking;
-
- private boolean bookingValid;
-
- @Begin
- public void selectHotel(final Long id)
- {
- // NOTE get a fresh reference that's managed by the extended persistence context
- hotelSelection = em.find(Hotel.class, id);
- if (hotelSelection != null)
- {
- 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, 7, 2);
- hotelSelection = null;
-
- // 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()
- {
- // if we got here, all validations passed
- bookingValid = true;
- }
-
- @End
- public void confirm()
- {
- em.persist(booking);
- bookingConfirmedEventSrc.fire(booking);
- }
-
- @End
- public void cancel()
- {
- booking = null;
- 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
- public Booking getBooking()
- {
- return booking;
- }
-
- @Produces
- @Named("hotel")
- @RequestScoped
- public Hotel getSelectedHotel()
- {
- return booking != null ? booking.getHotel() : hotelSelection;
- }
-
- public boolean isBookingValid()
- {
- return bookingValid;
- }
-}
Deleted: 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 15:15:54 UTC (rev 13217)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistory.java 2010-06-17 17:41:30 UTC (rev 13218)
@@ -1,39 +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 java.util.List;
-import javax.ejb.Local;
-import org.jboss.seam.examples.booking.model.Booking;
-
-/**
- * @author Dan Allen
- */
-@Local
-public interface BookingHistory
-{
- List<Booking> getBookingsForCurrentUser();
-
- void cancelBooking(Booking booking);
-
- void onBookingComplete(Booking booking);
-}
Copied: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistory.java (from rev 13217, 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/BookingHistory.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistory.java 2010-06-17 17:41:30 UTC (rev 13218)
@@ -0,0 +1,142 @@
+/*
+ * 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 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;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.criteria.CriteriaBuilder;
+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;
+import org.jboss.seam.examples.booking.model.Booking_;
+import org.jboss.seam.examples.booking.model.User;
+import org.jboss.seam.examples.booking.model.User_;
+import org.jboss.seam.examples.booking.security.Identity;
+import org.jboss.seam.international.status.Messages;
+import org.jboss.seam.international.status.builder.BundleKey;
+import org.slf4j.Logger;
+
+/**
+ * @author Dan Allen
+ */
+@Named
+@Stateful
+@SessionScoped
+public class BookingHistory
+{
+ @Inject
+ private Logger log;
+
+ @PersistenceContext
+ private EntityManager em;
+
+ @Inject
+ private Messages messages;
+
+ @Inject
+ private Identity identity;
+
+ @Inject @Authenticated
+ private Instance<User> currentUserInstance;
+
+ private List<Booking> bookingsForUser = null;
+
+ @Produces
+ @Authenticated
+ @Named("bookings")
+ public List<Booking> getBookingsForCurrentUser()
+ {
+ if (bookingsForUser == null && identity.isLoggedIn())
+ {
+ fetchBookingsForCurrentUser();
+ }
+ return bookingsForUser;
+ }
+
+ public void onBookingComplete(@Observes(during = TransactionPhase.AFTER_SUCCESS, notifyObserver = Reception.IF_EXISTS)
+ @Confirmed final Booking booking)
+ {
+ // optimization, save the db call
+ if (bookingsForUser != null)
+ {
+ 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)
+ {
+ log.info("Canceling booking {0} for {1}", selectedBooking.getId(), currentUserInstance.get().getName());
+ Booking booking = em.find(Booking.class, selectedBooking.getId());
+ if (booking != null)
+ {
+ em.remove(booking);
+ 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.");
+ }
+
+ bookingsForUser.remove(selectedBooking);
+ }
+
+ private void fetchBookingsForCurrentUser()
+ {
+ String username = currentUserInstance.get().getUsername();
+ CriteriaBuilder builder = em.getCriteriaBuilder();
+ CriteriaQuery<Booking> cquery = builder.createQuery(Booking.class);
+ Root<Booking> booking = cquery.from(Booking.class);
+ booking.fetch(Booking_.hotel, JoinType.INNER);
+ cquery.select(booking)
+ .where(builder.equal(booking.get(Booking_.user).get(User_.username), username))
+ .orderBy(builder.asc(booking.get(Booking_.checkinDate)));
+
+ bookingsForUser = em.createQuery(cquery).getResultList();
+ }
+
+}
Deleted: 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 15:15:54 UTC (rev 13217)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistoryBean.java 2010-06-17 17:41:30 UTC (rev 13218)
@@ -1,142 +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 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;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-import javax.persistence.criteria.CriteriaBuilder;
-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;
-import org.jboss.seam.examples.booking.model.Booking_;
-import org.jboss.seam.examples.booking.model.User;
-import org.jboss.seam.examples.booking.model.User_;
-import org.jboss.seam.examples.booking.security.Identity;
-import org.jboss.seam.international.status.Messages;
-import org.jboss.seam.international.status.builder.BundleKey;
-import org.slf4j.Logger;
-
-/**
- * @author Dan Allen
- */
-@Named("bookingHistory")
-@Stateful
-@SessionScoped
-public class BookingHistoryBean implements BookingHistory
-{
- @Inject
- private Logger log;
-
- @PersistenceContext
- private EntityManager em;
-
- @Inject
- private Messages messages;
-
- @Inject
- private Identity identity;
-
- @Inject @Authenticated
- private Instance<User> currentUserInstance;
-
- private List<Booking> bookingsForUser = null;
-
- @Produces
- @Authenticated
- @Named("bookings")
- public List<Booking> getBookingsForCurrentUser()
- {
- if (bookingsForUser == null && identity.isLoggedIn())
- {
- fetchBookingsForCurrentUser();
- }
- return bookingsForUser;
- }
-
- public void onBookingComplete(@Observes(during = TransactionPhase.AFTER_SUCCESS, notifyObserver = Reception.IF_EXISTS)
- @Confirmed final Booking booking)
- {
- // optimization, save the db call
- if (bookingsForUser != null)
- {
- 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)
- {
- log.info("Canceling booking {0} for {1}", selectedBooking.getId(), currentUserInstance.get().getName());
- Booking booking = em.find(Booking.class, selectedBooking.getId());
- if (booking != null)
- {
- em.remove(booking);
- 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.");
- }
-
- bookingsForUser.remove(selectedBooking);
- }
-
- private void fetchBookingsForCurrentUser()
- {
- String username = currentUserInstance.get().getUsername();
- CriteriaBuilder builder = em.getCriteriaBuilder();
- CriteriaQuery<Booking> cquery = builder.createQuery(Booking.class);
- Root<Booking> booking = cquery.from(Booking.class);
- booking.fetch(Booking_.hotel, JoinType.INNER);
- cquery.select(booking)
- .where(builder.equal(booking.get(Booking_.user).get(User_.username), username))
- .orderBy(builder.asc(booking.get(Booking_.checkinDate)));
-
- bookingsForUser = em.createQuery(cquery).getResultList();
- }
-
-}
Copied: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/bootstrap/ApplicationInitializer.java (from rev 13217, 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/ApplicationInitializer.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/bootstrap/ApplicationInitializer.java 2010-06-17 17:41:30 UTC (rev 13218)
@@ -0,0 +1,126 @@
+/*
+ * 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;
+import java.util.List;
+
+import javax.ejb.Stateless;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Alternative;
+import javax.faces.event.PostConstructApplicationEvent;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.validation.ConstraintViolation;
+import javax.validation.ConstraintViolationException;
+
+import org.jboss.seam.examples.booking.model.Hotel;
+import org.jboss.seam.examples.booking.model.User;
+import org.slf4j.Logger;
+
+/**
+ * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
+ */
+@Stateless
+@Alternative
+public class ApplicationInitializer
+{
+ @PersistenceContext
+ private EntityManager em;
+
+ @Inject
+ Logger log;
+
+ private final List<User> users = new ArrayList<User>();
+ private final List<Hotel> hotels = new ArrayList<Hotel>();
+
+ public ApplicationInitializer()
+ {
+ 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"));
+ hotels.add(new Hotel(289, 4, "W New York - Union Square", "201 Park Avenue South", "New York", "NY", "10003", "USA"));
+ hotels.add(new Hotel(219, 3, "W New York", "541 Lexington Avenue", "New York", "NY", "10022", "USA"));
+ hotels.add(new Hotel(250, 3, "Hotel Rouge", "1315 16th Street NW", "Washington", "DC", "20036", "USA"));
+ hotels.add(new Hotel(159, 4, "70 Park Avenue Hotel", "70 Park Avenue, 38th St", "New York", "NY", "10016", "USA"));
+ hotels.add(new Hotel(198, 4, "Parc 55", "55 Cyril Magnin Street", "San Francisco", "CA", "94102", "USA"));
+ hotels.add(new Hotel(189, 4, "Conrad Miami", "1395 Brickell Ave", "Miami", "FL", "33131", "USA"));
+ hotels.add(new Hotel(111, 4, "Grand Hyatt", "345 Stockton Street", "San Francisco", "CA", "94108", "USA"));
+ hotels.add(new Hotel(54, 1, "Super 8 Eau Claire Campus Area", "1151 W MacArthur Ave", "Eau Claire", "WI", "54701", "USA"));
+ hotels.add(new Hotel(199, 4, "San Francisco Marriott", "55 Fourth Street", "San Francisco", "CA", "94103", "USA"));
+ hotels.add(new Hotel(543, 4, "Hilton Diagonal Mar", "Passeig del Taulat 262-264", "Barcelona", "Catalunya", "08019", "ES"));
+ hotels.add(new Hotel(335, 5, "Hilton Tel Aviv", "Independence Park", "Tel Aviv", null, "63405", "IL"));
+ hotels.add(new Hotel(242, 5, "InterContinental Hotel Tokyo Bay", "1-15-2 Kaigan", "Tokyo", "Minato", "105", "JP"));
+ hotels.add(new Hotel(130, 4, "Hotel Beaulac", " Esplanade Léopold-Robert 2", "Neuchatel", null, "2000", "CH"));
+ hotels.add(new Hotel(266, 5, "Conrad Treasury Place", "130 William Street", "Brisbane", "QL", "4001", "AU"));
+ hotels.add(new Hotel(170, 4, "Ritz-Carlton Montreal", "1228 Sherbrooke St West", "Montreal", "Quebec", "H3G1H6", "CA"));
+ hotels.add(new Hotel(179, 4, "Ritz-Carlton Atlanta", "181 Peachtree St NE", "Atlanta", "GA", "30303", "USA"));
+ hotels.add(new Hotel(145, 4, "Swissotel Sydney", "68 Market Street", "Sydney", "NSW", "2000", "AU"));
+ hotels.add(new Hotel(178, 4, "Meliá White House", "Albany Street Regents Park", "London", null, "NW13UP", "GB"));
+ hotels.add(new Hotel(159, 3, "Hotel Allegro", "171 W Randolph Street", "Chicago", "IL", "60601", "USA"));
+ hotels.add(new Hotel(296, 5, "Caesars Palace", "3570 Las Vegas Blvd S", "Las Vegas", "NV", "89109", "USA"));
+ hotels.add(new Hotel(300, 4, "Mandalay Bay Resort & Casino", "3950 Las Vegas Blvd S", "Las Vegas", "NV", "89119", "USA"));
+ hotels.add(new Hotel(100, 2, "Hotel Cammerpoorte", "Nationalestraat 38-40", "Antwerp", null, "2000", "BE"));
+ }
+
+ public void init(@Observes final PostConstructApplicationEvent event)
+ {
+ try
+ {
+ persist(users);
+ persist(hotels);
+ }
+ catch (Exception e)
+ {
+ log.error("Encountered error seeding the database", e);
+ }
+ }
+
+ private void persist(final List entities)
+ {
+ for (Object e : entities)
+ {
+ persist(e);
+ }
+ }
+
+ private void persist(final Object entity)
+ {
+ try
+ {
+ em.persist(entity);
+ }
+ catch (ConstraintViolationException e)
+ {
+ for (ConstraintViolation v : e.getConstraintViolations())
+ {
+ log.error("Cannot persist entity because it has validation errors " + v.getRootBean() + ": " + v.getPropertyPath() + " " + v.getMessage());
+ }
+ }
+ }
+}
Deleted: 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-17 15:15:54 UTC (rev 13217)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/bootstrap/ApplicationSetup.java 2010-06-17 17:41:30 UTC (rev 13218)
@@ -1,34 +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.bootstrap;
-
-import javax.ejb.Local;
-import javax.faces.event.PostConstructApplicationEvent;
-
-/**
- * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
- */
-@Local
-public interface ApplicationSetup
-{
- public void init(final PostConstructApplicationEvent event);
-}
Deleted: 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 15:15:54 UTC (rev 13217)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/bootstrap/ApplicationSetupBean.java 2010-06-17 17:41:30 UTC (rev 13218)
@@ -1,125 +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.bootstrap;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.ejb.Stateless;
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.Alternative;
-import javax.faces.event.PostConstructApplicationEvent;
-import javax.inject.Inject;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-import javax.validation.ConstraintViolation;
-import javax.validation.ConstraintViolationException;
-
-import org.jboss.seam.examples.booking.model.Hotel;
-import org.jboss.seam.examples.booking.model.User;
-import org.slf4j.Logger;
-
-/**
- * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
- */
-@Stateless
-@Alternative
-public class ApplicationSetupBean implements ApplicationSetup
-{
- @PersistenceContext
- private EntityManager em;
-
- @Inject Logger log;
-
- private final List<User> users = new ArrayList<User>();
- private final List<Hotel> hotels = new ArrayList<Hotel>();
-
- public ApplicationSetupBean()
- {
- users.add(new User("Dan Allen", "dan", "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"));
- hotels.add(new Hotel(289, 4, "W New York - Union Square", "201 Park Avenue South", "New York", "NY", "10003", "USA"));
- hotels.add(new Hotel(219, 3, "W New York", "541 Lexington Avenue", "New York", "NY", "10022", "USA"));
- hotels.add(new Hotel(250, 3, "Hotel Rouge", "1315 16th Street NW", "Washington", "DC", "20036", "USA"));
- hotels.add(new Hotel(159, 4, "70 Park Avenue Hotel", "70 Park Avenue, 38th St", "New York", "NY", "10016", "USA"));
- hotels.add(new Hotel(198, 4, "Parc 55", "55 Cyril Magnin Street", "San Francisco", "CA", "94102", "USA"));
- hotels.add(new Hotel(189, 4, "Conrad Miami", "1395 Brickell Ave", "Miami", "FL", "33131", "USA"));
- hotels.add(new Hotel(111, 4, "Grand Hyatt", "345 Stockton Street", "San Francisco", "CA", "94108", "USA"));
- hotels.add(new Hotel(54, 1, "Super 8 Eau Claire Campus Area", "1151 W MacArthur Ave", "Eau Claire", "WI", "54701", "USA"));
- hotels.add(new Hotel(199, 4, "San Francisco Marriott", "55 Fourth Street", "San Francisco", "CA", "94103", "USA"));
- hotels.add(new Hotel(543, 4, "Hilton Diagonal Mar", "Passeig del Taulat 262-264", "Barcelona", "Catalunya", "08019", "ES"));
- hotels.add(new Hotel(335, 5, "Hilton Tel Aviv", "Independence Park", "Tel Aviv", null, "63405", "IL"));
- hotels.add(new Hotel(242, 5, "InterContinental Hotel Tokyo Bay", "1-15-2 Kaigan", "Tokyo", "Minato", "105", "JP"));
- hotels.add(new Hotel(130, 4, "Hotel Beaulac", " Esplanade Léopold-Robert 2", "Neuchatel", null, "2000", "CH"));
- hotels.add(new Hotel(266, 5, "Conrad Treasury Place", "130 William Street", "Brisbane", "QL", "4001", "AU"));
- hotels.add(new Hotel(170, 4, "Ritz-Carlton Montreal", "1228 Sherbrooke St West", "Montreal", "Quebec", "H3G1H6", "CA"));
- hotels.add(new Hotel(179, 4, "Ritz-Carlton Atlanta", "181 Peachtree St NE", "Atlanta", "GA", "30303", "USA"));
- hotels.add(new Hotel(145, 4, "Swissotel Sydney", "68 Market Street", "Sydney", "NSW", "2000", "AU"));
- hotels.add(new Hotel(178, 4, "Meliá White House", "Albany Street Regents Park", "London", null, "NW13UP", "GB"));
- hotels.add(new Hotel(159, 3, "Hotel Allegro", "171 W Randolph Street", "Chicago", "IL", "60601", "USA"));
- hotels.add(new Hotel(296, 5, "Caesars Palace", "3570 Las Vegas Blvd S", "Las Vegas", "NV", "89109", "USA"));
- hotels.add(new Hotel(300, 4, "Mandalay Bay Resort & Casino", "3950 Las Vegas Blvd S", "Las Vegas", "NV", "89119", "USA"));
- hotels.add(new Hotel(100, 2, "Hotel Cammerpoorte", "Nationalestraat 38-40", "Antwerp", null, "2000", "BE"));
- }
-
- public void init(@Observes final PostConstructApplicationEvent event)
- {
- try {
- persist(users);
- persist(hotels);
- }
- catch (Exception e)
- {
- log.error("Encountered error seeding the database", e);
- }
- }
-
- private void persist(List entities)
- {
- for (Object e : entities)
- {
- persist(e);
- }
- }
-
- private void persist(Object entity)
- {
- try
- {
- em.persist(entity);
- }
- catch (ConstraintViolationException e)
- {
- for (ConstraintViolation v : e.getConstraintViolations())
- {
- log.error("Cannot persist entity because it has validation errors " +
- v.getRootBean() + ": " + v.getPropertyPath() + " " + v.getMessage());
- }
- }
- }
-}
Deleted: 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-17 15:15:54 UTC (rev 13217)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearch.java 2010-06-17 17:41:30 UTC (rev 13218)
@@ -1,42 +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.inventory;
-
-import java.util.List;
-import javax.ejb.Local;
-import org.jboss.seam.examples.booking.model.Hotel;
-
-@Local
-public interface HotelSearch
-{
- void find();
-
- void previousPage();
-
- void nextPage();
-
- List<Hotel> getHotels();
-
- boolean isNextPageAvailable();
-
- boolean isPreviousPageAvailable();
-}
Copied: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearch.java (from rev 13217, 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/HotelSearch.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearch.java 2010-06-17 17:41:30 UTC (rev 13218)
@@ -0,0 +1,122 @@
+/*
+ * 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.inventory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ejb.Stateful;
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.inject.Instance;
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Root;
+
+import org.jboss.seam.examples.booking.model.Hotel;
+import org.jboss.seam.examples.booking.model.Hotel_;
+import org.jboss.seam.international.status.builder.TemplateMessage;
+import org.slf4j.Logger;
+
+@Named
+@Stateful
+@SessionScoped
+public class HotelSearch
+{
+ @Inject
+ private Logger log;
+
+ @PersistenceContext
+ private EntityManager em;
+
+ @Inject
+ private SearchCriteria criteria;
+
+ @Inject
+ private Instance<TemplateMessage> messageBuilder;
+
+ private boolean nextPageAvailable = false;
+
+ private List<Hotel> hotels = new ArrayList<Hotel>();
+
+ public void find()
+ {
+ criteria.firstPage();
+ queryHotels(criteria);
+ }
+
+ public void nextPage()
+ {
+ criteria.nextPage();
+ queryHotels(criteria);
+ }
+
+ public void previousPage()
+ {
+ criteria.previousPage();
+ queryHotels(criteria);
+ }
+
+ @Produces
+ @Named
+ public List<Hotel> getHotels()
+ {
+ return hotels;
+ }
+
+ public boolean isNextPageAvailable()
+ {
+ return nextPageAvailable;
+ }
+
+ public boolean isPreviousPageAvailable()
+ {
+ return criteria.getPage() > 0;
+ }
+
+ private void queryHotels(final SearchCriteria criteria)
+ {
+ CriteriaBuilder builder = em.getCriteriaBuilder();
+ CriteriaQuery<Hotel> cquery = builder.createQuery(Hotel.class);
+ Root<Hotel> hotel = cquery.from(Hotel.class);
+ // QUESTION can like create the pattern for us?
+ cquery.select(hotel).where(builder.or(builder.like(builder.lower(hotel.get(Hotel_.name)), criteria.getSearchPattern()), builder.like(builder.lower(hotel.get(Hotel_.city)), criteria.getSearchPattern()), builder.like(builder.lower(hotel.get(Hotel_.zip)), criteria.getSearchPattern()), builder.like(builder.lower(hotel.get(Hotel_.address)), criteria.getSearchPattern())));
+
+ List<Hotel> results = em.createQuery(cquery).setMaxResults(criteria.getFetchSize()).setFirstResult(criteria.getFetchOffset()).getResultList();
+
+ nextPageAvailable = results.size() > criteria.getPageSize();
+ if (nextPageAvailable)
+ {
+ // NOTE create new ArrayList since subList creates unserializable list
+ hotels = new ArrayList<Hotel>(results.subList(0, criteria.getPageSize()));
+ }
+ else
+ {
+ hotels = results;
+ }
+ log.info(messageBuilder.get().text("Found {0} hotel(s) matching search term [ {1} ] (limit {2})").textParams(hotels.size(), criteria.getQuery(), criteria.getPageSize()).build().getText());
+ }
+}
Deleted: 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 15:15:54 UTC (rev 13217)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearchBean.java 2010-06-17 17:41:30 UTC (rev 13218)
@@ -1,131 +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.inventory;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.ejb.Stateful;
-import javax.enterprise.context.SessionScoped;
-import javax.enterprise.inject.Instance;
-import javax.enterprise.inject.Produces;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaQuery;
-import javax.persistence.criteria.Root;
-
-import org.jboss.seam.examples.booking.model.Hotel;
-import org.jboss.seam.examples.booking.model.Hotel_;
-import org.jboss.seam.international.status.builder.TemplateMessage;
-import org.slf4j.Logger;
-
-@Stateful
-@SessionScoped
-@Named("hotelSearch")
-public class HotelSearchBean implements HotelSearch
-{
- @Inject
- private Logger log;
-
- @PersistenceContext
- private EntityManager em;
-
- @Inject
- private SearchCriteria criteria;
-
- @Inject
- private Instance<TemplateMessage> messageBuilder;
-
- private boolean nextPageAvailable = false;
-
- private List<Hotel> hotels = new ArrayList<Hotel>();
-
- public void find()
- {
- criteria.firstPage();
- queryHotels(criteria);
- }
-
- public void nextPage()
- {
- criteria.nextPage();
- queryHotels(criteria);
- }
-
- public void previousPage()
- {
- criteria.previousPage();
- queryHotels(criteria);
- }
-
- @Produces
- @Named
- public List<Hotel> getHotels()
- {
- return hotels;
- }
-
- public boolean isNextPageAvailable()
- {
- return nextPageAvailable;
- }
-
- public boolean isPreviousPageAvailable()
- {
- return criteria.getPage() > 0;
- }
-
- private void queryHotels(final SearchCriteria criteria)
- {
- CriteriaBuilder builder = em.getCriteriaBuilder();
- CriteriaQuery<Hotel> cquery = builder.createQuery(Hotel.class);
- Root<Hotel> hotel = cquery.from(Hotel.class);
- // QUESTION can like create the pattern for us?
- cquery.select(hotel)
- .where(builder.or(
- builder.like(builder.lower(hotel.get(Hotel_.name)), criteria.getSearchPattern()),
- builder.like(builder.lower(hotel.get(Hotel_.city)), criteria.getSearchPattern()),
- builder.like(builder.lower(hotel.get(Hotel_.zip)), criteria.getSearchPattern()),
- builder.like(builder.lower(hotel.get(Hotel_.address)), criteria.getSearchPattern())));
-
- List<Hotel> results = em.createQuery(cquery)
- .setMaxResults(criteria.getFetchSize())
- .setFirstResult(criteria.getFetchOffset())
- .getResultList();
-
- nextPageAvailable = results.size() > criteria.getPageSize();
- if (nextPageAvailable)
- {
- // NOTE create new ArrayList since subList creates unserializable list
- hotels = new ArrayList<Hotel>(results.subList(0, criteria.getPageSize()));
- }
- else
- {
- hotels = results;
- }
- log.info(messageBuilder.get().text("Found {0} hotel(s) matching search term [ {1} ] (limit {2})")
- .textParams(hotels.size(), criteria.getQuery(), criteria.getPageSize()).build().getText());
- }
-}
Deleted: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Authenticator.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Authenticator.java 2010-06-17 15:15:54 UTC (rev 13217)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Authenticator.java 2010-06-17 17:41:30 UTC (rev 13218)
@@ -1,37 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.seam.examples.booking.security;
-
-import javax.ejb.Local;
-
-/**
- * <strong>Authenticator</strong> is responsible for authenticating the current
- * user. The sole method of this interface, authenticate(), is invoked as a
- * callback method to Seam's security infrastructure during authentication.
- *
- * @author Dan Allen
- */
-@Local
-public interface Authenticator // extends org.jboss.seam.security.Authenticator
-{
- public boolean authenticate();
-}
Copied: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Authenticator.java (from rev 13217, 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/Authenticator.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Authenticator.java 2010-06-17 17:41:30 UTC (rev 13218)
@@ -0,0 +1,85 @@
+/*
+ * 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;
+import javax.enterprise.event.Event;
+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;
+import org.jboss.seam.international.status.Messages;
+import org.jboss.seam.international.status.builder.BundleKey;
+import org.slf4j.Logger;
+
+/**
+ * This implementation of <strong>Authenticator</strong> cross references the
+ * values of the user's credentials against the database.
+ *
+ * @author Dan Allen
+ */
+@Stateless
+public class Authenticator
+{
+ @Inject
+ private Logger log;
+
+ @PersistenceContext
+ private EntityManager em;
+
+ @Inject
+ private Messages messages;
+
+ @Inject
+ private Credentials credentials;
+
+ @Inject
+ @Authenticated
+ private Event<User> loginEventSrc;
+
+ public boolean authenticate()
+ {
+ log.info("Logging in " + credentials.getUsername());
+ if ((credentials.getUsername() == null) || (credentials.getPassword() == null))
+ {
+ messages.info(new BundleKey(Bundles.MESSAGES, "identity.loginFailed"));
+ return false;
+ }
+
+ User user = em.find(User.class, credentials.getUsername());
+ if ((user != null) && user.getPassword().equals(credentials.getPassword()))
+ {
+ loginEventSrc.fire(user);
+ messages.info(new BundleKey(Bundles.MESSAGES, "identity.loggedIn"), user.getName());
+ return true;
+ }
+ else
+ {
+ messages.info(new BundleKey(Bundles.MESSAGES, "identity.loginFailed"));
+ return false;
+ }
+ }
+
+}
Deleted: 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-17 15:15:54 UTC (rev 13217)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/AuthenticatorBean.java 2010-06-17 17:41:30 UTC (rev 13218)
@@ -1,85 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.seam.examples.booking.security;
-
-import javax.ejb.Stateless;
-import javax.enterprise.event.Event;
-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;
-import org.jboss.seam.international.status.Messages;
-import org.jboss.seam.international.status.builder.BundleKey;
-import org.slf4j.Logger;
-
-/**
- * This implementation of <strong>Authenticator</strong> cross references the
- * values of the user's credentials against the database.
- *
- * @author Dan Allen
- */
-@Stateless
-public class AuthenticatorBean implements Authenticator
-{
- @Inject
- private Logger log;
-
- @PersistenceContext
- private EntityManager em;
-
- @Inject
- private Messages messages;
-
- @Inject
- private Credentials credentials;
-
- @Inject
- @Authenticated
- private Event<User> loginEventSrc;
-
- public boolean authenticate()
- {
- log.info("Logging in " + credentials.getUsername());
- if ((credentials.getUsername() == null) || (credentials.getPassword() == null))
- {
- messages.info(new BundleKey(Bundles.MESSAGES, "identity.loginFailed"));
- return false;
- }
-
- User user = em.find(User.class, credentials.getUsername());
- if ((user != null) && user.getPassword().equals(credentials.getPassword()))
- {
- loginEventSrc.fire(user);
- messages.info(new BundleKey(Bundles.MESSAGES, "identity.loggedIn"), user.getName());
- return true;
- }
- else
- {
- messages.info(new BundleKey(Bundles.MESSAGES, "identity.loginFailed"));
- return false;
- }
- }
-
-}
Modified: examples/trunk/booking-simplified/src/main/webapp/WEB-INF/beans.xml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/WEB-INF/beans.xml 2010-06-17 15:15:54 UTC (rev 13217)
+++ examples/trunk/booking-simplified/src/main/webapp/WEB-INF/beans.xml 2010-06-17 17:41:30 UTC (rev 13218)
@@ -8,6 +8,6 @@
<class>org.jboss.seam.faces.context.conversation.ConversationBoundaryInterceptor</class>
</interceptors>
<alternatives>
- <class>org.jboss.seam.examples.booking.bootstrap.ApplicationSetupBean</class>
+ <class>org.jboss.seam.examples.booking.bootstrap.ApplicationInitializer</class>
</alternatives>
</beans>
Modified: examples/trunk/booking-simplified/src/main/webapp/password.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/password.xhtml 2010-06-17 15:15:54 UTC (rev 13217)
+++ examples/trunk/booking-simplified/src/main/webapp/password.xhtml 2010-06-17 17:41:30 UTC (rev 13218)
@@ -25,7 +25,9 @@
<fieldset>
<p:input id="current">
- <h:inputSecret id="password" value="#{currentUser.password}"/>
+ <h:inputSecret id="password" value="#{currentUser.password}">
+ <f:validator validatorId="currentPasswordValidator" />
+ </h:inputSecret>
</p:input>
<p:input id="new">
@@ -44,8 +46,6 @@
</fieldset>
- <s:validateForm validatorId="changePasswordValidator"
- fields="currentPassword=current:password"/>
<s:validateForm validatorId="confirmPasswordValidator"
fields="newPassword=new:password confirmPassword=confirm:password"/>
</h:form>
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 15:15:54 UTC (rev 13217)
+++ examples/trunk/booking-simplified/src/test/java/org/jboss/seam/examples/booking/booking/BookingAgentTest.java 2010-06-17 17:41:30 UTC (rev 13218)
@@ -38,7 +38,7 @@
{
WebArchive war = ShrinkWrap.create("test.war", WebArchive.class)
.addPackage(Hotel.class.getPackage())
- .addClasses(BookingAgent.class, BookingAgentBean.class, Confirmed.class,
+ .addClasses(BookingAgent.class, BookingAgent.class, Confirmed.class,
Authenticated.class, NoOpLogger.class)
.addLibraries(
MavenArtifactResolver.resolve("joda-time:joda-time:1.6"),
14 years, 4 months
Seam SVN: r13217 - in examples/trunk/booking-simplified/src/main/java/org/jboss/seam/faces: status and 1 other directory.
by seam-commits@lists.jboss.org
Author: lincolnthree
Date: 2010-06-17 11:15:54 -0400 (Thu, 17 Jun 2010)
New Revision: 13217
Added:
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/faces/status/
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/faces/status/MessagesAdapter.java
Log:
FlashScope MessagesAdapter patch
Added: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/faces/status/MessagesAdapter.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/faces/status/MessagesAdapter.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/faces/status/MessagesAdapter.java 2010-06-17 15:15:54 UTC (rev 13217)
@@ -0,0 +1,111 @@
+/*
+ * 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.status;
+
+import java.io.Serializable;
+import java.util.Set;
+
+import javax.enterprise.event.Observes;
+import javax.faces.application.FacesMessage;
+import javax.faces.application.FacesMessage.Severity;
+import javax.faces.event.PhaseEvent;
+import javax.inject.Inject;
+
+import org.jboss.seam.faces.context.FlashContext;
+import org.jboss.seam.faces.event.PreNavigateEvent;
+import org.jboss.seam.faces.event.qualifier.Before;
+import org.jboss.seam.faces.event.qualifier.RenderResponse;
+import org.jboss.seam.international.status.Level;
+import org.jboss.seam.international.status.Message;
+import org.jboss.seam.international.status.Messages;
+
+/**
+ * Convert Seam Messages into FacesMessages before RenderResponse phase.<br>
+ * TODO perform EL evaluation.
+ *
+ * @author <a href="mailto:lincolnbaxter@gmail.com>Lincoln Baxter, III</a>
+ *
+ */
+public class MessagesAdapter implements Serializable
+{
+ private static final long serialVersionUID = -2908193057765795662L;
+
+ private static final String FLASH_MESSAGES_KEY = MessagesAdapter.class.getName() + ".FLASH_KEY";
+
+ @Inject
+ Messages messages;
+
+ @Inject
+ FlashContext context;
+
+ void flushBeforeNavigate(@Observes final PreNavigateEvent event)
+ {
+ if (!messages.getAll().isEmpty())
+ {
+ context.put(FLASH_MESSAGES_KEY, messages.getAll());
+ messages.clear();
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ void convert(@Observes @Before @RenderResponse final PhaseEvent event)
+ {
+ Set<Message> savedMessages = (Set<Message>) context.get(FLASH_MESSAGES_KEY);
+ if (savedMessages != null)
+ {
+ for (Message m : savedMessages)
+ {
+ event.getFacesContext().addMessage(m.getTargets(), new FacesMessage(getSeverity(m.getLevel()), m.getText(), null));
+ }
+ }
+
+ for (Message m : messages.getAll())
+ {
+ event.getFacesContext().addMessage(m.getTargets(), new FacesMessage(getSeverity(m.getLevel()), m.getText(), null));
+ }
+ messages.clear();
+ }
+
+ private Severity getSeverity(final Level level)
+ {
+ Severity result = FacesMessage.SEVERITY_INFO;
+ switch (level)
+ {
+ case INFO:
+ break;
+ case WARN:
+ result = FacesMessage.SEVERITY_WARN;
+ break;
+ case ERROR:
+ result = FacesMessage.SEVERITY_ERROR;
+ break;
+ case FATAL:
+ result = FacesMessage.SEVERITY_FATAL;
+ break;
+ default:
+ break;
+ }
+ return result;
+ }
+
+}
14 years, 4 months
Seam SVN: r13216 - in examples/trunk/booking-simplified/src/main: java/org/jboss/seam/examples/booking/booking and 2 other directories.
by seam-commits@lists.jboss.org
Author: lincolnthree
Date: 2010-06-17 11:03:25 -0400 (Thu, 17 Jun 2010)
New Revision: 13216
Added:
examples/trunk/booking-simplified/src/main/resources/messages_de.properties
Modified:
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/booking/ReservationDateRangeValidator.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Identity.java
Log:
Modified: 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 2010-06-17 14:24:11 UTC (rev 13215)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/ChangePasswordValidator.java 2010-06-17 15:03:25 UTC (rev 13216)
@@ -1,6 +1,7 @@
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;
@@ -10,6 +11,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;
@@ -21,8 +23,8 @@
*/
@FacesValidator(value = "changePasswordValidator")
public class ChangePasswordValidator implements Validator
- // extending throws an unsatisified dependency exception
- //extends ConfirmPasswordValidator
+// extending throws an unsatisified dependency exception
+// extends ConfirmPasswordValidator
{
@Inject
private Instance<BundleTemplateMessage> messageBuilder;
@@ -35,25 +37,20 @@
@InputField
private String currentPassword;
- @Override
- public void validate(FacesContext ctx, UIComponent form, Object value) throws ValidatorException
+ public void validate(final FacesContext ctx, final UIComponent form, final Object value) throws ValidatorException
{
Map<String, UIInput> fieldMap = (Map<String, UIInput>) value;
- if (currentUser.getPassword() != null && !currentUser.getPassword().equals(currentPassword))
+ 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()));
+ 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);
+ // super.validate(ctx, form, value);
}
}
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 14:24:11 UTC (rev 13215)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/ReservationDateRangeValidator.java 2010-06-17 15:03:25 UTC (rev 13216)
@@ -24,6 +24,7 @@
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;
@@ -33,15 +34,16 @@
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;
/**
- * A cross-field validator that validates the begin date
- * is in the future and before the end date.
- *
+ * A cross-field validator that validates the begin date is in the future and
+ * before the end date.
+ *
* @author Dan Allen
*/
@FacesValidator("reservationDateRangeValidator")
@@ -58,8 +60,7 @@
@Inject
private Instance<BundleTemplateMessage> messageBuilder;
- @Override
- public void validate(FacesContext ctx, UIComponent form, Object value) throws ValidatorException
+ public void validate(final FacesContext ctx, final UIComponent form, final Object value) throws ValidatorException
{
Map<String, UIInput> fieldMap = (Map<String, UIInput>) value;
Calendar calendar = Calendar.getInstance();
@@ -67,17 +68,15 @@
if (beginDate.before(calendar.getTime()))
{
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();
+ // FIXME the component should come through via injection
+ .targets(fieldMap.get("beginDate").getClientId()).build().getText();
throw new ValidatorException(new FacesMessage(message));
}
else if (!beginDate.before(endDate))
{
String message = messageBuilder.get().text(new BundleKey(Bundles.MESSAGES, "booking.checkOutBeforeCheckIn"))
- // FIXME the component should come through via injection
- .targets(fieldMap.get("endDate").getClientId())
- .build().getText();
+ // FIXME the component should come through via injection
+ .targets(fieldMap.get("endDate").getClientId()).build().getText();
throw new ValidatorException(new FacesMessage(message));
}
}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Identity.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Identity.java 2010-06-17 14:24:11 UTC (rev 13215)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Identity.java 2010-06-17 15:03:25 UTC (rev 13216)
@@ -71,7 +71,7 @@
loggedIn = false;
HttpSession session = (HttpSession) facesContext.getExternalContext().getSession(true);
session.invalidate();
- return "pretty:home";
+ return "home?faces-redirect=true";
}
}
Added: examples/trunk/booking-simplified/src/main/resources/messages_de.properties
===================================================================
--- examples/trunk/booking-simplified/src/main/resources/messages_de.properties (rev 0)
+++ examples/trunk/booking-simplified/src/main/resources/messages_de.properties 2010-06-17 15:03:25 UTC (rev 13216)
@@ -0,0 +1,15 @@
+booking.initiated=Sie haben eine Buchung auf leitete die {0}.
+booking.checkInNotFutureDate=Check-in Datum muss in der Zukunft liegen.
+booking.checkOutBeforeCheckIn=Abreisedatum muss nach dem Check-in Datum sein.
+booking.confirmed=Du bist gebucht, um zu bleiben {0} {1}.
+booking.canceled=Ihre Buchung auf dem {0} auf {1} wurde abgebrochen.
+booking.doesNotExist=Unsere Aufzeichnungen zeigen, dass die Buchung Sie wurde bereits abgesagt ausgew�hlt.
+account.passwordChanged=Passwort erfolgreich aktualisiert.
+account.passwordNotConfirmed=Ihr aktuelles Passwort ung�ltig sei. Bitte versuchen Sie es erneut.
+account.passwordsDoNotMatch=Passw�rter stimmen nicht �berein. Bitte wiederholen Sie das neue Kennwort.
+account.usernameTaken=Der Benutzername '{0}' ist bereits vergeben. Bitte w�hlen Sie einen anderen Benutzernamen.
+registration.registered=Sie haben sich erfolgreich als Benutzer {0} registriert! Sie k�nnen sich jetzt anmelden.
+registration.invalid=Ung�ltige Anmeldung. Bitte korrigieren Sie den Fehler und versuchen Sie es erneut.
+identity.loggedOut=Sie erfolgreich Ihre Sitzung beendet haben.
+identity.loggedIn=Du bist angemeldet als unterzeichneten {0}.
+identity.loginFailed=Ung�ltiger Benutzername oder Kennwort.
\ No newline at end of file
14 years, 4 months
Seam SVN: r13215 - examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2010-06-17 10:24:11 -0400 (Thu, 17 Jun 2010)
New Revision: 13215
Modified:
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/CalendarReferenceProducer.java
Log:
add locale back in
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-17 14:10:52 UTC (rev 13214)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/reference/CalendarReferenceProducer.java 2010-06-17 14:24:11 UTC (rev 13215)
@@ -26,6 +26,7 @@
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
+import java.util.Locale;
import javax.enterprise.context.ConversationScoped;
import javax.inject.Named;
@@ -42,11 +43,11 @@
@Produces
@Named
@ConversationScoped
- public List<Month> getMonths()
+ public List<Month> getMonths(Locale locale)
{
List<Month> months = new ArrayList<Month>(12);
- DateFormat longNameFormat = new SimpleDateFormat("MMMM");
- DateFormat shortNameFormat = new SimpleDateFormat("MMM");
+ DateFormat longNameFormat = new SimpleDateFormat("MMMM", locale);
+ DateFormat shortNameFormat = new SimpleDateFormat("MMM", locale);
Calendar cal = Calendar.getInstance();
for (int m = 0; m < 12; m++)
{
14 years, 4 months