[seam-commits] Seam SVN: r13173 - in examples/trunk/booking-simplified: src/main/java/org/jboss/seam/examples/booking and 12 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Tue Jun 15 20:56:37 EDT 2010
Author: dan.j.allen
Date: 2010-06-15 20:56:36 -0400 (Tue, 15 Jun 2010)
New Revision: 13173
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/AccountHolderBean.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Authenticated.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/bootstrap/
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/security/Credentials.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Identity.java
examples/trunk/booking-simplified/src/main/webapp/resources/components/property/input.xhtml
examples/trunk/booking-simplified/src/main/webapp/resources/components/property/output.xhtml
Removed:
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/AccountProducer.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/AccountProducerBean.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Registered.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/MockIdentity.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/setup/
examples/trunk/booking-simplified/src/main/webapp/resources/components/property/display.xhtml
examples/trunk/booking-simplified/src/main/webapp/resources/components/property/edit.xhtml
Modified:
examples/trunk/booking-simplified/
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/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/inventory/HotelSearchBean.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/Booking.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/User.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Authenticator.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/AuthenticatorBean.java
examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/MockCredentials.java
examples/trunk/booking-simplified/src/main/resources/META-INF/persistence.xml
examples/trunk/booking-simplified/src/main/webapp/WEB-INF/beans.xml
examples/trunk/booking-simplified/src/main/webapp/WEB-INF/fragments/account.xhtml
examples/trunk/booking-simplified/src/main/webapp/WEB-INF/fragments/hotel.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/search.xhtml
examples/trunk/booking-simplified/src/test/java/org/jboss/seam/examples/booking/booking/BookingAgentTest.java
Log:
change currentUser to dependent-scoped producer
use critiera query for history
use UIInputContainer
renames
Property changes on: examples/trunk/booking-simplified
___________________________________________________________________
Name: svn:ignore
- .settings
.classpath
.project
faces-config.NavData
nbactions*
target
+ .settings
.classpath
.project
faces-config.NavData
nbactions*
target
Copied: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/AccountHolder.java (from rev 13171, examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/AccountProducer.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-16 00:56:36 UTC (rev 13173)
@@ -0,0 +1,19 @@
+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
+ */
+ at Local
+public interface AccountHolder
+{
+ User getCurrentAccount();
+
+ void onLogin(User user);
+}
Copied: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/AccountHolderBean.java (from rev 13171, examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/AccountProducerBean.java)
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/AccountHolderBean.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/AccountHolderBean.java 2010-06-16 00:56:36 UTC (rev 13173)
@@ -0,0 +1,38 @@
+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.enterprise.inject.Typed;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.jboss.seam.examples.booking.model.User;
+import org.slf4j.Logger;
+
+/**
+ * @author Dan Allen
+ */
+ at Stateful
+ at SessionScoped
+public class AccountHolderBean implements AccountHolder
+{
+ @Inject
+ private Logger log;
+
+ 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/AccountProducer.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/AccountProducer.java 2010-06-16 00:39:22 UTC (rev 13172)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/AccountProducer.java 2010-06-16 00:56:36 UTC (rev 13173)
@@ -1,17 +0,0 @@
-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
- */
- at Local
-public interface AccountProducer
-{
- User getCurrentAccount();
-}
Deleted: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/AccountProducerBean.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/AccountProducerBean.java 2010-06-16 00:39:22 UTC (rev 13172)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/AccountProducerBean.java 2010-06-16 00:56:36 UTC (rev 13173)
@@ -1,43 +0,0 @@
-package org.jboss.seam.examples.booking.account;
-
-import javax.ejb.Stateless;
-import javax.enterprise.context.SessionScoped;
-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.model.User;
-import org.jboss.seam.examples.booking.security.MockCredentials;
-import org.slf4j.Logger;
-
-/**
- * @author Dan Allen
- */
- at Stateless
-public class AccountProducerBean implements AccountProducer
-{
- @Inject
- private Logger log;
-
- @PersistenceContext
- private EntityManager em;
-
- @Inject
- MockCredentials credentials;
-
- @Produces
- @Registered
- @Named("currentUser")
- @SessionScoped
- public User getCurrentAccount()
- {
- User result = em.find(User.class, credentials.getUsername());
- if (result == null)
- {
- result = new User();
- }
- return result;
- }
-}
Copied: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Authenticated.java (from rev 13171, examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Registered.java)
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Authenticated.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Authenticated.java 2010-06-16 00:56:36 UTC (rev 13173)
@@ -0,0 +1,31 @@
+package org.jboss.seam.examples.booking.account;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+import org.jboss.seam.examples.booking.model.User;
+
+/**
+ * A binding type representing something that is registererd.
+ * In this simple application the only thing that can be
+ * registered is a {@link User}.
+ *
+ * @author Dan Allen
+ */
+ at Target({TYPE, METHOD, PARAMETER, FIELD})
+ at Retention(RUNTIME)
+ at Documented
+ at Qualifier
+public @interface Authenticated
+{
+}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManager.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManager.java 2010-06-16 00:39:22 UTC (rev 13172)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManager.java 2010-06-16 00:56:36 UTC (rev 13173)
@@ -20,6 +20,4 @@
@NotNull
@Size(min = 5, max = 15)
String getConfirmPassword();
-
- void destroy();
}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManagerBean.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManagerBean.java 2010-06-16 00:39:22 UTC (rev 13172)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/PasswordManagerBean.java 2010-06-16 00:56:36 UTC (rev 13173)
@@ -1,6 +1,5 @@
package org.jboss.seam.examples.booking.account;
-import javax.annotation.PreDestroy;
import javax.ejb.Stateful;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
@@ -31,7 +30,7 @@
private RegistrationFormControls formControls;
@Inject
- @Registered
+ @Authenticated
private User user;
private String confirmPassword;
@@ -42,15 +41,13 @@
{
if (user.getPassword().equals(confirmPassword))
{
- // FIXME: dirty hack, can't merge a managed bean
- em.merge(new User(user.getName(), user.getUsername(), user.getPassword()));
- user.setPassword(null);
+ em.merge(user);
messages.info(new BundleKey("messages.properties", "account.passwordChanged")).textDefault("Password successfully updated.");
changed = true;
}
else
{
- // FIME reverting isn't going to work here
+ // FIXME reverting isn't going to work here
// revertUser();
confirmPassword = null;
messages.error(new BundleKey("messages.properties", "account.passwordsDoNotMatch")).textDefault("Passwords do not match. Please re-type the new password.");
@@ -71,9 +68,4 @@
{
return this.confirmPassword;
}
-
- @PreDestroy
- public void destroy()
- {
- }
}
Deleted: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Registered.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Registered.java 2010-06-16 00:39:22 UTC (rev 13172)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Registered.java 2010-06-16 00:56:36 UTC (rev 13173)
@@ -1,31 +0,0 @@
-package org.jboss.seam.examples.booking.account;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import javax.inject.Qualifier;
-
-import org.jboss.seam.examples.booking.model.User;
-
-/**
- * A binding type representing something that is registererd.
- * In this simple application the only thing that can be
- * registered is a {@link User}.
- *
- * @author Dan Allen
- */
- at Target({TYPE, METHOD, PARAMETER, FIELD})
- at Retention(RUNTIME)
- at Documented
- at Qualifier
-public @interface Registered
-{
-}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Registrar.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Registrar.java 2010-06-16 00:39:22 UTC (rev 13172)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/Registrar.java 2010-06-16 00:56:36 UTC (rev 13173)
@@ -26,6 +26,4 @@
String getConfirmPassword();
void setConfirmPassword(String password);
-
- void destroy();
}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/RegistrarBean.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/RegistrarBean.java 2010-06-16 00:39:22 UTC (rev 13172)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/account/RegistrarBean.java 2010-06-16 00:56:36 UTC (rev 13173)
@@ -1,6 +1,5 @@
package org.jboss.seam.examples.booking.account;
-import javax.annotation.PreDestroy;
import javax.ejb.Stateful;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.inject.Produces;
@@ -117,9 +116,4 @@
return true;
}
-
- @PreDestroy
- public void destroy()
- {
- }
}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgentBean.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgentBean.java 2010-06-16 00:39:22 UTC (rev 13172)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgentBean.java 2010-06-16 00:56:36 UTC (rev 13173)
@@ -37,7 +37,7 @@
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
-import org.jboss.seam.examples.booking.account.Registered;
+import org.jboss.seam.examples.booking.account.Authenticated;
import org.jboss.seam.examples.booking.controls.BookingFormControls;
import org.jboss.seam.examples.booking.model.Booking;
import org.jboss.seam.examples.booking.model.Hotel;
@@ -60,9 +60,6 @@
@PersistenceContext(type = EXTENDED)
private EntityManager em;
- // @Inject
- // private Conversation conversation;
-
@Inject
private MessageFactory mf;
@@ -73,7 +70,7 @@
private BookingFormControls formControls;
@Inject
- @Registered
+ @Authenticated
private User user;
// @Inject @Fires @Confirmed Event<BookingEvent> bookingConfirmedEvent;
@@ -91,12 +88,11 @@
{
// NOTE get a fresh reference that's managed by the conversational
// persistence context
- if (id != null)
+ hotelSelection = em.find(Hotel.class, id);
+ if (hotelSelection != null)
{
- hotelSelection = em.find(Hotel.class, id);
log.info(mf.info("Selected the {0} in {1}").textParams(hotelSelection.getName(), hotelSelection.getCity()).build().getText());
}
- // conversation.begin();
}
public void bookHotel()
@@ -139,7 +135,6 @@
manager.fireEvent(new BookingEvent(booking), ConfirmedLiteral.INSTANCE);
log.info(mf.info("New booking at the {0} confirmed for {1}").textParams(booking.getHotel().getName(), booking.getUser().getName()).build().getText());
messages.info(new BundleKey("messages.properties", "booking.confirmed")).textDefault("Booking confirmed.");
- // conversation.end();
}
@End
@@ -147,7 +142,6 @@
{
booking = null;
hotelSelection = null;
- // conversation.end();
}
@Produces
@@ -163,12 +157,7 @@
@RequestScoped
public Hotel getHotelSelection()
{
- Hotel hotel = booking != null ? booking.getHotel() : hotelSelection;
- if (hotel == null)
- {
- hotel = new Hotel();
- }
- return hotel;
+ return booking != null ? booking.getHotel() : hotelSelection;
}
public boolean isBookingValid()
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistory.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistory.java 2010-06-16 00:39:22 UTC (rev 13172)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistory.java 2010-06-16 00:56:36 UTC (rev 13173)
@@ -7,13 +7,12 @@
/**
* @author Dan Allen
*/
+ at Local
public interface BookingHistory
{
List<Booking> getBookingsForCurrentUser();
void cancelBooking(Booking booking);
- void destroy();
-
void afterBookingConfirmed(BookingEvent bookingEvent);
}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistoryBean.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistoryBean.java 2010-06-16 00:39:22 UTC (rev 13172)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/booking/BookingHistoryBean.java 2010-06-16 00:56:36 UTC (rev 13173)
@@ -23,22 +23,28 @@
*/
package org.jboss.seam.examples.booking.booking;
-import java.util.ArrayList;
import java.util.List;
-import javax.annotation.PreDestroy;
import javax.ejb.Stateful;
import javax.enterprise.context.SessionScoped;
import javax.enterprise.event.Observes;
+import javax.enterprise.event.TransactionPhase;
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.account.AccountHolder;
-import org.jboss.seam.examples.booking.account.Registered;
+import org.jboss.seam.examples.booking.account.Authenticated;
import org.jboss.seam.examples.booking.model.Booking;
-import org.jboss.seam.examples.booking.model.User;
+import org.jboss.seam.examples.booking.model.Booking_;
+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;
@@ -51,7 +57,6 @@
@SessionScoped
public class BookingHistoryBean implements BookingHistory
{
-
@Inject
private Logger log;
@@ -62,31 +67,45 @@
private Messages messages;
@Inject
- @Registered
- private User user;
+ private Identity identity;
- private final List<Booking> bookingsForUser = new ArrayList<Booking>();
+ @Inject
+ private AccountHolder accountProducer;
+ private List<Booking> bookingsForUser = null;
+
@Produces
- @Registered
+ @Authenticated
@Named("bookings")
- @SessionScoped
public List<Booking> getBookingsForCurrentUser()
{
- bookingsForUser.clear();
- bookingsForUser.addAll(em.createQuery("select b from Booking b join fetch b.hotel where b.user.username = :username order by b.checkinDate").setParameter("username", user.getUsername()).getResultList());
+ if (identity.isLoggedIn() && bookingsForUser == null)
+ {
+ String username = accountProducer.getCurrentAccount().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();
+ }
return bookingsForUser;
}
- // TODO should probably observe @AfterTransactionSuccess (but it is broken)
- public void afterBookingConfirmed(@Observes @Confirmed final BookingEvent bookingEvent)
+ public void afterBookingConfirmed(@Observes(during = TransactionPhase.AFTER_SUCCESS) @Confirmed final BookingEvent bookingEvent)
{
- getBookingsForCurrentUser();
+ if (bookingsForUser != null)
+ {
+ bookingsForUser.add(bookingEvent.getBooking());
+ }
}
public void cancelBooking(final Booking selectedBooking)
{
- log.info("Canceling booking {0} for {1}", selectedBooking.getId(), user.getName());
+ log.info("Canceling booking {0} for {1}", selectedBooking.getId(), accountProducer.getCurrentAccount().getName());
Booking booking = em.find(Booking.class, selectedBooking.getId());
if (booking != null)
{
@@ -101,9 +120,4 @@
bookingsForUser.remove(selectedBooking);
}
- @PreDestroy
- public void destroy()
- {
- }
-
}
Copied: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/bootstrap/ApplicationSetup.java (from rev 13171, examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/setup/SetupBean.java)
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/bootstrap/ApplicationSetup.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/bootstrap/ApplicationSetup.java 2010-06-16 00:56:36 UTC (rev 13173)
@@ -0,0 +1,35 @@
+/*
+ * 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 at gmail.com">Lincoln Baxter, III</a>
+ *
+ */
+ at Local
+public interface ApplicationSetup
+{
+ public void init(final PostConstructApplicationEvent event);
+}
Copied: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/bootstrap/ApplicationSetupBean.java (from rev 13171, examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/setup/ApplicationSetupBean.java)
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/bootstrap/ApplicationSetupBean.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/bootstrap/ApplicationSetupBean.java 2010-06-16 00:56:36 UTC (rev 13173)
@@ -0,0 +1,90 @@
+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.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;
+
+/**
+ * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
+ */
+ at Stateless
+ at Alternative
+public class ApplicationSetupBean implements ApplicationSetup
+{
+ @PersistenceContext
+ private EntityManager em;
+
+ 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", "laurel"));
+ users.add(new User("Pete Muir", "pete", "edinburgh"));
+ users.add(new User("Lincoln Baxter III", "lincoln", "charlotte"));
+ users.add(new User("Shane", "shane", "brisbane"));
+ users.add(new User("Gavin King", "gavin", "mexico"));
+
+ 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 {
+
+ for (User u : users)
+ {
+ if (em.find(User.class, u.getUsername()) == null)
+ {
+ em.persist(u);
+ }
+ }
+
+ for (Hotel h : hotels)
+ {
+ em.persist(h);
+ }
+ }
+ catch (ConstraintViolationException e)
+ {
+ for (ConstraintViolation v : e.getConstraintViolations())
+ {
+ System.out.println(v.getPropertyPath() + ": " + v.getMessage());
+ }
+ }
+ }
+}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearchBean.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearchBean.java 2010-06-16 00:39:22 UTC (rev 13172)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/inventory/HotelSearchBean.java 2010-06-16 00:56:36 UTC (rev 13173)
@@ -108,9 +108,17 @@
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())));
+ 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();
+ List<Hotel> results = em.createQuery(cquery)
+ .setMaxResults(criteria.getFetchSize())
+ .setFirstResult(criteria.getFetchOffset())
+ .getResultList();
nextPageAvailable = results.size() > criteria.getPageSize();
if (nextPageAvailable)
@@ -122,6 +130,7 @@
{
hotels = results;
}
- log.info(mf.info("Found {0} hotel(s) matching search term ''{1}'' (limit {2})").textParams(hotels.size(), criteria.getQuery(), criteria.getPageSize()).build().getText());
+ log.info(mf.info("Found {0} hotel(s) matching search term [ {1} ] (limit {2})")
+ .textParams(hotels.size(), criteria.getQuery(), criteria.getPageSize()).build().getText());
}
}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/Booking.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/Booking.java 2010-06-16 00:39:22 UTC (rev 13172)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/Booking.java 2010-06-16 00:56:36 UTC (rev 13173)
@@ -151,7 +151,8 @@
{
this.smoking = smoking;
}
-
+
+ //@Size(min = 1, max = 3)
public int getBeds()
{
return beds;
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/User.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/User.java 2010-06-16 00:39:22 UTC (rev 13172)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/model/User.java 2010-06-16 00:56:36 UTC (rev 13173)
@@ -43,7 +43,7 @@
* @author Dan Allen
*/
@Entity
- at Table(name = "customer")
+ at Table(name = "traveler")
@Typed()
public class User implements Serializable
{
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Authenticator.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Authenticator.java 2010-06-16 00:39:22 UTC (rev 13172)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Authenticator.java 2010-06-16 00:56:36 UTC (rev 13173)
@@ -12,4 +12,5 @@
@Local
public interface Authenticator // extends org.jboss.seam.security.Authenticator
{
+ public boolean authenticate();
}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/AuthenticatorBean.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/AuthenticatorBean.java 2010-06-16 00:39:22 UTC (rev 13172)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/AuthenticatorBean.java 2010-06-16 00:56:36 UTC (rev 13173)
@@ -1,7 +1,14 @@
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.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;
@@ -16,11 +23,40 @@
{
@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 you in!");
- return true;
+ log.info("Logging in " + credentials.getUsername());
+ if (credentials.getUsername() == null || credentials.getPassword() == null)
+ {
+ messages.info(new BundleKey("messages.properties", "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("messages.properties", "identity.loggedIn"));
+ return true;
+ }
+ else
+ {
+ messages.info(new BundleKey("messages.properties", "identity.loginFailed"));
+ return false;
+ }
}
}
Added: 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 (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Credentials.java 2010-06-16 00:56:36 UTC (rev 13173)
@@ -0,0 +1,8 @@
+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/Identity.java (from rev 13167, examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/MockIdentity.java)
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Identity.java (rev 0)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/Identity.java 2010-06-16 00:56:36 UTC (rev 13173)
@@ -0,0 +1,76 @@
+/*
+ * 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.faces.context.FacesContext;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.servlet.http.HttpSession;
+
+/**
+ * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
+ */
+ at Named("identity")
+ at SessionScoped
+public class Identity implements Serializable
+{
+ private boolean loggedIn;
+
+ @Inject
+ private FacesContext facesContext;
+
+ @Inject
+ private Authenticator authenticator;
+
+ @Inject
+ private Credentials credentials;
+
+ public String getUsername()
+ {
+ return credentials.getUsername();
+ }
+
+ public boolean isLoggedIn()
+ {
+ return loggedIn;
+ }
+
+ public void login()
+ {
+ if (authenticator.authenticate())
+ {
+ loggedIn = true;
+ credentials.setPassword(null);
+ }
+ }
+
+ public void logout()
+ {
+ loggedIn = false;
+ HttpSession session = (HttpSession) facesContext.getExternalContext().getSession(true);
+ session.invalidate();
+ }
+
+}
Modified: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/MockCredentials.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/MockCredentials.java 2010-06-16 00:39:22 UTC (rev 13172)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/MockCredentials.java 2010-06-16 00:56:36 UTC (rev 13173)
@@ -28,11 +28,10 @@
/**
* @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
- *
*/
@Named("credentials")
@SessionScoped
-public class MockCredentials implements Serializable
+public class MockCredentials implements Credentials, Serializable
{
private String username;
private String password;
Deleted: examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/MockIdentity.java
===================================================================
--- examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/MockIdentity.java 2010-06-16 00:39:22 UTC (rev 13172)
+++ examples/trunk/booking-simplified/src/main/java/org/jboss/seam/examples/booking/security/MockIdentity.java 2010-06-16 00:56:36 UTC (rev 13173)
@@ -1,84 +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.faces.context.FacesContext;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.servlet.http.HttpSession;
-
-import org.jboss.seam.international.status.Messages;
-import org.jboss.seam.international.status.builder.BundleKey;
-
-/**
- * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
- *
- */
- at Named("identity")
- at SessionScoped
-public class MockIdentity implements Serializable
-{
- private boolean loggedIn;
-
- @Inject
- FacesContext context;
-
- @Inject
- Messages messages;
-
- @Inject
- MockCredentials credentials;
-
- public boolean isLoggedIn()
- {
- return loggedIn;
- }
-
- public void setLoggedIn(final boolean loggedIn)
- {
- this.loggedIn = loggedIn;
- }
-
- public void login()
- {
- if ((credentials.getUsername() != null) && !"".equals(credentials.getUsername().trim()))
- {
- loggedIn = true;
- messages.info(new BundleKey("messages.properties", "identity.loggedIn"));
- }
- else
- {
- messages.info(new BundleKey("messages.properties", "identity.loginFailed"));
- }
- }
-
- public void logout()
- {
- loggedIn = false;
- HttpSession session = (HttpSession) context.getExternalContext().getSession(true);
- session.invalidate();
- }
-
-}
Modified: examples/trunk/booking-simplified/src/main/resources/META-INF/persistence.xml
===================================================================
--- examples/trunk/booking-simplified/src/main/resources/META-INF/persistence.xml 2010-06-16 00:39:22 UTC (rev 13172)
+++ examples/trunk/booking-simplified/src/main/resources/META-INF/persistence.xml 2010-06-16 00:56:36 UTC (rev 13173)
@@ -4,10 +4,10 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="booking">
-<!-- <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>-->
+ <!--<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>-->
+ <provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/__default</jta-data-source>
<!--
- <provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/DefaultDS</jta-data-source>
<jta-data-source>jdbc/__arquillian</jta-data-source>
-->
@@ -15,7 +15,8 @@
<!-- Properties for Hibernate (default provider for JBoss AS) -->
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
<property name="hibernate.show_sql" value="true"/>
- <property name="hibernate.format_sql" value="true"/>
+ <!-- Only format when you need to debug, because it slows things down -->
+ <property name="hibernate.format_sql" value="false"/>
<!-- Properties for EclipseLink (default provider for GlassFish) -->
<property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
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-16 00:39:22 UTC (rev 13172)
+++ examples/trunk/booking-simplified/src/main/webapp/WEB-INF/beans.xml 2010-06-16 00:56:36 UTC (rev 13173)
@@ -1,14 +1,13 @@
<?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"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
- http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
-
- <alternatives>
- <class>org.jboss.seam.examples.booking.setup.ApplicationSetupBean</class>
- </alternatives>
-
- <interceptors>
- <class>org.jboss.seam.faces.context.conversation.ConversationBoundaryInterceptor</class>
- </interceptors>
-</beans>
\ No newline at end of file
+<beans xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+ <interceptors>
+ <class>org.jboss.seam.faces.context.conversation.ConversationBoundaryInterceptor</class>
+ </interceptors>
+ <alternatives>
+ <class>org.jboss.seam.examples.booking.bootstrap.ApplicationSetupBean</class>
+ </alternatives>
+</beans>
Modified: examples/trunk/booking-simplified/src/main/webapp/WEB-INF/fragments/account.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/WEB-INF/fragments/account.xhtml 2010-06-16 00:39:22 UTC (rev 13172)
+++ examples/trunk/booking-simplified/src/main/webapp/WEB-INF/fragments/account.xhtml 2010-06-16 00:56:36 UTC (rev 13173)
@@ -6,7 +6,7 @@
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://http://java.sun.com/jsf/composite/components/property">
- <p:display label="Username" value="#{currentUser.username}"/>
- <p:display label="Real name" value="#{currentUser.name}"/>
+ <p:output label="Username" value="#{currentUser.username}"/>
+ <p:output label="Real name" value="#{currentUser.name}"/>
</ui:composition>
Modified: examples/trunk/booking-simplified/src/main/webapp/WEB-INF/fragments/hotel.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/WEB-INF/fragments/hotel.xhtml 2010-06-16 00:39:22 UTC (rev 13172)
+++ examples/trunk/booking-simplified/src/main/webapp/WEB-INF/fragments/hotel.xhtml 2010-06-16 00:56:36 UTC (rev 13173)
@@ -6,17 +6,17 @@
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://http://java.sun.com/jsf/composite/components/property">
- <p:display label="Name" value="#{hotel.name}"/>
- <p:display label="Address" value="#{hotel.address}"/>
- <p:display label="City" value="#{hotel.city}"/>
- <p:display label="State" value="#{hotel.state}"/>
- <p:display label="Zip" value="#{hotel.zip}"/>
- <p:display label="Country" value="#{hotel.country}"/>
- <p:display label="Class" override="true">
+ <p:output label="Name" value="#{hotel.name}"/>
+ <p:output label="Address" value="#{hotel.address}"/>
+ <p:output label="City" value="#{hotel.city}"/>
+ <p:output label="State" value="#{hotel.state}"/>
+ <p:output label="Zip" value="#{hotel.zip}"/>
+ <p:output label="Country" value="#{hotel.country}"/>
+ <p:output label="Class" override="true">
<h:graphicImage value="/img/#{hotel.stars}-star.gif" style="padding-top: 4px;"/>
- </p:display>
- <p:display label="Nightly rate" value="#{hotel.price}">
+ </p:output>
+ <p:output label="Nightly rate" value="#{hotel.price}">
<f:convertNumber for="output" type="currency" currencySymbol="$"/>
- </p:display>
+ </p:output>
</ui:composition>
Modified: examples/trunk/booking-simplified/src/main/webapp/book.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/book.xhtml 2010-06-16 00:39:22 UTC (rev 13172)
+++ examples/trunk/booking-simplified/src/main/webapp/book.xhtml 2010-06-16 00:56:36 UTC (rev 13173)
@@ -25,54 +25,54 @@
<h:form id="bookingForm">
<fieldset>
- <p:edit id="checkinDate" label="Check-in date">
+ <p:input id="checkinDate" label="Check-in date">
<h:inputText id="input" value="#{booking.checkinDate}" binding="#{bookingFormControls.checkinDate}">
<f:convertDateTime type="date" pattern="MM/dd/yyyy"/>
</h:inputText>
- </p:edit>
+ </p:input>
- <p:edit id="checkoutDate" label="Check-out date">
+ <p:input id="checkoutDate" label="Check-out date">
<h:inputText id="input" value="#{booking.checkoutDate}" binding="#{bookingFormControls.checkoutDate}">
<f:convertDateTime type="date" pattern="MM/dd/yyyy"/>
</h:inputText>
- </p:edit>
+ </p:input>
- <p:edit id="beds" label="Room preference">
+ <p:input id="roomPreference">
<h:selectOneMenu id="input" value="#{booking.beds}">
<f:selectItem itemLabel="One king-size bed" itemValue="1"/>
<f:selectItem itemLabel="Two double beds" itemValue="2"/>
<f:selectItem itemLabel="Three beds" itemValue="3"/>
</h:selectOneMenu>
- </p:edit>
+ </p:input>
- <p:edit id="smoking" label="Smoking preference">
+ <p:input id="smokingPreference">
<h:selectOneRadio id="input" value="#{booking.smoking}" layout="pageDirection" styleClass="radio">
<f:selectItem itemLabel="Smoking" itemValue="true"/>
<f:selectItem itemLabel="Non Smoking" itemValue="false"/>
</h:selectOneRadio>
- </p:edit>
+ </p:input>
- <p:edit id="creditCardName" label="Credit card name">
+ <p:input id="creditCardName">
<h:inputText id="input" value="#{booking.creditCardName}"/>
- </p:edit>
+ </p:input>
- <p:edit id="creditCardNumber" label="Credit card #">
+ <p:input id="creditCardNumber" inputs="2">
<h:inputText id="input" value="#{booking.creditCardNumber}"/>
#{' '}
<h:selectOneMenu id="input2" value="#{booking.creditCardType}">
<f:selectItem itemValue="#{null}" itemLabel="Select..." noSelectionOption="true"/>
<f:selectItems value="#{creditCardTypes}" var="_type" itemValue="#{_type}"/>
</h:selectOneMenu>
- </p:edit>
+ </p:input>
- <p:edit id="creditCardExpiry" label="Credit card expiry">
+ <p:input id="creditCardExpiry" inputs="2">
<h:selectOneMenu id="input" value="#{booking.creditCardExpiryMonth}">
<f:selectItems value="#{months}" var="_month" itemValue="#{_month.number}" itemLabel="#{_month.shortName}"/>
</h:selectOneMenu>
<h:selectOneMenu id="input2" value="#{booking.creditCardExpiryYear}">
<f:selectItems value="#{creditCardExpiryYears}" var="_year" itemValue="#{_year}"/>
</h:selectOneMenu>
- </p:edit>
+ </p:input>
<div class="buttonBox">
<h:commandButton id="proceed" value="Proceed" action="#{bookingAgent.validateBooking}"/>
Modified: examples/trunk/booking-simplified/src/main/webapp/confirm.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/confirm.xhtml 2010-06-16 00:39:22 UTC (rev 13172)
+++ examples/trunk/booking-simplified/src/main/webapp/confirm.xhtml 2010-06-16 00:56:36 UTC (rev 13173)
@@ -17,21 +17,21 @@
<ui:include src="/WEB-INF/fragments/hotel.xhtml"/>
- <p:display label="Total payment" value="#{booking.total}">
+ <p:output label="Total payment" value="#{booking.total}">
<f:convertNumber for="output" type="currency" currencySymbol="$"/>
- </p:display>
+ </p:output>
- <p:display label="Check-in date" value="#{booking.checkinDate}">
+ <p:output label="Check-in date" value="#{booking.checkinDate}">
<f:convertDateTime for="output" type="date" pattern="MM/dd/yyyy"/>
- </p:display>
+ </p:output>
- <p:display label="Check-out date" value="#{booking.checkoutDate}">
+ <p:output label="Check-out date" value="#{booking.checkoutDate}">
<f:convertDateTime for="output" type="date" pattern="MM/dd/yyyy"/>
- </p:display>
+ </p:output>
- <p:display label="Credit card #" value="#{booking.creditCardNumber}"/>
+ <p:output label="Credit card #" value="#{booking.creditCardNumber}"/>
- <p:display label="Credit card type" value="#{booking.creditCardType}"/>
+ <p:output label="Credit card type" value="#{booking.creditCardType}"/>
<div class="buttonBox">
<h:form id="confirmForm">
Modified: examples/trunk/booking-simplified/src/main/webapp/hotel.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/hotel.xhtml 2010-06-16 00:39:22 UTC (rev 13172)
+++ examples/trunk/booking-simplified/src/main/webapp/hotel.xhtml 2010-06-16 00:56:36 UTC (rev 13173)
@@ -23,7 +23,7 @@
<div class="buttonBox">
<h:form id="actions">
- <h:commandButton id="bookHotel" action="#{bookingAgent.bookHotel}" value="Book Hotel"/>
+ <h:commandButton id="bookHotel" action="#{bookingAgent.bookHotel}" value="Book Hotel" rendered="#{identity.loggedIn}"/>
#{' '}
<h:commandButton id="cancel" action="#{bookingAgent.cancel}" value="Return to Search" immediate="true"/>
</h:form>
Modified: examples/trunk/booking-simplified/src/main/webapp/password.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/password.xhtml 2010-06-16 00:39:22 UTC (rev 13172)
+++ examples/trunk/booking-simplified/src/main/webapp/password.xhtml 2010-06-16 00:56:36 UTC (rev 13173)
@@ -23,14 +23,14 @@
<fieldset>
- <p:edit id="password" label="Password">
+ <p:input id="password">
<h:inputSecret id="input" value="#{currentUser.password}" redisplay="true"/>
- </p:edit>
+ </p:input>
- <p:edit id="confirmPassword" label="Confirm password">
+ <p:input id="confirmPassword">
<h:inputSecret id="input" value="#{passwordManager.confirmPassword}" redisplay="true"
binding="#{registrationFormControls.confirmPassword}"/>
- </p:edit>
+ </p:input>
<div class="buttonBox">
<h:commandButton id="change" value="Change" action="#{passwordManager.changePassword}"/>
Modified: examples/trunk/booking-simplified/src/main/webapp/register.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/register.xhtml 2010-06-16 00:39:22 UTC (rev 13172)
+++ examples/trunk/booking-simplified/src/main/webapp/register.xhtml 2010-06-16 00:56:36 UTC (rev 13173)
@@ -29,31 +29,31 @@
<fieldset>
- <p:edit id="username" label="Username">
+ <p:input id="username">
<h:inputText id="input" value="#{newUser.username}"
binding="#{registrationFormControls.username}">
<f:ajax event="blur" render="username"/>
</h:inputText>
- </p:edit>
+ </p:input>
- <p:edit id="name" label="Real name">
+ <p:input id="name">
<h:inputText id="input" value="#{newUser.name}">
<f:ajax event="blur" render="name"/>
</h:inputText>
- </p:edit>
+ </p:input>
- <p:edit id="password" label="Password">
+ <p:input id="password">
<h:inputSecret id="input" value="#{newUser.password}" redisplay="true">
<f:ajax event="blur" render="password"/>
</h:inputSecret>
- </p:edit>
+ </p:input>
- <p:edit id="confirmPassword" label="Confirm Password">
+ <p:input id="confirmPassword">
<h:inputSecret id="input" value="#{registrar.confirmPassword}" redisplay="true"
binding="#{registrationFormControls.confirmPassword}">
<f:ajax event="blur" render="confirmPassword"/>
</h:inputSecret>
- </p:edit>
+ </p:input>
<div class="buttonBox">
<h:commandButton id="register" value="Register" action="#{registrar.register}"/>
Deleted: examples/trunk/booking-simplified/src/main/webapp/resources/components/property/display.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/resources/components/property/display.xhtml 2010-06-16 00:39:22 UTC (rev 13172)
+++ examples/trunk/booking-simplified/src/main/webapp/resources/components/property/display.xhtml 2010-06-16 00:56:36 UTC (rev 13173)
@@ -1,32 +0,0 @@
-<!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:c="http://java.sun.com/jsp/jstl/core"
- xmlns:comp="http://java.sun.com/jsf/composite">
-
- <comp:interface>
- <comp:attribute name="label" required="true"/>
- <comp:attribute name="value" required="false"/>
- <comp:attribute name="override" required="false" default="false"/>
- </comp:interface>
-
- <ui:remove>
- TODO allow for a template to be specified, falling back to a default
- </ui:remove>
-
- <comp:implementation>
- <div class="entry" id="#{cc.clientId}">
- <span class="label">#{cc.attrs.label}:</span>
- <span class="output">
- <c:choose>
- <c:when test="#{cc.attrs.override}"><comp:insertChildren/></c:when>
- <c:otherwise><h:outputText id="output" value="#{cc.attrs.value}"><comp:insertChildren/></h:outputText></c:otherwise>
- </c:choose>
- </span>
- </div>
- </comp:implementation>
-
-</ui:composition>
Deleted: examples/trunk/booking-simplified/src/main/webapp/resources/components/property/edit.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/resources/components/property/edit.xhtml 2010-06-16 00:39:22 UTC (rev 13172)
+++ examples/trunk/booking-simplified/src/main/webapp/resources/components/property/edit.xhtml 2010-06-16 00:56:36 UTC (rev 13173)
@@ -1,40 +0,0 @@
-<!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:c="http://java.sun.com/jsp/jstl/core"
- xmlns:comp="http://java.sun.com/jsf/composite">
-
- <comp:interface>
- <comp:attribute name="label" required="true"/>
- <comp:attribute name="required" required="false" default="true"/>
- </comp:interface>
-
- <ui:remove>
- TODO allow for a template to be specified, falling back to a default
- TODO detect required from child or from bean validation annotation
- Ed claims there is #{component.messageList}, but I don't see it
- </ui:remove>
-
- <comp:implementation>
-
- <c:set var="invalid" value="#{not empty facesContext.getMessageList(cc.clientId.concat(':input'))}"/>
- <c:set var="invalid2" value="#{not empty facesContext.getMessageList(cc.clientId.concat(':input2'))}"/>
-
- <div class="entry" id="#{cc.clientId}">
- <h:outputLabel value="#{cc.attrs.label}:" for="input" styleClass="label#{invalid || invalid2 ? ' errors' : ''}">
- <c:if test="#{required}"><span class="required">*</span></c:if>
- </h:outputLabel>
- <span class="input#{invalid || invalid2 ? ' errors' : ''}">
- <comp:insertChildren/>
- </span>
- <h:message for="input" styleClass="error errors" rendered="#{invalid}"/>
- <h:message for="input2" styleClass="error errors" rendered="#{invalid2}"/>
- </div>
-
- </comp:implementation>
-
-
-</ui:composition>
Copied: examples/trunk/booking-simplified/src/main/webapp/resources/components/property/input.xhtml (from rev 13171, examples/trunk/booking-simplified/src/main/webapp/resources/components/property/edit.xhtml)
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/resources/components/property/input.xhtml (rev 0)
+++ examples/trunk/booking-simplified/src/main/webapp/resources/components/property/input.xhtml 2010-06-16 00:56:36 UTC (rev 13173)
@@ -0,0 +1,34 @@
+<!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:c="http://java.sun.com/jsp/jstl/core"
+ xmlns:cc="http://java.sun.com/jsf/composite">
+
+ <cc:interface componentType="org.jboss.seam.faces.InputContainer">
+ <cc:attribute name="label" required="true"/>
+ <cc:attribute name="required" required="false"/>
+ <cc:attribute name="inputs" required="false" default="1"/>
+ </cc:interface>
+
+ <cc:implementation>
+
+ <div class="entry" id="#{cc.clientId}">
+ <h:outputLabel id="label" for="" value="#{cc.attrs.label}:" styleClass="#{cc.attrs.invalid ? 'label errors' : 'label'}">
+ <h:panelGroup styleClass="required" rendered="#{cc.attrs.required}">*</h:panelGroup>
+ </h:outputLabel>
+ <span class="#{cc.attrs.invalid ? 'input errors' : 'input'}">
+ <cc:insertChildren/>
+ </span>
+ <h:panelGroup rendered="#{cc.attrs.invalid}">
+ <c:forEach var="i" begin="1" end="#{cc.attrs.numInputs}">
+ <h:message id="message" for="" errorClass="invalid message"/>
+ </c:forEach>
+ </h:panelGroup>
+ </div>
+
+ </cc:implementation>
+
+</ui:composition>
Copied: examples/trunk/booking-simplified/src/main/webapp/resources/components/property/output.xhtml (from rev 13171, examples/trunk/booking-simplified/src/main/webapp/resources/components/property/display.xhtml)
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/resources/components/property/output.xhtml (rev 0)
+++ examples/trunk/booking-simplified/src/main/webapp/resources/components/property/output.xhtml 2010-06-16 00:56:36 UTC (rev 13173)
@@ -0,0 +1,28 @@
+<!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:c="http://java.sun.com/jsp/jstl/core"
+ xmlns:cc="http://java.sun.com/jsf/composite">
+
+ <cc:interface>
+ <cc:attribute name="label" required="true"/>
+ <cc:attribute name="value" required="false"/>
+ <cc:attribute name="override" required="false" default="false"/>
+ </cc:interface>
+
+ <cc:implementation>
+ <div class="entry" id="#{cc.clientId}">
+ <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:choose>
+ </span>
+ </div>
+ </cc:implementation>
+
+</ui:composition>
Modified: examples/trunk/booking-simplified/src/main/webapp/search.xhtml
===================================================================
--- examples/trunk/booking-simplified/src/main/webapp/search.xhtml 2010-06-16 00:39:22 UTC (rev 13172)
+++ examples/trunk/booking-simplified/src/main/webapp/search.xhtml 2010-06-16 00:56:36 UTC (rev 13173)
@@ -112,10 +112,10 @@
<h1>Current Hotel Bookings</h1>
</div>
<div class="section">
- <h:panelGroup rendered="#{false}">
+ <h:panelGroup rendered="#{not identity.loggedIn}">
You must be logged in to see the list of your hotel bookings.
</h:panelGroup>
- <h:form id="bookings" rendered="#{true}">
+ <h:form id="bookings" rendered="#{identity.loggedIn}">
<h:outputText value="No bookings found." rendered="#{bookings.size() == 0}"/>
<h:dataTable id="bookings" value="#{bookings}" var="_booking" rendered="#{bookings.size() gt 0}">
<h:column id="nameCol">
Modified: examples/trunk/booking-simplified/src/test/java/org/jboss/seam/examples/booking/booking/BookingAgentTest.java
===================================================================
--- examples/trunk/booking-simplified/src/test/java/org/jboss/seam/examples/booking/booking/BookingAgentTest.java 2010-06-16 00:39:22 UTC (rev 13172)
+++ examples/trunk/booking-simplified/src/test/java/org/jboss/seam/examples/booking/booking/BookingAgentTest.java 2010-06-16 00:56:36 UTC (rev 13173)
@@ -13,7 +13,7 @@
import org.jboss.arquillian.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.seam.examples.booking.account.Registered;
+import org.jboss.seam.examples.booking.account.Authenticated;
import org.jboss.seam.examples.booking.controls.BookingFormControls;
import org.jboss.seam.examples.booking.model.Booking;
import org.jboss.seam.examples.booking.model.CreditCardType;
@@ -37,7 +37,7 @@
@Deployment
public static Archive<?> createTestArchive()
{
- WebArchive war = ShrinkWrap.create("test.war", WebArchive.class).addPackage(Hotel.class.getPackage()).addClasses(BookingAgent.class, BookingAgentBean.class, Confirmed.class, Registered.class, BookingEvent.class, BookingFormControls.class, NoOpLogger.class).addLibraries(MavenArtifactResolver.resolve("joda-time:joda-time:1.6"), MavenArtifactResolver.resolve("org.jboss.seam.international:seam-international-api:3.0.0.Alpha1"), MavenArtifactResolver.resolve("org.jboss.seam.international:seam-international:3.0.0.Alpha1")).addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml").addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml");
+ WebArchive war = ShrinkWrap.create("test.war", WebArchive.class).addPackage(Hotel.class.getPackage()).addClasses(BookingAgent.class, BookingAgentBean.class, Confirmed.class, Authenticated.class, BookingEvent.class, BookingFormControls.class, NoOpLogger.class).addLibraries(MavenArtifactResolver.resolve("joda-time:joda-time:1.6"), MavenArtifactResolver.resolve("org.jboss.seam.international:seam-international-api:3.0.0.Alpha1"), MavenArtifactResolver.resolve("org.jboss.seam.international:seam-international:3.0.0.Alpha1")).addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml").addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml");
return war;
}
@@ -71,7 +71,7 @@
// cc.setBeanStore(new HashMapBeanStore());
// cc.setActive(true);
- bookingAgent.selectHotel(em.find(Hotel.class, 1l));
+ bookingAgent.selectHotel(1l);
bookingAgent.bookHotel();
Booking booking = bookingInstance.get();
booking.setCreditCardNumber("1111222233334444");
@@ -86,7 +86,7 @@
}
@Produces
- @Registered
+ @Authenticated
User getRegisteredUser()
{
return em.find(User.class, "ike");
More information about the seam-commits
mailing list