Seam SVN: r10735 - in modules/trunk: faces/src/main/java/org/jboss/seam/faces/application and 3 other directories.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-04-30 16:56:30 -0400 (Thu, 30 Apr 2009)
New Revision: 10735
Added:
modules/trunk/faces/src/main/java/org/jboss/seam/faces/application/SeamViewHandler.java
Modified:
modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesStatusMessages.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/TransferStatusMessagesListener.java
modules/trunk/faces/src/main/resources/META-INF/faces-config.xml
modules/trunk/international/src/main/java/org/jboss/seam/international/StatusMessages.java
Log:
preserve messages on a redirect
change default severity to WARN for addToControl
Modified: modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesStatusMessages.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesStatusMessages.java 2009-04-30 20:26:53 UTC (rev 10734)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesStatusMessages.java 2009-04-30 20:56:30 UTC (rev 10735)
@@ -140,6 +140,9 @@
}
}
+ /**
+ * FIXME does not work if element is inside of form with prependId="false"
+ */
private boolean isAbsoluteClientIdPresent(String targetId, FacesContext facesContext)
{
return facesContext.getViewRoot().findComponent(targetId) != null;
Added: modules/trunk/faces/src/main/java/org/jboss/seam/faces/application/SeamViewHandler.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/application/SeamViewHandler.java (rev 0)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/application/SeamViewHandler.java 2009-04-30 20:56:30 UTC (rev 10735)
@@ -0,0 +1,53 @@
+package org.jboss.seam.faces.application;
+
+import java.util.List;
+import java.util.Map;
+import javax.faces.application.ViewHandler;
+import javax.faces.application.ViewHandlerWrapper;
+import javax.faces.context.FacesContext;
+import org.jboss.seam.faces.lifecycle.TransferStatusMessagesListener;
+import org.jboss.seam.international.StatusMessages;
+
+/**
+ * Wrap the standard JSF view handler to capture the
+ * request for a redirect URL so that the JSF messages
+ * can be preserved.
+ *
+ * @author Dan Allen
+ */
+public class SeamViewHandler extends ViewHandlerWrapper
+{
+ private ViewHandler delegate;
+
+ public SeamViewHandler(ViewHandler delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ @Override
+ public ViewHandler getWrapped()
+ {
+ return delegate;
+ }
+
+ /**
+ * If JSF is requesting a redirect URL, then likely a redirect is about to be performed.
+ * Take this opportunity to store the JSF messages in the flash scope so that they
+ * live past the redirect.
+ *
+ * @see ViewHandler#getRedirectURL(javax.faces.context.FacesContext, java.lang.String, java.util.Map, boolean)
+ */
+ @Override
+ public String getRedirectURL(FacesContext context, String viewId, Map<String, List<String>> parameters, boolean includeViewParams)
+ {
+ // QUESTION hmmm, we have to convert to faces messages now to leverage JSF's flash feature...I suppose that is okay
+ new TransferStatusMessagesListener().execute();
+ if (context.getMessages().hasNext())
+ {
+ context.getExternalContext().getFlash().setKeepMessages(true);
+ }
+
+ return super.getRedirectURL(context, viewId, parameters, includeViewParams);
+ }
+
+}
Modified: modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/TransferStatusMessagesListener.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/TransferStatusMessagesListener.java 2009-04-30 20:26:53 UTC (rev 10734)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/TransferStatusMessagesListener.java 2009-04-30 20:56:30 UTC (rev 10735)
@@ -10,12 +10,10 @@
import org.jboss.webbeans.log.Logging;
/**
- * A {@link SystemEventListener} that observes the PreRenderViewEvent and
- * transposes Seam StatusMessage objects into FacesMessage objects
- * and transfers them to the FacesContext.
+ * A {@link SystemEventListener} that observes the PreRenderViewEvent or
+ * a redirect navigation event (via SeamViewHandler) and transposes Seam
+ * StatusMessage objects into FacesMessage objects and transfers them to the FacesContext.
*
- * FIXME currently losing messages over a redirect after conversation ends (and perhaps when no conversation present)
- *
* @author Dan Allen
*/
//@ListenerFor(systemEventClass = PreRenderViewEvent.class, sourceClass = UIViewRoot.class)
@@ -25,6 +23,16 @@
public void processEvent(SystemEvent preRenderViewEvent)
{
+ execute();
+ }
+
+ public boolean isListenerForSource(Object source)
+ {
+ return true;
+ }
+
+ public void execute()
+ {
Expressions expressions = new FacesExpressions();
// FIXME this is kind of ugly...reminds me of the bad old days of JSF managed beans
StatusMessages statusMessages = (StatusMessages) expressions.createValueExpression(getBeanExpression(StatusMessages.class)).getValue();
@@ -38,11 +46,6 @@
}
}
- public boolean isListenerForSource(Object source)
- {
- return true;
- }
-
private String getBeanName(Class beanClass)
{
return beanClass.getPackage().getName() + "." + Introspector.decapitalize(beanClass.getSimpleName());
Modified: modules/trunk/faces/src/main/resources/META-INF/faces-config.xml
===================================================================
--- modules/trunk/faces/src/main/resources/META-INF/faces-config.xml 2009-04-30 20:26:53 UTC (rev 10734)
+++ modules/trunk/faces/src/main/resources/META-INF/faces-config.xml 2009-04-30 20:56:30 UTC (rev 10735)
@@ -14,6 +14,7 @@
</factory>
<application>
+ <view-handler>org.jboss.seam.faces.application.SeamViewHandler</view-handler>
<el-resolver>org.jboss.seam.el.SeamELResolver</el-resolver>
<el-resolver>org.jboss.seam.faces.el.SeamFacesELResolver</el-resolver>
<system-event-listener>
Modified: modules/trunk/international/src/main/java/org/jboss/seam/international/StatusMessages.java
===================================================================
--- modules/trunk/international/src/main/java/org/jboss/seam/international/StatusMessages.java 2009-04-30 20:26:53 UTC (rev 10734)
+++ modules/trunk/international/src/main/java/org/jboss/seam/international/StatusMessages.java 2009-04-30 20:56:30 UTC (rev 10735)
@@ -46,12 +46,15 @@
* JSF, Wicket).</p>
*
* <p>A status message can either be global or it can be keyed to a "client id", which
- * is the id of a cooresponding user interface component on the page.</p>
+ * is the id of a cooresponding user interface component on the page. The default
+ * severity of a global message is INFO, whereas the default severity of a message
+ * added to a control is WARN. These defaults are choosen since they represent the
+ * most common usage scenario.</p>
*
* <p>Seam will interpolate value expressions and positional parameters in
* message templates. Interpolation is deferred until just before the next view
* in the conversation is rendered, allowing value expressions to resolve to
- * the final state of the action as with the rest of the view.</p>
+ * the final state of the action as does the rest of the view.</p>
*
* @author Pete Muir
* @author Dan Allen
@@ -224,13 +227,13 @@
* used determine which widget the id refers to is determined by the view
* layer implementation in use.
*
- * A severity of INFO will be used, and you can specify parameters to be
+ * A severity of WARN will be used, and you can specify parameters to be
* interpolated
*
*/
public void addToControl(String id, String messageTemplate, Object... params)
{
- addToControl(id, INFO, null, messageTemplate, params);
+ addToControl(id, WARN, null, messageTemplate, params);
}
/**
@@ -308,13 +311,13 @@
* used determine which widget the id refers to is determined by the view
* layer implementation in use.
*
- * A severity of INFO will be used, and you can specify parameters to be
+ * A severity of WARN will be used, and you can specify parameters to be
* interpolated
*
*/
public void addToControlFromResourceBundle(String id, String key, Object... params)
{
- addToControlFromResourceBundle(id, INFO, key, params);
+ addToControlFromResourceBundle(id, WARN, key, params);
}
/**
@@ -342,13 +345,13 @@
* used determine which widget the id refers to is determined by the view
* layer implementation in use.
*
- * A severity of INFO will be used, and you can specify parameters to be
+ * A severity of WARN will be used, and you can specify parameters to be
* interpolated
*
*/
public void addToControlFromResourceBundleOrDefault(String id, String key, String defaultMessageTemplate, Object... params)
{
- addToControlFromResourceBundleOrDefault(id, INFO, key, defaultMessageTemplate, params);
+ addToControlFromResourceBundleOrDefault(id, WARN, key, defaultMessageTemplate, params);
}
/**
15 years, 6 months
Seam SVN: r10734 - in examples/trunk/booking: ejb-jar/src/main/java/org/jboss/seam/examples/booking and 8 other directories.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-04-30 16:26:53 -0400 (Thu, 30 Apr 2009)
New Revision: 10734
Added:
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/BookingEvent.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/Confirmed.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/Identity.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/BookingHistory.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/BookingHistoryBean.java
examples/trunk/booking/ejb-jar/src/main/java/ui/
examples/trunk/booking/ejb-jar/src/main/java/ui/BookingFormControls.java
examples/trunk/booking/ejb-jar/src/main/java/ui/RegistrationFormControls.java
Modified:
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/Registered.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/model/Booking.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/model/Hotel.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/model/User.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/AccountProducerBean.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/BookingAgentBean.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/HotelSearchBean.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/PasswordManager.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/PasswordManagerBean.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/RegistrarBean.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/SearchCriteria.java
examples/trunk/booking/war/src/main/webapp/WEB-INF/faces-config.xml
examples/trunk/booking/war/src/main/webapp/WEB-INF/layout/template.xhtml
examples/trunk/booking/war/src/main/webapp/css/screen.css
examples/trunk/booking/war/src/main/webapp/home.xhtml
examples/trunk/booking/war/src/main/webapp/main.xhtml
examples/trunk/booking/war/src/main/webapp/password.xhtml
Log:
add hotel booking history
add temporary identity component to simulate authentication and current user
add @Registered binding type for registered User
finish change password screen
stub out event to be fired when booking is confirmed (not working yet)
get @Logger annotation working
fix ajax pagination (was executing action method twice)
Added: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/BookingEvent.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/BookingEvent.java (rev 0)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/BookingEvent.java 2009-04-30 20:26:53 UTC (rev 10734)
@@ -0,0 +1,25 @@
+package org.jboss.seam.examples.booking;
+
+import org.jboss.seam.examples.booking.model.Booking;
+
+/**
+ * An event that is raised when a booking change occurs
+ * (either a new booking is confirmed or an existing
+ * booking is canceled).
+ *
+ * @author Dan Allen
+ */
+public class BookingEvent
+{
+ private Booking booking;
+
+ public BookingEvent(Booking booking)
+ {
+ this.booking = booking;
+ }
+
+ public Booking getBooking()
+ {
+ return booking;
+ }
+}
Added: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/Confirmed.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/Confirmed.java (rev 0)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/Confirmed.java 2009-04-30 20:26:53 UTC (rev 10734)
@@ -0,0 +1,30 @@
+package org.jboss.seam.examples.booking;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import javax.inject.BindingType;
+
+/**
+ * @author Dan Allen
+ */
+public
+@Target(
+{
+ TYPE, METHOD, PARAMETER, FIELD
+})
+@Retention(RUNTIME)
+@Documented
+@BindingType
+@Inherited
+@interface Confirmed
+{
+}
Modified: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/Registered.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/Registered.java 2009-04-30 18:42:29 UTC (rev 10733)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/Registered.java 2009-04-30 20:26:53 UTC (rev 10734)
@@ -11,7 +11,7 @@
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
-import javax.inject.DeploymentType;
+import javax.inject.BindingType;
import org.jboss.seam.examples.booking.model.User;
/**
@@ -28,7 +28,7 @@
})
@Retention(RUNTIME)
@Documented
-@DeploymentType
+@BindingType
@Inherited
@interface Registered
{
Modified: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/model/Booking.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/model/Booking.java 2009-04-30 18:42:29 UTC (rev 10733)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/model/Booking.java 2009-04-30 20:26:53 UTC (rev 10734)
@@ -73,6 +73,7 @@
{
this.hotel = hotel;
this.user = user;
+ this.creditCardName = user.getName();
}
@Id
Modified: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/model/Hotel.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/model/Hotel.java 2009-04-30 18:42:29 UTC (rev 10733)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/model/Hotel.java 2009-04-30 20:26:53 UTC (rev 10734)
@@ -31,6 +31,7 @@
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
+import javax.persistence.Transient;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
@@ -148,6 +149,12 @@
this.price = price;
}
+ @Transient
+ public String getLocation()
+ {
+ return city + ", " + state + ", " + country;
+ }
+
@Override
public String toString()
{
Modified: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/model/User.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/model/User.java 2009-04-30 18:42:29 UTC (rev 10733)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/model/User.java 2009-04-30 20:26:53 UTC (rev 10734)
@@ -49,11 +49,11 @@
private String password;
private String name;
- public User(String name, String password, String username)
+ public User(String name, String username, String password)
{
this.name = name;
+ this.username = username;
this.password = password;
- this.username = username;
}
public User()
Added: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/Identity.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/Identity.java (rev 0)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/Identity.java 2009-04-30 20:26:53 UTC (rev 10734)
@@ -0,0 +1,74 @@
+package org.jboss.seam.examples.booking.security;
+
+import java.io.Serializable;
+import javax.annotation.Named;
+import javax.context.SessionScoped;
+import javax.faces.context.FacesContext;
+import javax.inject.manager.Manager;
+
+/**
+ * @author Dan Allen
+ */
+public
+@Named
+@SessionScoped
+class Identity implements Serializable
+{
+ private String username;
+
+ private String password;
+
+ private boolean loggedIn;
+
+ public boolean isLoggedIn()
+ {
+ return loggedIn;
+ }
+
+ public void setLoggedIn(boolean loggedIn)
+ {
+ this.loggedIn = loggedIn;
+ }
+
+ public String getPassword()
+ {
+ return password;
+ }
+
+ public void setPassword(String password)
+ {
+ this.password = password;
+ }
+
+ public String getUsername()
+ {
+ return username;
+ }
+
+ public void setUsername(String username)
+ {
+ this.username = username;
+ }
+
+ public boolean login()
+ {
+ if (username != null && username.length() > 0)
+ {
+ password = null;
+ loggedIn = true;
+ return true;
+ }
+
+ return false;
+ }
+
+ Manager manager;
+
+ public void logout()
+ {
+ username = null;
+ loggedIn = false;
+ // FIXME this is a dirty hack to reset a producer
+ FacesContext.getCurrentInstance().getExternalContext().invalidateSession();
+ }
+}
Modified: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/AccountProducerBean.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/AccountProducerBean.java 2009-04-30 18:42:29 UTC (rev 10733)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/AccountProducerBean.java 2009-04-30 20:26:53 UTC (rev 10734)
@@ -3,11 +3,13 @@
import javax.annotation.Named;
import javax.context.SessionScoped;
import javax.ejb.Stateless;
+import javax.inject.Current;
import javax.inject.Produces;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.jboss.seam.examples.booking.Registered;
import org.jboss.seam.examples.booking.model.User;
+import org.jboss.seam.examples.booking.security.Identity;
/**
* @author Dan Allen
@@ -16,16 +18,28 @@
@Stateless
class AccountProducerBean implements AccountProducer
{
- private @PersistenceContext EntityManager em;
+ @PersistenceContext EntityManager em;
+ @Current Identity identity;
+
public
@Produces
-// @Registered // FIXME not resolving"user" variable if binding type is present
+ @Registered
@Named("user")
@SessionScoped
User getCurrentAccount()
{
- // FIXME provide a real implementation
- return em.find(User.class, "dan");
+ if (identity.isLoggedIn())
+ {
+ User user = em.find(User.class, identity.getUsername());
+ if (user != null)
+ {
+ user.setPassword(null);
+ return user;
+ }
+ }
+
+ // TODO can't return null, but then we are not honoring the semantics of our binding type
+ return new User();
}
}
Modified: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/BookingAgentBean.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/BookingAgentBean.java 2009-04-30 18:42:29 UTC (rev 10733)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/BookingAgentBean.java 2009-04-30 20:26:53 UTC (rev 10734)
@@ -31,10 +31,15 @@
import javax.context.RequestScoped;
import javax.ejb.Remove;
import javax.ejb.Stateful;
+import javax.event.Event;
+import javax.event.Fires;
import javax.inject.Current;
import javax.inject.Produces;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
+import org.jboss.seam.examples.booking.BookingEvent;
+import org.jboss.seam.examples.booking.Confirmed;
+import org.jboss.seam.examples.booking.Registered;
import org.jboss.seam.examples.booking.model.Booking;
import org.jboss.seam.examples.booking.model.Hotel;
import org.jboss.seam.examples.booking.model.User;
@@ -49,7 +54,7 @@
@ConversationScoped
class BookingAgentBean implements BookingAgent
{
- //private @Logger Log log;
+ private @Logger Log log;
@PersistenceContext(type = EXTENDED) EntityManager em;
@@ -59,6 +64,10 @@
@Current BookingFormControls formControls;
+ @Registered User user;
+
+ //@Fires @Confirmed Event<BookingEvent> bookingConfirmedEvent;
+
private Hotel hotelSelection;
private Booking booking;
@@ -67,17 +76,16 @@
public void selectHotel(Hotel hotel)
{
+ // NOTE get a fresh reference that's managed by the conversational persistence context
+ hotelSelection = em.find(Hotel.class, hotel.getId());
+ log.info("Selected the " + hotelSelection.getName() + " in " + hotelSelection.getCity());
conversation.begin();
- // get a fresh reference that's managed by the conversational persistence context
- hotelSelection = em.find(Hotel.class, hotel.getId());
}
public void bookHotel()
{
- // FIXME use current user
- User user = em.find(User.class, "dan");
booking = new Booking(hotelSelection, user);
- // push logic into Booking?
+ // QUESTION push logic into Booking?
Calendar calendar = Calendar.getInstance();
booking.setCheckinDate(calendar.getTime());
calendar.add(Calendar.DAY_OF_MONTH, 1);
@@ -109,7 +117,8 @@
public void confirm()
{
em.persist(booking);
- //log.info("New booking confirmed for...");
+ //bookingConfirmedEvent.fire(new BookingEvent(booking));
+ log.info("New booking at the " + booking.getHotel().getName() + " confirmed for " + booking.getUser().getName());
statusMessages.add("You're booked!");
conversation.end();
}
Added: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/BookingHistory.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/BookingHistory.java (rev 0)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/BookingHistory.java 2009-04-30 20:26:53 UTC (rev 10734)
@@ -0,0 +1,22 @@
+package org.jboss.seam.examples.booking.session;
+
+import java.util.List;
+import javax.ejb.Local;
+import org.jboss.seam.examples.booking.BookingEvent;
+import org.jboss.seam.examples.booking.model.Booking;
+
+/**
+ * @author Dan Allen
+ */
+public
+@Local
+interface BookingHistory
+{
+ List<Booking> getBookingsForCurrentUser();
+
+ void cancelBooking(Booking booking);
+
+ void destroy();
+
+ void afterBookingConfirmed(BookingEvent bookingEvent);
+}
Added: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/BookingHistoryBean.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/BookingHistoryBean.java (rev 0)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/BookingHistoryBean.java 2009-04-30 20:26:53 UTC (rev 10734)
@@ -0,0 +1,85 @@
+package org.jboss.seam.examples.booking.session;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.annotation.Named;
+import javax.annotation.PreDestroy;
+import javax.context.RequestScoped;
+import javax.context.SessionScoped;
+import javax.ejb.Stateful;
+import javax.event.Observes;
+import javax.inject.Current;
+import javax.inject.Produces;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import org.jboss.seam.examples.booking.BookingEvent;
+import org.jboss.seam.examples.booking.Confirmed;
+import org.jboss.seam.examples.booking.Registered;
+import org.jboss.seam.examples.booking.model.Booking;
+import org.jboss.seam.examples.booking.model.User;
+import org.jboss.seam.international.StatusMessages;
+import org.jboss.webbeans.log.Log;
+import org.jboss.webbeans.log.Logger;
+
+/**
+ * @author Dan Allen
+ */
+public
+@Named("bookingHistory")
+@Stateful
+@SessionScoped
+class BookingHistoryBean implements BookingHistory {
+
+ private @Logger Log log;
+
+ @PersistenceContext EntityManager em;
+
+ @Current StatusMessages statusMessages;
+
+ @Registered User user;
+
+ private List<Booking> bookingsForUser = new ArrayList<Booking>();
+
+ public
+ @Produces
+ @Registered
+ @Named("bookings")
+ @SessionScoped
+ List<Booking> getBookingsForCurrentUser()
+ {
+ bookingsForUser.clear();
+ bookingsForUser.addAll(em.createQuery("select b from Booking b join fetch b.hotel where b.user.username = :username order by b.checkinDate")
+ .setParameter("username", user.getUsername())
+ .getResultList());
+ return bookingsForUser;
+ }
+
+ // TODO should probably observe after transaction success
+ public void afterBookingConfirmed(@Observes @Confirmed BookingEvent bookingEvent)
+ {
+ getBookingsForCurrentUser();
+ }
+
+ public void cancelBooking(Booking selectedBooking)
+ {
+ log.info("Canceling booking " + selectedBooking.getId() + " for " + user.getName());
+ Booking booking = em.find(Booking.class, selectedBooking.getId());
+ if (booking != null)
+ {
+ em.remove(booking);
+ statusMessages.add("The booking at the {0} on {1,date} has been canceled.", selectedBooking.getHotel().getName(), selectedBooking.getCheckinDate());
+ }
+ else
+ {
+ statusMessages.add("Our records indicate that the booking you selected has already been canceled.");
+ }
+
+ bookingsForUser.remove(selectedBooking);
+ }
+
+ @PreDestroy
+ public void destroy()
+ {
+ }
+
+}
Modified: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/HotelSearchBean.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/HotelSearchBean.java 2009-04-30 18:42:29 UTC (rev 10733)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/HotelSearchBean.java 2009-04-30 20:26:53 UTC (rev 10734)
@@ -31,10 +31,11 @@
import javax.ejb.Stateful;
import javax.inject.Current;
import javax.inject.Produces;
-import javax.inject.manager.Manager;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.jboss.seam.examples.booking.model.Hotel;
+import org.jboss.webbeans.log.Log;
+import org.jboss.webbeans.log.Logger;
public
@Named("hotelSearch")
@@ -42,11 +43,14 @@
@SessionScoped
class HotelSearchBean implements HotelSearch
{
- @Current Manager manager;
+ private @Logger Log log;
+
+ @PersistenceContext EntityManager em;
+
@Current SearchCriteria criteria;
- private @PersistenceContext EntityManager em;
private boolean nextPageAvailable = false;
+
private List<Hotel> hotels = new ArrayList<Hotel>();
public void find()
@@ -98,7 +102,6 @@
setParameter("pattern", criteria.getSearchPattern()).setMaxResults(criteria.getPageSize() + 1).setFirstResult(criteria.getPage() * criteria.getPageSize()).
getResultList();
- System.out.println("Found " + results.size() + " hotels");
nextPageAvailable = results.size() > criteria.getPageSize();
if (nextPageAvailable)
{
@@ -108,5 +111,6 @@
{
hotels = results;
}
+ log.info("Found " + hotels.size() + " hotels matching search term '" + criteria.getSearchString() + "' (limit " + criteria.getPageSize() + ")");
}
}
Modified: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/PasswordManager.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/PasswordManager.java 2009-04-30 18:42:29 UTC (rev 10733)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/PasswordManager.java 2009-04-30 20:26:53 UTC (rev 10734)
@@ -1,6 +1,8 @@
package org.jboss.seam.examples.booking.session;
import javax.ejb.Local;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
/**
*
@@ -8,10 +10,17 @@
*/
public
@Local
-interface PasswordManager {
+interface PasswordManager
+{
void changePassword();
+
boolean isChanged();
+
void setConfirmPassword(String password);
+
+ @NotNull
+ @Size(min = 5, max = 15)
String getConfirmPassword();
+
void destroy();
}
Modified: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/PasswordManagerBean.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/PasswordManagerBean.java 2009-04-30 18:42:29 UTC (rev 10733)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/PasswordManagerBean.java 2009-04-30 20:26:53 UTC (rev 10734)
@@ -1,5 +1,6 @@
package org.jboss.seam.examples.booking.session;
+import javax.annotation.Named;
import javax.annotation.PreDestroy;
import javax.context.RequestScoped;
import javax.ejb.Stateful;
@@ -12,21 +13,21 @@
import ui.RegistrationFormControls;
/**
- *
* @author Dan Allen
*/
public
+@Named("passwordManager")
@Stateful
@RequestScoped
class PasswordManagerBean implements PasswordManager
{
- private @PersistenceContext EntityManager em;
+ @PersistenceContext EntityManager em;
- private @Current StatusMessages statusMessages;
+ @Current StatusMessages statusMessages;
- private @Current RegistrationFormControls formControls;
+ @Current RegistrationFormControls formControls;
- private @Registered User user;
+ @Registered User user;
private String confirmPassword;
@@ -36,7 +37,9 @@
{
if (user.getPassword().equals(confirmPassword))
{
- user = em.merge(user);
+ // FIXME: dirty hack, can't merge a managed bean
+ em.merge(new User(user.getName(), user.getUsername(), user.getPassword()));
+ user.setPassword(null);
statusMessages.add("Password successfully updated.");
changed = true;
}
Modified: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/RegistrarBean.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/RegistrarBean.java 2009-04-30 18:42:29 UTC (rev 10733)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/RegistrarBean.java 2009-04-30 20:26:53 UTC (rev 10734)
@@ -9,6 +9,7 @@
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.jboss.seam.examples.booking.model.User;
+import org.jboss.seam.examples.booking.security.Identity;
import org.jboss.seam.international.StatusMessage;
import org.jboss.seam.international.StatusMessages;
import ui.RegistrationFormControls;
@@ -22,18 +23,14 @@
@RequestScoped
class RegistrarBean implements Registrar
{
- private
- @PersistenceContext
- EntityManager em;
+ @PersistenceContext EntityManager em;
- private
- @Current
- StatusMessages statusMessages;
+ @Current StatusMessages statusMessages;
- private
- @Current
- RegistrationFormControls formControls;
+ @Current RegistrationFormControls formControls;
+ @Current Identity identity;
+
private User newUser;
private String confirmPassword;
@@ -47,6 +44,8 @@
if (verifyPasswordsMatch() && verifyUsernameIsAvailable())
{
em.persist(newUser);
+ identity.setUsername(newUser.getUsername());
+ identity.login();
registered = true;
statusMessages.add("You have been successfully registered as the user {0}!", newUser.getUsername());
}
Modified: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/SearchCriteria.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/SearchCriteria.java 2009-04-30 18:42:29 UTC (rev 10733)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/SearchCriteria.java 2009-04-30 20:26:53 UTC (rev 10734)
@@ -81,6 +81,7 @@
this.pageSize = pageSize;
}
+ // QUESTION: rename to searchTerm?
public String getSearchString()
{
return searchString;
Added: examples/trunk/booking/ejb-jar/src/main/java/ui/BookingFormControls.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/ui/BookingFormControls.java (rev 0)
+++ examples/trunk/booking/ejb-jar/src/main/java/ui/BookingFormControls.java 2009-04-30 20:26:53 UTC (rev 10734)
@@ -0,0 +1,51 @@
+package ui;
+
+import javax.annotation.Named;
+import javax.context.RequestScoped;
+import javax.faces.component.UIComponent;
+
+/**
+ * A UI binding bean that can provide access to the local id and client id
+ * of selected input components in the booking form.
+ *
+ * @author Dan Allen
+ */
+public
+@Named
+@RequestScoped
+class BookingFormControls
+{
+ private UIComponent checkinDate;
+
+ private UIComponent checkoutDate;
+
+ public UIComponent getCheckinDate()
+ {
+ return checkinDate;
+ }
+
+ public String getCheckinDateControlId()
+ {
+ return checkinDate.getClientId();
+ }
+
+ public void setCheckinDate(UIComponent checkinDate)
+ {
+ this.checkinDate = checkinDate;
+ }
+
+ public UIComponent getCheckoutDate()
+ {
+ return checkoutDate;
+ }
+
+ public void setCheckoutDate(UIComponent checkoutDate)
+ {
+ this.checkoutDate = checkoutDate;
+ }
+
+ public String getCheckoutDateControlId()
+ {
+ return checkoutDate.getClientId();
+ }
+}
Added: examples/trunk/booking/ejb-jar/src/main/java/ui/RegistrationFormControls.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/ui/RegistrationFormControls.java (rev 0)
+++ examples/trunk/booking/ejb-jar/src/main/java/ui/RegistrationFormControls.java 2009-04-30 20:26:53 UTC (rev 10734)
@@ -0,0 +1,52 @@
+package ui;
+
+import javax.annotation.Named;
+import javax.context.RequestScoped;
+import javax.faces.component.UIComponent;
+
+/**
+ * A UI binding bean that can provide access to the local id and client id
+ * of selected input components in the registration form.
+ *
+ * @author Dan Allen
+ */
+public
+@Named
+@RequestScoped
+class RegistrationFormControls
+{
+ private UIComponent username;
+
+ private UIComponent confirmPassword;
+
+ public UIComponent getConfirmPassword()
+ {
+ return confirmPassword;
+ }
+
+ public void setConfirmPassword(UIComponent confirmPassword)
+ {
+ this.confirmPassword = confirmPassword;
+ }
+
+ public String getConfirmPasswordControlId()
+ {
+ return confirmPassword.getClientId();
+ }
+
+ public UIComponent getUsername()
+ {
+ return username;
+ }
+
+ public void setUsername(UIComponent username)
+ {
+ this.username = username;
+ }
+
+ public String getUsernameControlId()
+ {
+ return username.getClientId();
+ }
+
+}
Modified: examples/trunk/booking/war/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- examples/trunk/booking/war/src/main/webapp/WEB-INF/faces-config.xml 2009-04-30 18:42:29 UTC (rev 10733)
+++ examples/trunk/booking/war/src/main/webapp/WEB-INF/faces-config.xml 2009-04-30 20:26:53 UTC (rev 10734)
@@ -8,6 +8,13 @@
<from-view-id>*</from-view-id>
<navigation-case>
+ <from-action>#{identity.logout}</from-action>
+ <if>#{true}</if>
+ <to-view-id>/home.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
<from-action>#{bookingAgent.cancel}</from-action>
<if>#{true}</if>
<to-view-id>/main.xhtml</to-view-id>
@@ -17,6 +24,18 @@
</navigation-rule>
<navigation-rule>
+ <from-view-id>/home.xhtml</from-view-id>
+
+ <navigation-case>
+ <from-action>#{identity.login}</from-action>
+ <if>#{identity.loggedIn}</if>
+ <to-view-id>/main.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ </navigation-rule>
+
+ <navigation-rule>
<from-view-id>/main.xhtml</from-view-id>
<!-- navigation rules are required to reset request-scoped producer variables -->
@@ -87,9 +106,21 @@
<from-action>#{registrar.register}</from-action>
<if>#{registrar.registered}</if>
<to-view-id>/account.xhtml</to-view-id>
- <!--<redirect/> disabled until messages can be kept over redirect -->
+ <redirect/>
</navigation-case>
</navigation-rule>
+ <navigation-rule>
+ <from-view-id>/password.xhtml</from-view-id>
+
+ <navigation-case>
+ <from-action>#{passwordManager.changePassword}</from-action>
+ <if>#{passwordManager.changed}</if>
+ <to-view-id>/account.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ </navigation-rule>
+
</faces-config>
Modified: examples/trunk/booking/war/src/main/webapp/WEB-INF/layout/template.xhtml
===================================================================
--- examples/trunk/booking/war/src/main/webapp/WEB-INF/layout/template.xhtml 2009-04-30 18:42:29 UTC (rev 10733)
+++ examples/trunk/booking/war/src/main/webapp/WEB-INF/layout/template.xhtml 2009-04-30 20:26:53 UTC (rev 10734)
@@ -18,17 +18,21 @@
<div id="document">
<div id="header">
<div id="title"><h:graphicImage value="/img/hdr.title.gif" alt="JBoss Suites: seam framework demo"/></div>
- <div id="status">
- <h:link id="about" outcome="/home.xhtml" value="About"/>
- #{' | '}
- <h:link id="search" outcome="/main.xhtml" value="Search"/>
- <ui:remove><!--
- Welcome #{user.name} or use (#{user.name})
- | <h:link id="search" outcome="/main.xhtml" value="Search"/>
- | <h:link id="settings" outcome="/password.xhtml" value="Settings"/>
- | <s:link id="logout" action="#{identity.logout}" value="Logout"/>
- --></ui:remove>
- </div>
+ <h:form id="menuForm">
+ <div id="status">
+ <h:outputText value="(#{user.name})" rendered="#{identity.loggedIn}" styleClass="user"/>
+ #{' '}
+ <h:link id="about" outcome="/home.xhtml" value="About"/>
+ #{' | '}
+ <h:link id="search" outcome="/main.xhtml" value="Search"/>
+ <h:panelGroup rendered="#{identity.loggedIn}">
+ #{' | '}
+ <h:link id="settings" outcome="/password.xhtml" value="Settings"/>
+ #{' | '}
+ <h:commandLink id="logout" action="#{identity.logout}" value="Logout"/>
+ </h:panelGroup>
+ </div>
+ </h:form>
</div>
<div id="container">
<div id="sidebar">
Modified: examples/trunk/booking/war/src/main/webapp/css/screen.css
===================================================================
--- examples/trunk/booking/war/src/main/webapp/css/screen.css 2009-04-30 18:42:29 UTC (rev 10733)
+++ examples/trunk/booking/war/src/main/webapp/css/screen.css 2009-04-30 20:26:53 UTC (rev 10734)
@@ -269,6 +269,11 @@
color: #C7B299;
text-decoration: none;
}
+#status span.user {
+ padding-right: 5px;
+ color: #FFFDFB;
+ font-weight: normal;
+}
/* Homepage Modifications
----------------------------------------------- */
body.home #container {
Modified: examples/trunk/booking/war/src/main/webapp/home.xhtml
===================================================================
--- examples/trunk/booking/war/src/main/webapp/home.xhtml 2009-04-30 18:42:29 UTC (rev 10733)
+++ examples/trunk/booking/war/src/main/webapp/home.xhtml 2009-04-30 20:26:53 UTC (rev 10734)
@@ -39,23 +39,20 @@
</ui:define>
<ui:define name="sidebar">
- <h:form id="login">
+ <h:form id="login" rendered="#{not identity.loggedIn}">
<fieldset>
- <ui:remove>
<div>
- <h:outputLabel id="UsernameLabel" for="username">Login Name</h:outputLabel>
+ <h:outputLabel for="username" value="Login name"/>
<h:inputText id="username" value="#{identity.username}" style="width: 175px;"/>
- <div class="errors"><h:message id="UsernameMessage" for="username"/></div>
+ <div class="errors"><h:message for="username"/></div>
</div>
<div>
- <h:outputLabel id="PasswordLabel" for="password">Password</h:outputLabel>
+ <h:outputLabel for="password" value="Password"/>
<h:inputSecret id="password" value="#{identity.password}" style="width: 175px;"/>
</div>
<div class="errors"><h:messages id="messages" globalOnly="true"/></div>
<div class="buttonBox"><h:commandButton id="login" action="#{identity.login}" value="Account Login"/></div>
- </ui:remove>
<div class="notes"><h:link id="register" outcome="/register.xhtml" value="Register New User"/></div>
- <ui:remove>
<div class="subnotes">
Or use a demo account:
<ul>
@@ -65,7 +62,6 @@
<li>dan/maryland</li>
</ul>
</div>
- </ui:remove>
</fieldset>
</h:form>
</ui:define>
Modified: examples/trunk/booking/war/src/main/webapp/main.xhtml
===================================================================
--- examples/trunk/booking/war/src/main/webapp/main.xhtml 2009-04-30 18:42:29 UTC (rev 10733)
+++ examples/trunk/booking/war/src/main/webapp/main.xhtml 2009-04-30 20:26:53 UTC (rev 10734)
@@ -40,7 +40,7 @@
</h:inputText>
#{' '}
<h:commandButton id="findHotels" value="Find Hotels" action="#{hotelSearch.find}">
- <f:ajax listener="#{hotelSearch.find}" execute="searchString" render="searchResults" onevent="controlSpinner"/>
+ <f:ajax execute="searchString" render="searchResults" onevent="controlSpinner"/>
</h:commandButton>
#{' '}
<span id="activity" style="display: none;"><h:graphicImage id="spinner" value="/img/spinner.gif"/></span>
@@ -48,6 +48,7 @@
<h:outputLabel id="lblPageSize" for="pageSize" value="Maximum results:"/>
#{' '}
<h:selectOneMenu id="pageSize" value="#{searchCriteria.pageSize}">
+ <f:ajax listener="#{hotelSearch.find}" render="searchResults" onevent="controlSpinner"/>
<f:selectItem itemLabel="5" itemValue="5"/>
<f:selectItem itemLabel="10" itemValue="10"/>
<f:selectItem itemLabel="20" itemValue="20"/>
@@ -63,23 +64,23 @@
<h:dataTable id="hotels" value="#{hotels}" var="_hotel" rendered="#{not empty hotels}"
columnClasses=",,,,action">
<h:column id="nameCol">
- <f:facet id="nameFct" name="header">Name</f:facet>
+ <f:facet id="nameFct" name="header">Hotel name</f:facet>
#{_hotel.name}
</h:column>
- <h:column id="addressCol">
- <f:facet id="addressFct" name="header">Address</f:facet>
+ <h:column id="addrCol">
+ <f:facet id="addrFct" name="header">Address</f:facet>
#{_hotel.address}
</h:column>
- <h:column id="locationCol">
- <f:facet id="locationFct" name="header">Location</f:facet>
- #{_hotel.city}, #{_hotel.state}, #{_hotel.country}
+ <h:column id="locCol">
+ <f:facet id="locFct" name="header">Location</f:facet>
+ #{_hotel.location}
</h:column>
<h:column id="zipCol">
<f:facet id="zipFct" name="header">Zip</f:facet>
#{_hotel.zip}
</h:column>
- <h:column id="actionCol">
- <f:facet id="actionFct" name="header">Action</f:facet>
+ <h:column id="actCol">
+ <f:facet id="actFct" name="header">Action</f:facet>
<h:commandLink id="view" value="View" action="#{bookingAgent.selectHotel(_hotel)}" style="white-space: nowrap;"/>
<ui:remove>
<h:commandButton id="view" value="View" action="#{bookingAgent.selectHotel(_hotel)}"/>
@@ -88,64 +89,73 @@
</h:dataTable>
</h:form>
<h:form id="paginationForm">
- <h:commandButton id="previousResults" value="Previous page" action="#{hotelSearch.previousPage}" rendered="#{hotelSearch.previousPageAvailable}"/>
+ <h:commandButton id="previousResults" value="Previous page" action="#{hotelSearch.previousPage}" rendered="#{hotelSearch.previousPageAvailable}">
+ <f:ajax render="searchResults" onevent="controlSpinner"/>
+ </h:commandButton>
#{' '}
- <h:commandButton id="moreResults" value="More results" action="#{hotelSearch.nextPage}" rendered="#{hotelSearch.nextPageAvailable}"/>
+ <h:commandButton id="moreResults" value="More results" action="#{hotelSearch.nextPage}" rendered="#{hotelSearch.nextPageAvailable}">
+ <f:ajax render="searchResults" onevent="controlSpinner"/>
+ </h:commandButton>
<ui:remove>
- <!-- links in Mojarra are broken -->
- <h:commandLink id="previousResults" value="More results" action="#{hotelSearch.previousPage}" rendered="#{hotelSearch.previousPageAvailable}">
- <f:ajax listener="#{hotelSearch.previousPage}" render="searchResults"/>
+ <h:commandLink id="previousResults" value="Previous page" action="#{hotelSearch.previousPage}" rendered="#{hotelSearch.previousPageAvailable}">
+ <f:ajax render="searchResults" onevent="controlSpinner"/>
</h:commandLink>
+ #{' '}
<h:commandLink id="moreResults" value="More results" action="#{hotelSearch.nextPage}" rendered="#{hotelSearch.nextPageAvailable}">
- <f:ajax listener="#{hotelSearch.nextPage}" render="searchResults"/>
+ <f:ajax render="searchResults" onevent="controlSpinner"/>
</h:commandLink>
</ui:remove>
</h:form>
</div>
- </h:panelGroup>
+ </h:panelGroup>
-<ui:remove>
-<!--
-<div class="section">
- <h1>Current Hotel Bookings</h1>
-</div>
-<div class="section">
- <h:form id="bookings">
- <h:outputText id="NoBookingsFoundMessage" value="No Bookings Found" rendered="#{bookings.rowCount==0}"/>
- <h:dataTable id="bookings" value="#{bookings}" var="book" rendered="#{bookings.rowCount>0}">
- <h:column id="column1">
- <f:facet id="NameFacet" name="header">Name</f:facet>
- #{book.hotel.name}
- </h:column>
- <h:column id="column2">
- <f:facet id="AddressFacet" name="header">Address</f:facet>
- #{book.hotel.address}
- </h:column>
- <h:column id="column3">
- <f:facet id="CityStateFacet" name="header">City, State</f:facet>
- #{book.hotel.city}, #{book.hotel.state}
- </h:column>
- <h:column id="column4">
- <f:facet id="CheckInDateFacet" name="header">Check in date</f:facet>
- <h:outputText id="BookingCheckInDate" value="#{book.checkinDate}"/>
- </h:column>
- <h:column id="column5">
- <f:facet id="CheckOutDateFacet" name="header">Check out date</f:facet>
- <h:outputText id="BookingCheckOutDate" value="#{book.checkoutDate}"/>
- </h:column>
- <h:column id="column6">
- <f:facet id="ConfNumberFacet" name="header">Confirmation number</f:facet>
- #{book.id}
- </h:column>
- <h:column id="column7">
- <f:facet id="ActionFacet" name="header">Action</f:facet>
- <h:commandLink id="cancel" value="Cancel" action="#{bookingList.cancel}"/>
- </h:column>
- </h:dataTable>
- </h:form>
-</div>
--->
-</ui:remove>
+ <div class="section">
+ <h1>Current Hotel Bookings</h1>
+ </div>
+ <div class="section">
+ <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="#{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}">
+ <ui:remove>
+ <h:column id="nameCol">
+ <f:facet id="nameFct" name="header">Hotel name</f:facet>
+ #{_booking.hotel}
+ </h:column>
+ <h:column id="addrCol">
+ <f:facet id="addrCol" name="header">Address</f:facet>
+ #{_booking.hotel.address}
+ </h:column>
+ <h:column id="locCol">
+ <f:facet id="locFct" name="header">Location</f:facet>
+ #{_booking.hotel.location}
+ </h:column>
+ </ui:remove>
+ <h:column id="inCol">
+ <f:facet id="inCol" name="header">Check-in date</f:facet>
+ <h:outputText value="#{_booking.checkinDate}">
+ <f:convertDateTime type="date" pattern="MM/dd/yyyy"/>
+ </h:outputText>
+ </h:column>
+ <h:column id="outCol">
+ <f:facet id="outFct" name="header">Check-out date</f:facet>
+ <h:outputText value="#{_booking.checkoutDate}">
+ <f:convertDateTime type="date" pattern="MM/dd/yyyy"/>
+ </h:outputText>
+ </h:column>
+ <h:column id="idCol">
+ <f:facet id="idFct" name="header">Confirmation number</f:facet>
+ #{_booking.id}
+ </h:column>
+ <h:column id="actCol">
+ <f:facet id="ActFct" name="header">Action</f:facet>
+ <h:commandLink id="cancel" value="Cancel" action="#{bookingHistory.cancelBooking(_booking)}"/>
+ </h:column>
+ </h:dataTable>
+ </h:form>
+ </div>
</ui:define>
Modified: examples/trunk/booking/war/src/main/webapp/password.xhtml
===================================================================
--- examples/trunk/booking/war/src/main/webapp/password.xhtml 2009-04-30 18:42:29 UTC (rev 10733)
+++ examples/trunk/booking/war/src/main/webapp/password.xhtml 2009-04-30 20:26:53 UTC (rev 10734)
@@ -24,11 +24,11 @@
<fieldset>
<p:edit id="password" label="Password">
- <h:inputSecret id="password" value="#{user.password}" redisplay="true"/>
+ <h:inputSecret id="input" value="#{user.password}" redisplay="true"/>
</p:edit>
<p:edit id="confirmPassword" label="Confirm password">
- <h:inputSecret id="password" value="#{passwordManager.confirmPassword}" redisplay="true"
+ <h:inputSecret id="input" value="#{passwordManager.confirmPassword}" redisplay="true"
binding="#{registrationFormControls.confirmPassword}"/>
</p:edit>
15 years, 6 months
Seam SVN: r10733 - branches/community/Seam_2_1/examples/contactlist/resources/WEB-INF.
by seam-commits@lists.jboss.org
Author: norman.richards(a)jboss.com
Date: 2009-04-30 14:42:29 -0400 (Thu, 30 Apr 2009)
New Revision: 10733
Modified:
branches/community/Seam_2_1/examples/contactlist/resources/WEB-INF/components.xml
Log:
JBSEAM-3032
Modified: branches/community/Seam_2_1/examples/contactlist/resources/WEB-INF/components.xml
===================================================================
--- branches/community/Seam_2_1/examples/contactlist/resources/WEB-INF/components.xml 2009-04-30 12:06:45 UTC (rev 10732)
+++ branches/community/Seam_2_1/examples/contactlist/resources/WEB-INF/components.xml 2009-04-30 18:42:29 UTC (rev 10733)
@@ -34,11 +34,11 @@
<fwk:entity-query name="contacts"
max-results="5">
- <fwk:ejbql>from Contact</fwk:ejbql>
+ <fwk:ejbql>select c from Contact c</fwk:ejbql>
<fwk:order>lastName</fwk:order>
<fwk:restrictions>
- <value>lower(firstName) like lower( concat( #{exampleContact.firstName}, '%' ) )</value>
- <value>lower(lastName) like lower( concat( #{exampleContact.lastName}, '%' ) )</value>
+ <value>lower(c.firstName) like lower( concat( #{exampleContact.firstName}, '%' ) )</value>
+ <value>lower(c.lastName) like lower( concat( #{exampleContact.lastName}, '%' ) )</value>
</fwk:restrictions>
</fwk:entity-query>
15 years, 6 months
Seam SVN: r10732 - in branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest: seamgen/src/main/org/jboss/seam/test/functional/seamgen and 1 other directory.
by seam-commits@lists.jboss.org
Author: manaRH
Date: 2009-04-30 08:06:45 -0400 (Thu, 30 Apr 2009)
New Revision: 10732
Modified:
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/ftest.properties
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/SeamGenTest.java
Log:
JBPAPP-1899
Modified: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/ftest.properties
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/ftest.properties 2009-04-30 12:02:38 UTC (rev 10731)
+++ branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/ftest.properties 2009-04-30 12:06:45 UTC (rev 10732)
@@ -44,6 +44,10 @@
jboss.undeploy.target=undeploy
# default wait times
jboss.deploy.waittime=300
+# container locations - must be set
+# independent from ${seam.dir}/build.properties
+jboss.home=/home/mnovotny/apps/jboss-eap-4.3_fp/jboss-as
+
# default wait urls
jboss.example.ready.check.url=seam-${example.name}/
Modified: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/SeamGenTest.java
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/SeamGenTest.java 2009-04-30 12:02:38 UTC (rev 10731)
+++ branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/SeamGenTest.java 2009-04-30 12:06:45 UTC (rev 10732)
@@ -141,7 +141,7 @@
WORKSPACE = ftestProperties.getProperty("workspace.home");
// container specific
- CONTAINER = ftestProperties.getProperty("container", "jboss5");
+ CONTAINER = ftestProperties.getProperty("container", "jboss");
CONTAINER_LOCATION = ftestProperties.getProperty(CONTAINER + ".home");
DEPLOY_TIMEOUT = Integer.parseInt(ftestProperties.getProperty(CONTAINER + ".deploy.waittime")) * 1000; // miliseconds
DELETE_PROJECT = Boolean.valueOf(ftestProperties.getProperty("seamgen.delete.project", "false"));
@@ -160,14 +160,14 @@
{
seamGenProperties = new Properties();
- String[] propertiesToCopy = { "database.type", "database.exists", "database.drop", "driver.jar", "driver.license.jar", "hibernate.connection.username", "hibernate.connection.password", "hibernate.connection.driver_class", "hibernate.connection.dataSource_class", "hibernate.cache.provider_class", "hibernate.default_catalog.null", "hibernate.default_schema.null", "hibernate.dialect", "hibernate.connection.url", "model.package", "action.package", "test.package", "richfaces.skin", "icefaces.home", "jboss.home" };
+ String[] propertiesToCopy = { "database.type", "database.exists", "database.drop", "driver.jar", "driver.license.jar", "hibernate.connection.username", "hibernate.connection.password", "hibernate.connection.driver_class", "hibernate.connection.dataSource_class", "hibernate.cache.provider_class", "hibernate.default_catalog.null", "hibernate.default_schema.null", "hibernate.dialect", "hibernate.connection.url", "model.package", "action.package", "test.package", "richfaces.skin", "icefaces.home", "jboss.home", "jboss.domain" };
for (String property : propertiesToCopy)
{
if (ftestProperties.get(property) != null)
{
seamGenProperties.put(property, ftestProperties.get(property));
- }
+ }
}
// override with ftest.properties
15 years, 6 months
Seam SVN: r10731 - in branches/enterprise/JBPAPP_4_3_FP01: examples and 3 other directories.
by seam-commits@lists.jboss.org
Author: manaRH
Date: 2009-04-30 08:02:38 -0400 (Thu, 30 Apr 2009)
New Revision: 10731
Modified:
branches/enterprise/JBPAPP_4_3_FP01/build/common.build.xml
branches/enterprise/JBPAPP_4_3_FP01/build/utilities.build.xml
branches/enterprise/JBPAPP_4_3_FP01/examples/build.xml
branches/enterprise/JBPAPP_4_3_FP01/seam-gen/build-scripts/deployed-jars-ear.list
branches/enterprise/JBPAPP_4_3_FP01/seam-gen/build-scripts/deployed-jars-war.list
branches/enterprise/JBPAPP_4_3_FP01/seam-gen/icefaces/build-scripts/deployed-jars-ear.list
branches/enterprise/JBPAPP_4_3_FP01/seam-gen/icefaces/build-scripts/deployed-jars-war.list
branches/enterprise/JBPAPP_4_3_FP01/seam-gen/nbproject/project.xml
Log:
replaced mvel14.jar renaming, used pure mvel.jar
Modified: branches/enterprise/JBPAPP_4_3_FP01/build/common.build.xml
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/build/common.build.xml 2009-04-30 07:49:15 UTC (rev 10730)
+++ branches/enterprise/JBPAPP_4_3_FP01/build/common.build.xml 2009-04-30 12:02:38 UTC (rev 10731)
@@ -125,9 +125,7 @@
<copyDependencies id="pdf" pom="${pdf.pom}" todir="${lib.dir}" scope="compile" />
<copyDependencies id="remoting" pom="${remoting.pom}" todir="${lib.dir}" scope="compile" />
<copyDependencies id="ui" pom="${ui.pom}" todir="${lib.dir}" scope="compile" />
- <copyDependencies id="gen" pom="${gen.pom}" todir="${lib.dir}/gen" scope="compile" />
- <!-- globmapper doesn't work with ant 1.6.5-->
- <move file="${lib.dir}/mvel.jar" tofile="${lib.dir}/mvel14.jar"/>
+ <copyDependencies id="gen" pom="${gen.pom}" todir="${lib.dir}/gen" scope="compile" />
<property name="copyseamdependenciesdone" value="true" />
</target>
Modified: branches/enterprise/JBPAPP_4_3_FP01/build/utilities.build.xml
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/build/utilities.build.xml 2009-04-30 07:49:15 UTC (rev 10730)
+++ branches/enterprise/JBPAPP_4_3_FP01/build/utilities.build.xml 2009-04-30 12:02:38 UTC (rev 10731)
@@ -137,10 +137,6 @@
<chainedmapper>
<mapper classpathref="maven-ant-tasks.classpath" classname="org.apache.maven.artifact.ant.VersionMapper" from="${@{scope}.(a){id}.versions}" to="flatten" />
<flattenmapper />
- <compositemapper>
- <identitymapper />
- <globmapper from="mvel.jar" to="mvel14.jar"/>
- </compositemapper>
</chainedmapper>
</copy>
</sequential>
@@ -162,10 +158,6 @@
<chainedmapper>
<mapper classpathref="maven-ant-tasks.classpath" classname="org.apache.maven.artifact.ant.VersionMapper" from="${@{scope}.(a){id}.versions}" to="flatten" />
<flattenmapper />
- <compositemapper>
- <identitymapper />
- <globmapper from="mvel.jar" to="mvel14.jar"/>
- </compositemapper>
</chainedmapper>
</copy>
</sequential>
Modified: branches/enterprise/JBPAPP_4_3_FP01/examples/build.xml
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/examples/build.xml 2009-04-30 07:49:15 UTC (rev 10730)
+++ branches/enterprise/JBPAPP_4_3_FP01/examples/build.xml 2009-04-30 12:02:38 UTC (rev 10731)
@@ -253,7 +253,7 @@
<include name="antlr-runtime.jar" if="drools.lib" />
<include name="core.jar" if="drools.lib" />
<include name="janino.jar" if="drools.lib" />
- <include name="mvel14.jar" if="drools.lib" />
+ <include name="mvel.jar" if="drools.lib" />
<include name="drools-core.jar" if="drools.lib" />
<include name="drools-compiler.jar" if="drools.lib" />
</fileset>
Modified: branches/enterprise/JBPAPP_4_3_FP01/seam-gen/build-scripts/deployed-jars-ear.list
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/seam-gen/build-scripts/deployed-jars-ear.list 2009-04-30 07:49:15 UTC (rev 10730)
+++ branches/enterprise/JBPAPP_4_3_FP01/seam-gen/build-scripts/deployed-jars-ear.list 2009-04-30 12:02:38 UTC (rev 10731)
@@ -5,5 +5,5 @@
janino.jar
jboss-el.jar
jbpm-jpdl.jar
-mvel14.jar
+mvel.jar
richfaces-api.jar
Modified: branches/enterprise/JBPAPP_4_3_FP01/seam-gen/build-scripts/deployed-jars-war.list
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/seam-gen/build-scripts/deployed-jars-war.list 2009-04-30 07:49:15 UTC (rev 10730)
+++ branches/enterprise/JBPAPP_4_3_FP01/seam-gen/build-scripts/deployed-jars-war.list 2009-04-30 12:02:38 UTC (rev 10731)
@@ -10,7 +10,7 @@
jboss-seam-*.jar
jbpm-jpdl.jar
jsf-facelets.jar
-mvel14.jar
+mvel.jar
richfaces-api.jar
richfaces-impl.jar
richfaces-ui.jar
Modified: branches/enterprise/JBPAPP_4_3_FP01/seam-gen/icefaces/build-scripts/deployed-jars-ear.list
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/seam-gen/icefaces/build-scripts/deployed-jars-ear.list 2009-04-30 07:49:15 UTC (rev 10730)
+++ branches/enterprise/JBPAPP_4_3_FP01/seam-gen/icefaces/build-scripts/deployed-jars-ear.list 2009-04-30 12:02:38 UTC (rev 10731)
@@ -11,4 +11,4 @@
janino.jar
jboss-el.jar
jbpm-jpdl.jar
-mvel14.jar
+mvel.jar
Modified: branches/enterprise/JBPAPP_4_3_FP01/seam-gen/icefaces/build-scripts/deployed-jars-war.list
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/seam-gen/icefaces/build-scripts/deployed-jars-war.list 2009-04-30 07:49:15 UTC (rev 10730)
+++ branches/enterprise/JBPAPP_4_3_FP01/seam-gen/icefaces/build-scripts/deployed-jars-war.list 2009-04-30 12:02:38 UTC (rev 10731)
@@ -14,4 +14,4 @@
jboss-seam.jar
jboss-seam-*.jar
jbpm-jpdl.jar
-mvel14.jar
+mvel.jar
Modified: branches/enterprise/JBPAPP_4_3_FP01/seam-gen/nbproject/project.xml
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/seam-gen/nbproject/project.xml 2009-04-30 07:49:15 UTC (rev 10730)
+++ branches/enterprise/JBPAPP_4_3_FP01/seam-gen/nbproject/project.xml 2009-04-30 12:02:38 UTC (rev 10731)
@@ -96,18 +96,18 @@
<java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/2">
<compilation-unit>
<package-root>src/model</package-root>
- <classpath mode="compile">lib/hibernate-validator.jar:lib/hibernate3.jar:lib/hibernate-annotations.jar:lib/hibernate-commons-annotations.jar:lib/hibernate-entitymanager.jar:lib/jboss-seam.jar:lib/jboss-seam-debug.jar:lib/jboss-cache.jar:lib/jbpm-jpdl.jar:lib/antlr.jar:lib/jgroups.jar:lib/jsf-facelets.jar:lib/jstl.jar:lib/jsf-api.jar:lib/servlet-api.jar:lib/jboss-el.jar:lib/el-api.jar:lib/mvel14.jar:lib/drools-core.jar:lib/drools-compiler.jar:lib/janino.jar:lib/antlr-runtime.jar:lib/mail.jar:lib/persistence-api.jar:lib/ejb-api.jar:lib/jsr250-api.jar:lib/jta.jar:lib/core.jar:lib/jboss-embedded-api.jar:lib/hibernate-search.jar:lib/richfaces-api.jar:lib/richfaces-ui.jar:lib/@driverJar@:lib/lucene-core.jar</classpath>
+ <classpath mode="compile">lib/hibernate-validator.jar:lib/hibernate3.jar:lib/hibernate-annotations.jar:lib/hibernate-commons-annotations.jar:lib/hibernate-entitymanager.jar:lib/jboss-seam.jar:lib/jboss-seam-debug.jar:lib/jboss-cache.jar:lib/jbpm-jpdl.jar:lib/antlr.jar:lib/jgroups.jar:lib/jsf-facelets.jar:lib/jstl.jar:lib/jsf-api.jar:lib/servlet-api.jar:lib/jboss-el.jar:lib/el-api.jar:lib/mvel.jar:lib/drools-core.jar:lib/drools-compiler.jar:lib/janino.jar:lib/antlr-runtime.jar:lib/mail.jar:lib/persistence-api.jar:lib/ejb-api.jar:lib/jsr250-api.jar:lib/jta.jar:lib/core.jar:lib/jboss-embedded-api.jar:lib/hibernate-search.jar:lib/richfaces-api.jar:lib/richfaces-ui.jar:lib/@driverJar@:lib/lucene-core.jar</classpath>
<source-level>1.5</source-level>
</compilation-unit>
<compilation-unit>
<package-root>src/action</package-root>
- <classpath mode="compile">lib/hibernate-validator.jar:lib/hibernate3.jar:lib/hibernate-annotations.jar:lib/hibernate-commons-annotations.jar:lib/hibernate-entitymanager.jar:lib/jboss-seam.jar:lib/jboss-seam-debug.jar:lib/jboss-cache.jar:lib/jbpm-jpdl.jar:lib/antlr.jar:lib/jgroups.jar:lib/jsf-facelets.jar:lib/jstl.jar:lib/jsf-api.jar:lib/servlet-api.jar:lib/jboss-el.jar:lib/el-api.jar:lib/mvel14.jar:lib/drools-core.jar:lib/drools-compiler.jar:lib/janino.jar:lib/antlr-runtime.jar:lib/mail.jar:lib/persistence-api.jar:lib/ejb-api.jar:lib/jsr250-api.jar:lib/jta.jar:lib/core.jar:lib/jboss-embedded-api.jar:lib/hibernate-search.jar:lib/richfaces-api.jar:lib/richfaces-ui.jar:lib/@driverJar@:lib/lucene-core.jar</classpath>
+ <classpath mode="compile">lib/hibernate-validator.jar:lib/hibernate3.jar:lib/hibernate-annotations.jar:lib/hibernate-commons-annotations.jar:lib/hibernate-entitymanager.jar:lib/jboss-seam.jar:lib/jboss-seam-debug.jar:lib/jboss-cache.jar:lib/jbpm-jpdl.jar:lib/antlr.jar:lib/jgroups.jar:lib/jsf-facelets.jar:lib/jstl.jar:lib/jsf-api.jar:lib/servlet-api.jar:lib/jboss-el.jar:lib/el-api.jar:lib/mvel.jar:lib/drools-core.jar:lib/drools-compiler.jar:lib/janino.jar:lib/antlr-runtime.jar:lib/mail.jar:lib/persistence-api.jar:lib/ejb-api.jar:lib/jsr250-api.jar:lib/jta.jar:lib/core.jar:lib/jboss-embedded-api.jar:lib/hibernate-search.jar:lib/richfaces-api.jar:lib/richfaces-ui.jar:lib/@driverJar@:lib/lucene-core.jar</classpath>
<source-level>1.5</source-level>
</compilation-unit>
<compilation-unit>
<package-root>src/test</package-root>
<unit-tests/>
- <classpath mode="compile">bootstrap:lib/hibernate-validator.jar:lib/hibernate3.jar:lib/hibernate-annotations.jar:lib/hibernate-commons-annotations.jar:lib/hibernate-entitymanager.jar:lib/jboss-seam.jar:lib/jboss-seam-debug.jar:lib/jboss-cache.jar:lib/jbpm-jpdl.jar:lib/antlr.jar:lib/jgroups.jar:lib/jsf-facelets.jar:lib/jstl.jar:lib/jsf-api.jar:lib/servlet-api.jar:lib/testng.jar:lib/jboss-el.jar:lib/el-api.jar:lib/mvel14.jar:lib/drools-core.jar:lib/drools-compiler.jar:lib/janino.jar:lib/antlr-runtime.jar:lib/mail.jar:lib/persistence-api.jar:lib/ejb-api.jar:lib/jsr250-api.jar:lib/jta.jar:lib/core.jar:lib/jboss-embedded-api.jar:lib/hibernate-search.jar:lib/richfaces-api.jar:lib/@driverJar@:lib/lucene-core.jar</classpath>
+ <classpath mode="compile">bootstrap:lib/hibernate-validator.jar:lib/hibernate3.jar:lib/hibernate-annotations.jar:lib/hibernate-commons-annotations.jar:lib/hibernate-entitymanager.jar:lib/jboss-seam.jar:lib/jboss-seam-debug.jar:lib/jboss-cache.jar:lib/jbpm-jpdl.jar:lib/antlr.jar:lib/jgroups.jar:lib/jsf-facelets.jar:lib/jstl.jar:lib/jsf-api.jar:lib/servlet-api.jar:lib/testng.jar:lib/jboss-el.jar:lib/el-api.jar:lib/mvel.jar:lib/drools-core.jar:lib/drools-compiler.jar:lib/janino.jar:lib/antlr-runtime.jar:lib/mail.jar:lib/persistence-api.jar:lib/ejb-api.jar:lib/jsr250-api.jar:lib/jta.jar:lib/core.jar:lib/jboss-embedded-api.jar:lib/hibernate-search.jar:lib/richfaces-api.jar:lib/@driverJar@:lib/lucene-core.jar</classpath>
<source-level>1.5</source-level>
</compilation-unit>
</java-data>
15 years, 6 months
Seam SVN: r10730 - examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-04-30 03:49:15 -0400 (Thu, 30 Apr 2009)
New Revision: 10730
Added:
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/Registered.java
Log:
add binding type for registered entities
Added: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/Registered.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/Registered.java (rev 0)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/Registered.java 2009-04-30 07:49:15 UTC (rev 10730)
@@ -0,0 +1,35 @@
+package org.jboss.seam.examples.booking;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import javax.inject.DeploymentType;
+import org.jboss.seam.examples.booking.model.User;
+
+/**
+ * A binding type representing something that is registererd.
+ * In this simple application the only thing that can be
+ * registered is a {@link User}.
+ *
+ * @author Dan Allen
+ */
+public
+@Target(
+{
+ TYPE, METHOD, PARAMETER, FIELD
+})
+@Retention(RUNTIME)
+@Documented
+@DeploymentType
+@Inherited
+@interface Registered
+{
+}
15 years, 6 months
Seam SVN: r10729 - in examples/trunk/booking: ejb-jar and 7 other directories.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-04-30 03:48:46 -0400 (Thu, 30 Apr 2009)
New Revision: 10729
Added:
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/AccountProducer.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/AccountProducerBean.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/PasswordManager.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/PasswordManagerBean.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/Registrar.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/RegistrarBean.java
examples/trunk/booking/war/src/main/webapp/WEB-INF/fragments/account.xhtml
examples/trunk/booking/war/src/main/webapp/WEB-INF/fragments/user.xhtml
examples/trunk/booking/war/src/main/webapp/account.xhtml
examples/trunk/booking/war/src/main/webapp/password.xhtml
examples/trunk/booking/war/src/main/webapp/register.xhtml
Modified:
examples/trunk/booking/ejb-jar/pom.xml
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/model/User.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/BookingAgentBean.java
examples/trunk/booking/pom.xml
examples/trunk/booking/war/src/main/webapp/WEB-INF/faces-config.xml
examples/trunk/booking/war/src/main/webapp/WEB-INF/layout/template.xhtml
examples/trunk/booking/war/src/main/webapp/book.xhtml
examples/trunk/booking/war/src/main/webapp/confirm.xhtml
examples/trunk/booking/war/src/main/webapp/css/screen.css
examples/trunk/booking/war/src/main/webapp/home.xhtml
Log:
add registration, account page, and change password
clean up some styles
Modified: examples/trunk/booking/ejb-jar/pom.xml
===================================================================
--- examples/trunk/booking/ejb-jar/pom.xml 2009-04-29 23:56:18 UTC (rev 10728)
+++ examples/trunk/booking/ejb-jar/pom.xml 2009-04-30 07:48:46 UTC (rev 10729)
@@ -77,6 +77,12 @@
</dependency>
<dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<scope>provided</scope>
Modified: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/model/User.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/model/User.java 2009-04-29 23:56:18 UTC (rev 10728)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/model/User.java 2009-04-30 07:48:46 UTC (rev 10729)
@@ -85,7 +85,8 @@
}
@Id
- @Size(min = 4, max = 15)
+ @NotNull
+ @Size(min = 3, max = 15)
@Pattern(regexp = "^\\w*$", message = "not a valid username")
public String getUsername()
{
Added: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/AccountProducer.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/AccountProducer.java (rev 0)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/AccountProducer.java 2009-04-30 07:48:46 UTC (rev 10729)
@@ -0,0 +1,17 @@
+package org.jboss.seam.examples.booking.session;
+
+import javax.ejb.Local;
+import org.jboss.seam.examples.booking.model.User;
+
+/**
+ * The <strong>AccountProducer</strong> produces the object that
+ * represents the current user's account information. The account
+ * information is represented by the {@link User} entity.
+ *
+ * @author Dan Allen
+ */
+public
+@Local
+interface AccountProducer {
+ User getCurrentAccount();
+}
Added: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/AccountProducerBean.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/AccountProducerBean.java (rev 0)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/AccountProducerBean.java 2009-04-30 07:48:46 UTC (rev 10729)
@@ -0,0 +1,31 @@
+package org.jboss.seam.examples.booking.session;
+
+import javax.annotation.Named;
+import javax.context.SessionScoped;
+import javax.ejb.Stateless;
+import javax.inject.Produces;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import org.jboss.seam.examples.booking.Registered;
+import org.jboss.seam.examples.booking.model.User;
+
+/**
+ * @author Dan Allen
+ */
+public
+@Stateless
+class AccountProducerBean implements AccountProducer
+{
+ private @PersistenceContext EntityManager em;
+
+ public
+ @Produces
+// @Registered // FIXME not resolving"user" variable if binding type is present
+ @Named("user")
+ @SessionScoped
+ User getCurrentAccount()
+ {
+ // FIXME provide a real implementation
+ return em.find(User.class, "dan");
+ }
+}
Modified: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/BookingAgentBean.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/BookingAgentBean.java 2009-04-29 23:56:18 UTC (rev 10728)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/BookingAgentBean.java 2009-04-30 07:48:46 UTC (rev 10729)
@@ -41,6 +41,7 @@
import org.jboss.seam.international.StatusMessages;
import org.jboss.webbeans.log.Log;
import org.jboss.webbeans.log.Logger;
+import ui.BookingFormControls;
public
@Named("bookingAgent")
@@ -56,6 +57,8 @@
@Current StatusMessages statusMessages;
+ @Current BookingFormControls formControls;
+
private Hotel hotelSelection;
private Booking booking;
@@ -89,12 +92,12 @@
calendar.add(Calendar.DAY_OF_MONTH, -1);
if (booking.getCheckinDate().before(calendar.getTime()))
{
- statusMessages.addToControl("booking:checkinDate:input", "Check in date must be a future date");
+ statusMessages.addToControl(formControls.getCheckinDateControlId(), "Check in date must be a future date");
bookingValid = false;
}
else if (!booking.getCheckinDate().before(booking.getCheckoutDate()))
{
- statusMessages.addToControl("booking:checkoutDate:input", "Check out date must be after check in date");
+ statusMessages.addToControl(formControls.getCheckoutDateControlId(), "Check out date must be after check in date");
bookingValid = false;
}
else
Added: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/PasswordManager.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/PasswordManager.java (rev 0)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/PasswordManager.java 2009-04-30 07:48:46 UTC (rev 10729)
@@ -0,0 +1,17 @@
+package org.jboss.seam.examples.booking.session;
+
+import javax.ejb.Local;
+
+/**
+ *
+ * @author Dan Allen
+ */
+public
+@Local
+interface PasswordManager {
+ void changePassword();
+ boolean isChanged();
+ void setConfirmPassword(String password);
+ String getConfirmPassword();
+ void destroy();
+}
Added: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/PasswordManagerBean.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/PasswordManagerBean.java (rev 0)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/PasswordManagerBean.java 2009-04-30 07:48:46 UTC (rev 10729)
@@ -0,0 +1,71 @@
+package org.jboss.seam.examples.booking.session;
+
+import javax.annotation.PreDestroy;
+import javax.context.RequestScoped;
+import javax.ejb.Stateful;
+import javax.inject.Current;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import org.jboss.seam.examples.booking.Registered;
+import org.jboss.seam.examples.booking.model.User;
+import org.jboss.seam.international.StatusMessages;
+import ui.RegistrationFormControls;
+
+/**
+ *
+ * @author Dan Allen
+ */
+public
+@Stateful
+@RequestScoped
+class PasswordManagerBean implements PasswordManager
+{
+ private @PersistenceContext EntityManager em;
+
+ private @Current StatusMessages statusMessages;
+
+ private @Current RegistrationFormControls formControls;
+
+ private @Registered User user;
+
+ private String confirmPassword;
+
+ private boolean changed;
+
+ public void changePassword()
+ {
+ if (user.getPassword().equals(confirmPassword))
+ {
+ user = em.merge(user);
+ statusMessages.add("Password successfully updated.");
+ changed = true;
+ }
+ else
+ {
+ // FIME reverting isn't going to work here
+ //revertUser();
+ confirmPassword = null;
+ statusMessages.addToControl(formControls.getConfirmPasswordControlId(), "Passwords do not match. Please re-type the new password.");
+ }
+ }
+
+ public boolean isChanged()
+ {
+ return changed;
+ }
+
+ public void setConfirmPassword(String password)
+ {
+ this.confirmPassword = password;
+ }
+
+ public String getConfirmPassword()
+ {
+ return this.confirmPassword;
+ }
+
+ @PreDestroy
+ public void destroy()
+ {
+ }
+}
Added: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/Registrar.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/Registrar.java (rev 0)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/Registrar.java 2009-04-30 07:48:46 UTC (rev 10729)
@@ -0,0 +1,32 @@
+package org.jboss.seam.examples.booking.session;
+
+import javax.ejb.Local;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import org.jboss.seam.examples.booking.model.User;
+
+/**
+ * @author Dan Allen
+ */
+public
+@Local
+interface Registrar
+{
+ void register();
+
+ boolean isRegistrationInvalid();
+
+ void notifyIfRegistrationIsInvalid(boolean validationFailed);
+
+ User getNewUser();
+
+ boolean isRegistered();
+
+ @NotNull
+ @Size(min = 5, max = 15)
+ String getConfirmPassword();
+
+ void setConfirmPassword(String password);
+
+ void destroy();
+}
Added: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/RegistrarBean.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/RegistrarBean.java (rev 0)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/RegistrarBean.java 2009-04-30 07:48:46 UTC (rev 10729)
@@ -0,0 +1,129 @@
+package org.jboss.seam.examples.booking.session;
+
+import javax.annotation.Named;
+import javax.annotation.PreDestroy;
+import javax.context.RequestScoped;
+import javax.ejb.Stateful;
+import javax.inject.Current;
+import javax.inject.Produces;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import org.jboss.seam.examples.booking.model.User;
+import org.jboss.seam.international.StatusMessage;
+import org.jboss.seam.international.StatusMessages;
+import ui.RegistrationFormControls;
+
+/**
+ * @author Dan Allen
+ */
+public
+@Named("registrar")
+@Stateful
+@RequestScoped
+class RegistrarBean implements Registrar
+{
+ private
+ @PersistenceContext
+ EntityManager em;
+
+ private
+ @Current
+ StatusMessages statusMessages;
+
+ private
+ @Current
+ RegistrationFormControls formControls;
+
+ private User newUser;
+
+ private String confirmPassword;
+
+ private boolean registered;
+
+ private boolean registrationInvalid;
+
+ public void register()
+ {
+ if (verifyPasswordsMatch() && verifyUsernameIsAvailable())
+ {
+ em.persist(newUser);
+ registered = true;
+ statusMessages.add("You have been successfully registered as the user {0}!", newUser.getUsername());
+ }
+ else
+ {
+ registrationInvalid = true;
+ }
+ }
+
+ public boolean isRegistrationInvalid()
+ {
+ return registrationInvalid;
+ }
+
+ // TODO it would be nice to move the conditional to the UI but <f:event> doesn't support if=""
+ public void notifyIfRegistrationIsInvalid(boolean validationFailed)
+ {
+ if (validationFailed || registrationInvalid)
+ {
+ statusMessages.add(StatusMessage.Severity.WARN, "Invalid registration. Please correct the errors and try again.");
+ }
+ }
+
+ public
+ @Produces
+ @Named
+ @RequestScoped
+ User getNewUser()
+ {
+ newUser = new User();
+ return newUser;
+ }
+
+ public boolean isRegistered()
+ {
+ return registered;
+ }
+
+ public String getConfirmPassword()
+ {
+ return confirmPassword;
+ }
+
+ public void setConfirmPassword(String password)
+ {
+ this.confirmPassword = password;
+ }
+
+ /**
+ * Verify that the same password is entered twice.
+ */
+ private boolean verifyPasswordsMatch()
+ {
+ if (!newUser.getPassword().equals(confirmPassword))
+ {
+ statusMessages.addToControl(formControls.getConfirmPasswordControlId(), "Passwords do not match. Please re-type your password.");
+ confirmPassword = null;
+ return false;
+ }
+
+ return true;
+ }
+
+ private boolean verifyUsernameIsAvailable()
+ {
+ User existing = em.find(User.class, newUser.getUsername());
+ if (existing != null)
+ {
+ statusMessages.addToControl(formControls.getUsernameControlId(), "The username '{0}' is already taken. Please choose another username.", newUser.getUsername());
+ return false;
+ }
+
+ return true;
+ }
+
+ @PreDestroy
+ public void destroy()
+ {
+ }
+}
Modified: examples/trunk/booking/pom.xml
===================================================================
--- examples/trunk/booking/pom.xml 2009-04-29 23:56:18 UTC (rev 10728)
+++ examples/trunk/booking/pom.xml 2009-04-30 07:48:46 UTC (rev 10729)
@@ -24,6 +24,7 @@
<build>
<defaultGoal>package</defaultGoal>
<pluginManagement>
+
<plugins>
<!-- version matrix or parent? -->
Modified: examples/trunk/booking/war/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- examples/trunk/booking/war/src/main/webapp/WEB-INF/faces-config.xml 2009-04-29 23:56:18 UTC (rev 10728)
+++ examples/trunk/booking/war/src/main/webapp/WEB-INF/faces-config.xml 2009-04-30 07:48:46 UTC (rev 10729)
@@ -9,8 +9,8 @@
<navigation-case>
<from-action>#{bookingAgent.cancel}</from-action>
+ <if>#{true}</if>
<to-view-id>/main.xhtml</to-view-id>
- <if>#{true}</if>
<redirect/>
</navigation-case>
@@ -23,22 +23,22 @@
<!--
<navigation-case>
<from-action>#{hotelSearch.find}</from-action>
+ <if>#{true}</if>
<to-view-id>/main.xhtml</to-view-id>
- <if>#{true}</if>
<redirect/>
</navigation-case>
<navigation-case>
<from-action>#{hotelSearch.nextPage}</from-action>
+ <if>#{true}</if>
<to-view-id>/main.xhtml</to-view-id>
- <if>#{true}</if>
<redirect/>
</navigation-case>
-->
<navigation-case>
<from-action>#{bookingAgent.selectHotel(_hotel)}</from-action>
+ <if>#{bookingAgent.hotelSelection != null}</if>
<to-view-id>/hotel.xhtml</to-view-id>
- <if>#{bookingAgent.hotelSelection != null}</if>
<redirect/>
</navigation-case>
@@ -49,8 +49,8 @@
<navigation-case>
<from-action>#{bookingAgent.bookHotel}</from-action>
+ <if>#{bookingAgent.booking != null}</if>
<to-view-id>/book.xhtml</to-view-id>
- <if>#{bookingAgent.booking != null}</if>
<redirect/>
</navigation-case>
@@ -61,8 +61,8 @@
<navigation-case>
<from-action>#{bookingAgent.validateBooking}</from-action>
+ <if>#{bookingAgent.bookingValid}</if>
<to-view-id>/confirm.xhtml</to-view-id>
- <if>#{bookingAgent.bookingValid}</if>
<redirect/>
</navigation-case>
@@ -73,11 +73,23 @@
<navigation-case>
<from-action>#{bookingAgent.confirm}</from-action>
+ <if>#{true}</if>
<to-view-id>/main.xhtml</to-view-id>
- <if>#{true}</if>
<redirect/>
</navigation-case>
</navigation-rule>
+ <navigation-rule>
+ <from-view-id>/register.xhtml</from-view-id>
+
+ <navigation-case>
+ <from-action>#{registrar.register}</from-action>
+ <if>#{registrar.registered}</if>
+ <to-view-id>/account.xhtml</to-view-id>
+ <!--<redirect/> disabled until messages can be kept over redirect -->
+ </navigation-case>
+
+ </navigation-rule>
+
</faces-config>
Added: examples/trunk/booking/war/src/main/webapp/WEB-INF/fragments/account.xhtml
===================================================================
--- examples/trunk/booking/war/src/main/webapp/WEB-INF/fragments/account.xhtml (rev 0)
+++ examples/trunk/booking/war/src/main/webapp/WEB-INF/fragments/account.xhtml 2009-04-30 07:48:46 UTC (rev 10729)
@@ -0,0 +1,12 @@
+<!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/property">
+
+ <p:display label="Username" value="#{user.username}"/>
+ <p:display label="Real name" value="#{user.name}"/>
+
+</ui:composition>
Added: examples/trunk/booking/war/src/main/webapp/WEB-INF/fragments/user.xhtml
===================================================================
--- examples/trunk/booking/war/src/main/webapp/WEB-INF/fragments/user.xhtml (rev 0)
+++ examples/trunk/booking/war/src/main/webapp/WEB-INF/fragments/user.xhtml 2009-04-30 07:48:46 UTC (rev 10729)
@@ -0,0 +1,21 @@
+<!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/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="Nightly rate" override="true">
+ <h:outputText value="#{hotel.price}">
+ <f:convertNumber type="currency" currencySymbol="$"/>
+ </h:outputText>
+ </p:display>
+
+</ui:composition>
Modified: examples/trunk/booking/war/src/main/webapp/WEB-INF/layout/template.xhtml
===================================================================
--- examples/trunk/booking/war/src/main/webapp/WEB-INF/layout/template.xhtml 2009-04-29 23:56:18 UTC (rev 10728)
+++ examples/trunk/booking/war/src/main/webapp/WEB-INF/layout/template.xhtml 2009-04-30 07:48:46 UTC (rev 10729)
@@ -4,6 +4,9 @@
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"><ui:remove><!-- Using <f:view> as the root prevents conversation from propagating correctly--></ui:remove>
+ <f:facet name="metadata">
+ <ui:insert name="pageMetadata"/>
+ </f:facet>
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>JBoss Suites: Seam Framework</title>
@@ -11,7 +14,7 @@
<link href="#{request.contextPath}/css/screen.css" rel="stylesheet" type="text/css"/>
<ui:insert name="head"/>
</h:head>
- <h:body>
+ <h:body styleClass="#{empty pageClass ? 'page' : 'home'}">
<div id="document">
<div id="header">
<div id="title"><h:graphicImage value="/img/hdr.title.gif" alt="JBoss Suites: seam framework demo"/></div>
Added: examples/trunk/booking/war/src/main/webapp/account.xhtml
===================================================================
--- examples/trunk/booking/war/src/main/webapp/account.xhtml (rev 0)
+++ examples/trunk/booking/war/src/main/webapp/account.xhtml 2009-04-30 07:48:46 UTC (rev 10729)
@@ -0,0 +1,49 @@
+<!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"
+ template="/WEB-INF/layout/template.xhtml">
+
+ <ui:define name="content">
+
+ <div class="section">
+ <h1>Your Account</h1>
+ </div>
+
+ <div class="section">
+
+ <div class="errors">
+ <h:messages id="messages" globalOnly="true"/>
+ </div>
+
+ <ui:include src="/WEB-INF/fragments/account.xhtml"/>
+
+ <div class="buttonBox">
+ <h:button id="changePassword" value="Change password" outcome="/password.xhtml"/>
+ </div>
+ </div>
+
+ </ui:define>
+
+ <ui:define name="sidebar">
+
+ <h1>Producing variables</h1>
+ <p>
+ You shouldn't need to write accessor methods (getters and setters) on a backing bean just to get at your data.
+ Rather, you should be able to expose data as a top-level variable. The logic necessary to load the data should
+ be produced on demand. That's the role of a @Producer method on a bean, which you can leverage in a Seam
+ application. Here, the user's account is loaded into the session as the variable 'user' when this page is
+ accessed. Once the variable has been produced, it doesn't need to happen again, another cycle-saving benefit of
+ this pattern.
+ </p>
+ <p>
+ <a href="#" onclick="window.open('exp/FIXME.html','exp','width=752,height=500,scrollbars=yes');">
+ What happens when this page loads?
+ </a>
+ </p>
+
+ </ui:define>
+
+</ui:composition>
Modified: examples/trunk/booking/war/src/main/webapp/book.xhtml
===================================================================
--- examples/trunk/booking/war/src/main/webapp/book.xhtml 2009-04-29 23:56:18 UTC (rev 10728)
+++ examples/trunk/booking/war/src/main/webapp/book.xhtml 2009-04-30 07:48:46 UTC (rev 10729)
@@ -13,7 +13,7 @@
</div>
<div class="section">
- <div class="entry errors">
+ <div class="errors">
<h:messages id="messages" globalOnly="true"/>
</div>
@@ -21,17 +21,17 @@
<div style="clear: both;"/>
- <h:form id="booking">
+ <h:form id="bookingForm">
<fieldset>
<p:edit id="checkinDate" label="Check-in date">
- <h:inputText id="input" value="#{booking.checkinDate}">
+ <h:inputText id="input" value="#{booking.checkinDate}" binding="#{bookingFormControls.checkinDate}">
<f:convertDateTime type="date" pattern="MM/dd/yyyy"/>
</h:inputText>
</p:edit>
<p:edit id="checkoutDate" label="Check-out date">
- <h:inputText id="input" value="#{booking.checkoutDate}">
+ <h:inputText id="input" value="#{booking.checkoutDate}" binding="#{bookingFormControls.checkoutDate}">
<f:convertDateTime type="date" pattern="MM/dd/yyyy"/>
</h:inputText>
</p:edit>
@@ -99,15 +99,15 @@
<h1>Workspace management</h1>
<p>
- As you can see, Seam makes it easy to work in multiple windows or
- multiple browser tabs. But you can even switch between multiple tasks
- inside a single browser tab! The "Workspaces" section showcases this
- advanced feature.
+ As you can see, Seam makes it easy to work in multiple windows or multiple browser tabs. But you can even
+ switch between multiple tasks inside a single browser tab! The "Workspaces" section showcases this advanced
+ feature.
</p>
<p>
<a href="#" onclick="window.open('exp/workspaceExp.html','exp','width=752,height=500,scrollbars=yes');">
How does the workspace list work?
</a>
+
</p>
</ui:define>
Modified: examples/trunk/booking/war/src/main/webapp/confirm.xhtml
===================================================================
--- examples/trunk/booking/war/src/main/webapp/confirm.xhtml 2009-04-29 23:56:18 UTC (rev 10728)
+++ examples/trunk/booking/war/src/main/webapp/confirm.xhtml 2009-04-30 07:48:46 UTC (rev 10729)
@@ -28,7 +28,7 @@
<p:display label="Credit card #" value="#{booking.creditCard}"/>
<div class="buttonBox">
- <h:form id="confirm">
+ <h:form id="confirmForm">
<h:commandButton id="confirm" value="Confirm" action="#{bookingAgent.confirm}"/>
#{' '}
<h:button id="revise" value="Revise" outcome="/book.xhtml">
Modified: examples/trunk/booking/war/src/main/webapp/css/screen.css
===================================================================
--- examples/trunk/booking/war/src/main/webapp/css/screen.css 2009-04-29 23:56:18 UTC (rev 10728)
+++ examples/trunk/booking/war/src/main/webapp/css/screen.css 2009-04-30 07:48:46 UTC (rev 10729)
@@ -33,13 +33,13 @@
border: 1px solid #C3BBB6;
padding: 4px;
margin: 5px 0;
- background: #fff url(../img/input.bg.gif) 0 0 repeat-x;
+ background: #FFFFFF url(../img/input.bg.gif) 0 0 repeat-x;
}
select {
border: 1px solid #C3BBB6;
- padding: 4px;
+ padding: 1px;
margin: 5px 0;
- background: #fff url(../img/input.bg.gif) 0 0 repeat-x;
+ background: #FFFFFF url(../img/input.bg.gif) 0 0 repeat-x;
}
ol, ul {
margin: 10px 0px 10px 6px;
@@ -54,7 +54,7 @@
----------------------------------------------- */
#document {
padding: 0 1px;
- background: #fff url(../img/bg.gif) 0 0 repeat-y;
+ background: #FFFFFF url(../img/bg.gif) 0 0 repeat-y;
float: left;
border-bottom: 1px solid #C3BBB6;
}
@@ -81,7 +81,7 @@
width: 548px;
margin-top: 75px;
padding-top: 5px;
- background: #fff url(../img/cnt.bg.gif) 0 0 repeat-x;
+ background: #FFFFFF url(../img/cnt.bg.gif) 0 0 repeat-x;
}
#footer {
clear: both;
@@ -89,19 +89,20 @@
float: left;
padding: 20px;
border-top: 1px solid #C3BBB6;
- background-color: #fff;
+ background-color: #FFFFFF;
width: 718px;
text-align: right;
}
/* General
----------------------------------------------- */
-input[type="submit"], input[type="button"] {
+input[type=submit], input[type=button] {
font-weight: bold;
- color: #fff;
+ color: #FFFFFF;
border: 1px solid #5D1414;
height: 26px;
- background: #fff url(../img/btn.bg.gif) 0 0 repeat-x;
+ background: #FFFFFF url(../img/btn.bg.gif) 0 0 repeat-x;
border-style: none;
+ cursor: pointer;
}
.center {
text-align: center;
@@ -117,6 +118,9 @@
width: 160px;
text-align: right;
}
+.entry input {
+ margin: 0;
+}
.entry .input, .entry .output, .entry .error {
float: right;
width: 350px;
@@ -135,8 +139,8 @@
.errors {
font-size: small;
font-weight: bold;
- text-align: center;
- color: #600;
+ /*text-align: center;*/
+ color: #600000;
}
.errors div {
text-align: left;
@@ -145,11 +149,18 @@
text-align: left;
}
.errors input {
- border: 1px solid #600;
+ border: 1px solid #600000;
}
.errors ul {
list-style: none;
}
+#messages {
+ margin-left: 1px;
+ margin-bottom: 20px;
+}
+#messages li {
+ margin-left: 0;
+}
.buttonBox {
text-align: center;
padding: 5px 0;
@@ -205,7 +216,7 @@
}
#content table thead th {
border-left: 1px solid #D2C9C4;
- background: #fff url(../img/th.bg.gif) 0 100% repeat-x;
+ background: #FFFFFF url(../img/th.bg.gif) 0 100% repeat-x;
border-bottom: 1px solid #D2C9C4;
padding: 6px;
text-align: left;
@@ -260,12 +271,17 @@
}
/* Homepage Modifications
----------------------------------------------- */
-#pgHome #container {
+body.home #container {
background: url(../img/hdr.ad.jpg) 0 0 repeat-x;
}
-#pgHome #sidebar {
+body.home #sidebar {
margin-top: 207px;
}
-#pgHome #content {
+body.home #content {
margin-top: 183px;
}
+/* Extras
+----------------------------------------------- */
+#javax_faces_developmentstage_messages {
+ display: none;
+}
Modified: examples/trunk/booking/war/src/main/webapp/home.xhtml
===================================================================
--- examples/trunk/booking/war/src/main/webapp/home.xhtml 2009-04-29 23:56:18 UTC (rev 10728)
+++ examples/trunk/booking/war/src/main/webapp/home.xhtml 2009-04-30 07:48:46 UTC (rev 10729)
@@ -1,87 +1,73 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml"
+<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:f="http://java.sun.com/jsf/core">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
- <title>JBoss Suites: Seam Framework</title>
- <link rel="shortcut icon" href="#{request.contextPath}/favicon.ico"/>
- <link href="#{request.contextPath}/css/screen.css" rel="stylesheet" type="text/css"/>
- </head>
- <body id="pgHome">
- <f:view>
- <div id="document">
- <div id="header">
- <div id="title"><h:graphicImage value="/img/hdr.title.gif" alt="JBoss Suites: seam framework demo"/></div>
+ template="/WEB-INF/layout/template.xhtml">
+
+ <ui:param name="pageClass" value="home"/>
+
+ <ui:define name="content">
+ <div class="section">
+
+ <h1>About this example application</h1>
+
+ <p>
+ This sample application demonstrates how easy it is to develop stateful web applications using JBoss Seam.
+ Just register, login, and book a room to see Seam in action. Throughout the application you'll see popup
+ links like the ones at the bottom of this page. Click them to see how the application works under the hood.
+ </p>
+
+ <p>
+ Note: Please do NOT enter personal information or your credit card number in this sample application.
+ </p>
+
+ <p>
+ <a href="#" onclick="window.open('exp/introExp.html','exp','width=752,height=500,scrollbars=yes');">
+ What is Seam?
+ </a>
+ </p>
+
+ <p>
+ <a href="#" onclick="window.open('exp/loginExp.html','exp','width=752,height=500,scrollbars=yes');">
+ What happens when I login?
+ </a>
+ </p>
+
+ </div>
+ </ui:define>
+
+ <ui:define name="sidebar">
+ <h:form id="login">
+ <fieldset>
+ <ui:remove>
+ <div>
+ <h:outputLabel id="UsernameLabel" for="username">Login Name</h:outputLabel>
+ <h:inputText id="username" value="#{identity.username}" style="width: 175px;"/>
+ <div class="errors"><h:message id="UsernameMessage" for="username"/></div>
</div>
- <div id="container">
- <div id="sidebar">
- <h:link id="search" outcome="/main.xhtml" value="Search"/>
- <ui:remove>
- <h:form id="login">
- <fieldset>
- <div>
- <h:outputLabel id="UsernameLabel" for="username">Login Name</h:outputLabel>
- <h:inputText id="username" value="#{identity.username}" style="width: 175px;"/>
- <div class="errors"><h:message id="UsernameMessage" for="username"/></div>
- </div>
- <div>
- <h:outputLabel id="PasswordLabel" for="password">Password</h:outputLabel>
- <h:inputSecret id="password" value="#{identity.password}" style="width: 175px;"/>
- </div>
- <div class="errors"><h:messages id="messages" globalOnly="true"/></div>
- <div class="buttonBox"><h:commandButton id="login" action="#{identity.login}" value="Account Login"/></div>
- <div class="notes"><!--<h:link id="register" outcome="/register.xhtml" value="Register New User"/>--></div>
- <div class="subnotes">
- Or use a demo account:
- <ul>
- <li>gavin/mexico</li>
- <li>pete/edinburgh</li>
- <li>shane/brisbane</li>
- <li>dan/maryland</li>
- </ul>
- </div>
- </fieldset>
- </h:form>
- </ui:remove>
- </div>
- <div id="content">
- <div class="section">
-
- <h1>About this example application</h1>
-
- <p>
- This sample application demonstrates how easy it is to develop stateful web
- applications using JBoss Seam. Just register, login, and book a room to see
- Seam in action. Throughout the application you'll see popup links like
- the ones at the bottom of this page. Click them to see how the application
- works under the hood.
- </p>
-
- <p>
- Note: Please do NOT enter personal information or your credit card number in
- this sample application.
- </p>
-
- <p>
- <a href="#" onclick="window.open('exp/introExp.html','exp','width=752,height=500,scrollbars=yes');">
- What is JBoss Seam?
- </a>
- </p>
-
- <p>
- <a href="#" onclick="window.open('exp/loginExp.html','exp','width=752,height=500,scrollbars=yes');">
- What happens when I login?
- </a>
- </p>
-
- </div>
- </div>
+ <div>
+ <h:outputLabel id="PasswordLabel" for="password">Password</h:outputLabel>
+ <h:inputSecret id="password" value="#{identity.password}" style="width: 175px;"/>
</div>
- <div id="footer">Created with Seam 3.0, Web Beans, EJB 3.0 and JSF 2.0</div>
- </div>
- </f:view>
- </body>
-</html>
+ <div class="errors"><h:messages id="messages" globalOnly="true"/></div>
+ <div class="buttonBox"><h:commandButton id="login" action="#{identity.login}" value="Account Login"/></div>
+ </ui:remove>
+ <div class="notes"><h:link id="register" outcome="/register.xhtml" value="Register New User"/></div>
+ <ui:remove>
+ <div class="subnotes">
+ Or use a demo account:
+ <ul>
+ <li>gavin/mexico</li>
+ <li>pete/edinburgh</li>
+ <li>shane/brisbane</li>
+ <li>dan/maryland</li>
+ </ul>
+ </div>
+ </ui:remove>
+ </fieldset>
+ </h:form>
+ </ui:define>
+
+</ui:composition>
Added: examples/trunk/booking/war/src/main/webapp/password.xhtml
===================================================================
--- examples/trunk/booking/war/src/main/webapp/password.xhtml (rev 0)
+++ examples/trunk/booking/war/src/main/webapp/password.xhtml 2009-04-30 07:48:46 UTC (rev 10729)
@@ -0,0 +1,62 @@
+<!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/property"
+ template="/WEB-INF/layout/template.xhtml">
+
+ <ui:define name="content">
+
+ <div class="section">
+ <h1>Change Your Password</h1>
+ </div>
+
+ <div class="section">
+
+ <div class="errors">
+ <h:messages id="messages" globalOnly="true"/>
+ </div>
+
+ <h:form id="changePasswordForm">
+
+ <fieldset>
+
+ <p:edit id="password" label="Password">
+ <h:inputSecret id="password" value="#{user.password}" redisplay="true"/>
+ </p:edit>
+
+ <p:edit id="confirmPassword" label="Confirm password">
+ <h:inputSecret id="password" value="#{passwordManager.confirmPassword}" redisplay="true"
+ binding="#{registrationFormControls.confirmPassword}"/>
+ </p:edit>
+
+ <div class="buttonBox">
+ <h:commandButton id="change" value="Change" action="#{passwordManager.changePassword}"/>
+ #{' '}
+ <h:button id="cancel" value="Cancel" outcome="/main.xhtml"/>
+ </div>
+
+ </fieldset>
+
+ </h:form>
+ </div>
+
+</ui:define>
+
+ <ui:define name="sidebar">
+
+ <h1>Simple things should be easy</h1>
+ <p>
+ (And so should some complex things.) You shouldn't have to write four different classes just to change a
+ password. Traditional J2EE architectures require that developers spend more time writing code to make the
+ frameworks happy, than they ever get to spend writing code to make the user happy. Seam lets you reduce the
+ size of your code dramatically. And that reduces bugs. And it makes refactoring easier. And it makes
+ delivering new functionality quicker. Productivity matters. But with Seam, JSF, EJB 3.0 and jBPM, you don't
+ need to sacrifice the ability to handle complex problems just to achieve great productivity.
+ </p>
+
+ </ui:define>
+
+</ui:composition>
Added: examples/trunk/booking/war/src/main/webapp/register.xhtml
===================================================================
--- examples/trunk/booking/war/src/main/webapp/register.xhtml (rev 0)
+++ examples/trunk/booking/war/src/main/webapp/register.xhtml 2009-04-30 07:48:46 UTC (rev 10729)
@@ -0,0 +1,90 @@
+<!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/property"
+ template="/WEB-INF/layout/template.xhtml">
+
+ <ui:param name="pageClass" value="home"/>
+
+ <ui:define name="pageMetadata">
+ <f:event type="preRenderView" listener="#{registrar.notifyIfRegistrationIsInvalid(facesContext.validationFailed)}"/>
+ </ui:define>
+
+ <ui:define name="content">
+
+ <div class="section">
+ <h1>Register</h1>
+ </div>
+
+ <div class="section">
+
+ <div class="errors">
+ <h:messages id="messages" globalOnly="true"/>
+ </div>
+
+ <h:form id="registrationForm">
+
+ <fieldset>
+
+ <p:edit id="username" label="Username">
+ <h:inputText id="input" value="#{newUser.username}"
+ binding="#{registrationFormControls.username}">
+ <ui:remove><f:ajax event="blur" render="username"/></ui:remove>
+ </h:inputText>
+ </p:edit>
+
+ <p:edit id="name" label="Real name">
+ <h:inputText id="input" value="#{newUser.name}">
+ <ui:remove><f:ajax event="blur" render="name"/></ui:remove>
+ </h:inputText>
+ </p:edit>
+
+ <p:edit id="password" label="Password">
+ <h:inputSecret id="input" value="#{newUser.password}" redisplay="true">
+ <ui:remove><f:ajax event="blur" render="password"/></ui:remove>
+ </h:inputSecret>
+ </p:edit>
+
+ <p:edit id="confirmPassword" label="Confirm Password">
+ <h:inputSecret id="input" value="#{registrar.confirmPassword}" redisplay="true"
+ binding="#{registrationFormControls.confirmPassword}">
+ <ui:remove><f:ajax event="blur" render="confirmPassword"/></ui:remove>
+ </h:inputSecret>
+ </p:edit>
+
+ <div class="buttonBox">
+ <h:commandButton id="register" value="Register" action="#{registrar.register}"/>
+ #{' '}
+ <h:button id="cancel" value="Cancel" outcome="/home.xhtml"/>
+ </div>
+
+ </fieldset>
+ </h:form>
+
+ </div>
+
+ </ui:define>
+
+ <ui:define name="sidebar">
+
+ <h1>Integrated multi-layer validation</h1>
+ <p>
+ Robust applications need data validation in several different places. Seam integrates Hibernate Validator, a
+ set of annotations for expressing data model constraints in your domain model classes. Then, these constraints
+ are applied almost completely transparently at three levels of the application: by Seam when the user first
+ enters data, by EJB before persisting data to the database, and, if you use Hibernate to generate your database
+ schema, by the database constraints themselves. Multi-layer validation hardens your application and protects
+ your data. Even better, it's self-documenting, and easy to change when your business rules change.
+ </p>
+ <p>
+ <a href="#" onclick="window.open('exp/registerExp.html','exp','width=752,height=500,scrollbars=yes');">
+ What happens when I register?
+ </a>
+ </p>
+
+ </ui:define>
+
+</ui:composition>
15 years, 6 months
Seam SVN: r10728 - in modules/trunk/security/src/main/java/org/jboss/seam/security: management and 1 other directory.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-04-29 19:56:18 -0400 (Wed, 29 Apr 2009)
New Revision: 10728
Modified:
modules/trunk/security/src/main/java/org/jboss/seam/security/Identity.java
modules/trunk/security/src/main/java/org/jboss/seam/security/management/IdentityManagementException.java
modules/trunk/security/src/main/java/org/jboss/seam/security/management/IdentityStore.java
modules/trunk/security/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java
modules/trunk/security/src/main/java/org/jboss/seam/security/management/LdapIdentityStore.java
modules/trunk/security/src/main/java/org/jboss/seam/security/management/NoSuchRoleException.java
modules/trunk/security/src/main/java/org/jboss/seam/security/management/NoSuchUserException.java
Log:
get JpaIdentityStore compiling, fixed other warnings
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/Identity.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/Identity.java 2009-04-29 23:00:22 UTC (rev 10727)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/Identity.java 2009-04-29 23:56:18 UTC (rev 10728)
@@ -26,8 +26,6 @@
import javax.security.auth.login.LoginContext;
import javax.security.auth.login.LoginException;
-import org.jboss.webbeans.log.LogProvider;
-import org.jboss.webbeans.log.Logging;
import org.jboss.seam.security.callbacks.AuthenticatorCallback;
import org.jboss.seam.security.callbacks.IdentityCallback;
import org.jboss.seam.security.callbacks.IdentityManagerCallback;
@@ -42,6 +40,8 @@
import org.jboss.seam.security.events.QuietLoginEvent;
import org.jboss.seam.security.management.IdentityManager;
import org.jboss.seam.security.permission.PermissionMapper;
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
/**
* API for authorization and authentication via Seam security.
@@ -570,7 +570,7 @@
}
}
- public void filterByPermission(Collection collection, String action)
+ public void filterByPermission(Collection<?> collection, String action)
{
permissionMapper.filterByPermission(collection, action);
}
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/management/IdentityManagementException.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/management/IdentityManagementException.java 2009-04-29 23:00:22 UTC (rev 10727)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/management/IdentityManagementException.java 2009-04-29 23:56:18 UTC (rev 10728)
@@ -7,6 +7,8 @@
*/
public class IdentityManagementException extends RuntimeException
{
+ private static final long serialVersionUID = -8682163627028954352L;
+
public IdentityManagementException(String message)
{
super(message);
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/management/IdentityStore.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/management/IdentityStore.java 2009-04-29 23:00:22 UTC (rev 10727)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/management/IdentityStore.java 2009-04-29 23:56:18 UTC (rev 10728)
@@ -6,7 +6,7 @@
import java.util.Set;
/**
- * The identity store does the actual work of persisting user accounts in a
+ * The identity store does the actual work of persisting user accounts and roles in a
* database, LDAP directory, etc.
*
* @author Shane Bryzak
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java 2009-04-29 23:00:22 UTC (rev 10727)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java 2009-04-29 23:56:18 UTC (rev 10728)
@@ -13,14 +13,14 @@
import javax.annotation.Named;
import javax.context.ApplicationScoped;
-import javax.event.Observes;
import javax.inject.Current;
import javax.inject.Initializer;
-import javax.inject.manager.Bean;
import javax.inject.manager.Manager;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
+import org.jboss.seam.security.Role;
+import org.jboss.seam.security.SimplePrincipal;
import org.jboss.seam.security.annotations.management.PasswordSalt;
import org.jboss.seam.security.annotations.management.RoleConditional;
import org.jboss.seam.security.annotations.management.RoleGroups;
@@ -31,19 +31,15 @@
import org.jboss.seam.security.annotations.management.UserPassword;
import org.jboss.seam.security.annotations.management.UserPrincipal;
import org.jboss.seam.security.annotations.management.UserRoles;
-import org.jboss.webbeans.log.LogProvider;
-import org.jboss.webbeans.log.Logging;
-import org.jboss.seam.security.Identity;
-import org.jboss.seam.security.Role;
-import org.jboss.seam.security.SimplePrincipal;
import org.jboss.seam.security.crypto.BinTools;
-import org.jboss.seam.security.events.PostAuthenticateEvent;
import org.jboss.seam.security.events.PrePersistUserEvent;
import org.jboss.seam.security.events.PrePersistUserRoleEvent;
import org.jboss.seam.security.events.UserAuthenticatedEvent;
import org.jboss.seam.security.events.UserCreatedEvent;
import org.jboss.seam.security.util.AnnotatedBeanProperty;
import org.jboss.seam.security.util.TypedBeanProperty;
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
/**
* The default identity store implementation, uses JPA as its persistence mechanism.
@@ -54,19 +50,18 @@
@ApplicationScoped
public class JpaIdentityStore implements IdentityStore, Serializable
{
+ private static final long serialVersionUID = 1171875389743972646L;
+
private static final LogProvider log = Logging.getLogProvider(JpaIdentityStore.class);
protected FeatureSet featureSet;
-
- private ValueExpression<EntityManager> entityManager;
- private Bean<EntityManager> entityManagerBean;
-
+
@Current Manager manager;
@Current PasswordHash passwordHash;
- private Class<?> userClass;
- private Class<?> roleClass;
- private Class<?> xrefClass;
+ private Class<?> userEntityClass;
+ private Class<?> roleEntityClass;
+ private Class<?> xrefEntityClass;
private TypedBeanProperty xrefUserProperty;
private TypedBeanProperty xrefRoleProperty;
@@ -103,15 +98,10 @@
{
featureSet = new FeatureSet();
featureSet.enableAll();
- }
+ }
- if (entityManager == null)
+ if (userEntityClass == null)
{
- entityManager = Expressions.instance().createValueExpression("#{entityManager}", EntityManager.class);
- }
-
- if (userClass == null)
- {
log.error("Error in JpaIdentityStore configuration - userClass must be configured.");
return;
}
@@ -121,35 +111,35 @@
private void initProperties()
{
- userPrincipalProperty = new AnnotatedBeanProperty<UserPrincipal>(userClass, UserPrincipal.class);
- userPasswordProperty = new AnnotatedBeanProperty<UserPassword>(userClass, UserPassword.class);
- passwordSaltProperty = new AnnotatedBeanProperty<PasswordSalt>(userClass, PasswordSalt.class);
- userRolesProperty = new AnnotatedBeanProperty<UserRoles>(userClass, UserRoles.class);
- userEnabledProperty = new AnnotatedBeanProperty<UserEnabled>(userClass, UserEnabled.class);
- userFirstNameProperty = new AnnotatedBeanProperty<UserFirstName>(userClass, UserFirstName.class);
- userLastNameProperty = new AnnotatedBeanProperty<UserLastName>(userClass, UserLastName.class);
+ userPrincipalProperty = new AnnotatedBeanProperty<UserPrincipal>(userEntityClass, UserPrincipal.class);
+ userPasswordProperty = new AnnotatedBeanProperty<UserPassword>(userEntityClass, UserPassword.class);
+ passwordSaltProperty = new AnnotatedBeanProperty<PasswordSalt>(userEntityClass, PasswordSalt.class);
+ userRolesProperty = new AnnotatedBeanProperty<UserRoles>(userEntityClass, UserRoles.class);
+ userEnabledProperty = new AnnotatedBeanProperty<UserEnabled>(userEntityClass, UserEnabled.class);
+ userFirstNameProperty = new AnnotatedBeanProperty<UserFirstName>(userEntityClass, UserFirstName.class);
+ userLastNameProperty = new AnnotatedBeanProperty<UserLastName>(userEntityClass, UserLastName.class);
if (!userPrincipalProperty.isSet())
{
- throw new IdentityManagementException("Invalid userClass " + userClass.getName() +
+ throw new IdentityManagementException("Invalid userClass " + userEntityClass.getName() +
" - required annotation @UserPrincipal not found on any Field or Method.");
}
if (!userRolesProperty.isSet())
{
- throw new IdentityManagementException("Invalid userClass " + userClass.getName() +
+ throw new IdentityManagementException("Invalid userClass " + userEntityClass.getName() +
" - required annotation @UserRoles not found on any Field or Method.");
}
- if (roleClass != null)
+ if (roleEntityClass != null)
{
- roleNameProperty = new AnnotatedBeanProperty<RoleName>(roleClass, RoleName.class);
- roleGroupsProperty = new AnnotatedBeanProperty<RoleGroups>(roleClass, RoleGroups.class);
- roleConditionalProperty = new AnnotatedBeanProperty<RoleConditional>(roleClass, RoleConditional.class);
+ roleNameProperty = new AnnotatedBeanProperty<RoleName>(roleEntityClass, RoleName.class);
+ roleGroupsProperty = new AnnotatedBeanProperty<RoleGroups>(roleEntityClass, RoleGroups.class);
+ roleConditionalProperty = new AnnotatedBeanProperty<RoleConditional>(roleEntityClass, RoleConditional.class);
if (!roleNameProperty.isSet())
{
- throw new IdentityManagementException("Invalid roleClass " + roleClass.getName() +
+ throw new IdentityManagementException("Invalid roleClass " + roleEntityClass.getName() +
" - required annotation @RoleName not found on any Field or Method.");
}
@@ -167,11 +157,11 @@
// If the @UserRoles property isn't a collection of <roleClass>, then assume the relationship
// is going through a cross-reference table
- if (!genType.equals(roleClass))
+ if (!genType.equals(roleEntityClass))
{
- xrefClass = (Class<?>) genType;
- xrefUserProperty = new TypedBeanProperty(xrefClass, userClass);
- xrefRoleProperty = new TypedBeanProperty(xrefClass, roleClass);
+ xrefEntityClass = (Class<?>) genType;
+ xrefUserProperty = new TypedBeanProperty(xrefEntityClass, userEntityClass);
+ xrefRoleProperty = new TypedBeanProperty(xrefEntityClass, roleEntityClass);
if (!xrefUserProperty.isSet())
{
@@ -193,7 +183,7 @@
{
try
{
- if (userClass == null)
+ if (userEntityClass == null)
{
throw new IdentityManagementException("Could not create account, userClass not set");
}
@@ -203,7 +193,7 @@
throw new IdentityManagementException("Could not create account, already exists");
}
- Object user = userClass.newInstance();
+ Object user = userEntityClass.newInstance();
userPrincipalProperty.setValue(user, username);
@@ -290,9 +280,10 @@
return true;
}
+ @SuppressWarnings("unchecked")
public boolean grantRole(String username, String role)
{
- if (roleClass == null) return false;
+ if (roleEntityClass == null) return false;
Object user = lookupUser(username);
if (user == null)
@@ -328,16 +319,16 @@
if (userRoles == null)
{
Type propType = userRolesProperty.getPropertyType();
- Class collectionType;
+ Class<?> collectionType;
- if (propType instanceof Class && Collection.class.isAssignableFrom((Class) propType))
+ if (propType instanceof Class && Collection.class.isAssignableFrom((Class<?>) propType))
{
- collectionType = (Class) propType;
+ collectionType = (Class<?>) propType;
}
else if (propType instanceof ParameterizedType &&
- Collection.class.isAssignableFrom((Class) ((ParameterizedType) propType).getRawType()))
+ Collection.class.isAssignableFrom((Class<?>) ((ParameterizedType) propType).getRawType()))
{
- collectionType = (Class) ((ParameterizedType) propType).getRawType();
+ collectionType = (Class<?>) ((ParameterizedType) propType).getRawType();
}
else
{
@@ -347,37 +338,37 @@
// This should either be a Set, or a List...
if (Set.class.isAssignableFrom(collectionType))
{
- userRoles = new HashSet();
+ userRoles = new HashSet<Object>();
}
else if (List.class.isAssignableFrom(collectionType))
{
- userRoles = new ArrayList();
+ userRoles = new ArrayList<Object>();
}
userRolesProperty.setValue(user, userRoles);
}
- else if (((Collection) userRolesProperty.getValue(user)).contains(roleToGrant))
+ else if (((Collection<?>) userRolesProperty.getValue(user)).contains(roleToGrant))
{
return false;
}
- if (xrefClass == null)
+ if (xrefEntityClass == null)
{
// If this is a Many-To-Many relationship, simply add the role
- ((Collection) userRolesProperty.getValue(user)).add(roleToGrant);
+ ((Collection<Object>) userRolesProperty.getValue(user)).add(roleToGrant);
}
else
{
// Otherwise we need to insert a cross-reference entity instance
try
{
- Object xref = xrefClass.newInstance();
+ Object xref = xrefEntityClass.newInstance();
xrefUserProperty.setValue(xref, user);
xrefRoleProperty.setValue(xref, roleToGrant);
manager.fireEvent(new PrePersistUserRoleEvent(xref));
- ((Collection) userRolesProperty.getValue(user)).add(mergeEntity(xref));
+ ((Collection<Object>) userRolesProperty.getValue(user)).add(mergeEntity(xref));
}
catch (Exception ex)
{
@@ -404,13 +395,13 @@
boolean success = false;
- if (xrefClass == null)
+ if (xrefEntityClass == null)
{
- success = ((Collection) userRolesProperty.getValue(user)).remove(roleToRevoke);
+ success = ((Collection<?>) userRolesProperty.getValue(user)).remove(roleToRevoke);
}
else
{
- Collection roles = ((Collection) userRolesProperty.getValue(user));
+ Collection<?> roles = ((Collection<?>) userRolesProperty.getValue(user));
for (Object xref : roles)
{
@@ -425,6 +416,7 @@
return success;
}
+ @SuppressWarnings("unchecked")
public boolean addRoleToGroup(String role, String group)
{
if (!roleGroupsProperty.isSet()) return false;
@@ -441,14 +433,14 @@
throw new NoSuchRoleException("Could not grant role, group '" + group + "' does not exist");
}
- Collection roleGroups = (Collection) roleGroupsProperty.getValue(targetRole);
+ Collection<?> roleGroups = (Collection<?>) roleGroupsProperty.getValue(targetRole);
if (roleGroups == null)
{
// This should either be a Set, or a List...
- Class rawType = null;
+ Class<?> rawType = null;
if (roleGroupsProperty.getPropertyType() instanceof ParameterizedType)
{
- rawType = (Class) ((ParameterizedType) roleGroupsProperty.getPropertyType()).getRawType();
+ rawType = (Class<?>) ((ParameterizedType) roleGroupsProperty.getPropertyType()).getRawType();
}
else
{
@@ -457,21 +449,21 @@
if (Set.class.isAssignableFrom(rawType))
{
- roleGroups = new HashSet();
+ roleGroups = new HashSet<Object>();
}
else if (List.class.isAssignableFrom(rawType))
{
- roleGroups = new ArrayList();
+ roleGroups = new ArrayList<Object>();
}
roleGroupsProperty.setValue(targetRole, roleGroups);
}
- else if (((Collection) roleGroupsProperty.getValue(targetRole)).contains(targetGroup))
+ else if (((Collection<?>) roleGroupsProperty.getValue(targetRole)).contains(targetGroup))
{
return false;
}
- ((Collection) roleGroupsProperty.getValue(targetRole)).add(targetGroup);
+ ((Collection<Object>) roleGroupsProperty.getValue(targetRole)).add(targetGroup);
return true;
}
@@ -492,7 +484,8 @@
throw new NoSuchRoleException("Could not remove role from group, no such group '" + group + "'");
}
- boolean success = ((Collection) roleGroupsProperty.getValue(roleToRemove)).remove(targetGroup);
+ boolean success = ((Collection<?>) roleGroupsProperty.getValue(roleToRemove)).remove(targetGroup);
+
return success;
}
@@ -500,7 +493,7 @@
{
try
{
- if (roleClass == null)
+ if (roleEntityClass == null)
{
throw new IdentityManagementException("Could not create role, roleClass not set");
}
@@ -510,7 +503,7 @@
throw new IdentityManagementException("Could not create role, already exists");
}
- Object instance = roleClass.newInstance();
+ Object instance = roleEntityClass.newInstance();
roleNameProperty.setValue(instance, role);
persistEntity(instance);
@@ -537,9 +530,9 @@
throw new NoSuchRoleException("Could not delete role, role '" + role + "' does not exist");
}
- if (xrefClass != null)
+ if (xrefEntityClass != null)
{
- lookupEntityManager().createQuery("delete " + xrefClass.getName() + " where role = :role")
+ lookupEntityManager().createQuery("delete " + xrefEntityClass.getName() + " where role = :role")
.setParameter("role", roleToDelete)
.executeUpdate();
}
@@ -566,7 +559,7 @@
{
if (!userEnabledProperty.isSet())
{
- log.debug("Can not enable user, no @UserEnabled property configured in userClass " + userClass.getName());
+ log.debug("Can not enable user, no @UserEnabled property configured in userClass " + userEntityClass.getName());
return false;
}
@@ -590,7 +583,7 @@
{
if (!userEnabledProperty.isSet())
{
- log.debug("Can not disable user, no @UserEnabled property configured in userClass " + userClass.getName());
+ log.debug("Can not disable user, no @UserEnabled property configured in userClass " + userEntityClass.getName());
return false;
}
@@ -649,12 +642,12 @@
List<String> roles = new ArrayList<String>();
- Collection userRoles = (Collection) userRolesProperty.getValue(user);
+ Collection<?> userRoles = (Collection<?>) userRolesProperty.getValue(user);
if (userRoles != null)
{
for (Object role : userRoles)
{
- if (xrefClass == null)
+ if (xrefEntityClass == null)
{
roles.add((String) roleNameProperty.getValue(role));
}
@@ -682,7 +675,7 @@
if (roleGroupsProperty.isSet())
{
- Collection roleGroups = (Collection) roleGroupsProperty.getValue(role);
+ Collection<?> roleGroups = (Collection<?>) roleGroupsProperty.getValue(role);
if (roleGroups != null)
{
for (Object group : roleGroups)
@@ -704,7 +697,7 @@
}
Set<String> roles = new HashSet<String>();
- Collection userRoles = (Collection) userRolesProperty.getValue(user);
+ Collection<?> userRoles = (Collection<?>) userRolesProperty.getValue(user);
if (userRoles != null)
{
for (Object role : userRoles)
@@ -724,7 +717,7 @@
if (roleGroupsProperty.isSet())
{
- Collection groups = (Collection) roleGroupsProperty.getValue(instance);
+ Collection<?> groups = (Collection<?>) roleGroupsProperty.getValue(instance);
if (groups != null)
{
@@ -824,32 +817,19 @@
boolean success = passwordHash.equals(userPasswordProperty.getValue(user));
if (success)
- {
- if (Contexts.isEventContextActive())
- {
- Contexts.getEventContext().set(AUTHENTICATED_USER, user);
- }
-
+ {
manager.fireEvent(new UserAuthenticatedEvent(user));
+ }
return success;
}
- public void setUserAccountForSession(@Observes PostAuthenticateEvent event)
- {
- if (Contexts.isEventContextActive() && Contexts.isSessionContextActive())
- {
- Contexts.getSessionContext().set(AUTHENTICATED_USER,
- Contexts.getEventContext().get(AUTHENTICATED_USER));
- }
- }
-
public Object lookupUser(String username)
{
try
{
Object user = lookupEntityManager().createQuery(
- "select u from " + userClass.getName() + " u where " + userPrincipalProperty.getName() +
+ "select u from " + userEntityClass.getName() + " u where " + userPrincipalProperty.getName() +
" = :username")
.setParameter("username", username)
.getSingleResult();
@@ -883,7 +863,7 @@
try
{
Object value = lookupEntityManager().createQuery(
- "select r from " + roleClass.getName() + " r where " + roleNameProperty.getName() +
+ "select r from " + roleEntityClass.getName() + " r where " + roleNameProperty.getName() +
" = :role")
.setParameter("role", role)
.getSingleResult();
@@ -896,27 +876,30 @@
}
}
+ @SuppressWarnings("unchecked")
public List<String> listUsers()
{
- return lookupEntityManager().createQuery(
- "select u." + userPrincipalProperty.getName() + " from " + userClass.getName() + " u")
+ return (List<String>) lookupEntityManager().createQuery(
+ "select u." + userPrincipalProperty.getName() + " from " + userEntityClass.getName() + " u")
.getResultList();
}
+ @SuppressWarnings("unchecked")
public List<String> listUsers(String filter)
{
- return lookupEntityManager().createQuery(
- "select u." + userPrincipalProperty.getName() + " from " + userClass.getName() +
+ return (List<String>) lookupEntityManager().createQuery(
+ "select u." + userPrincipalProperty.getName() + " from " + userEntityClass.getName() +
" u where lower(" + userPrincipalProperty.getName() + ") like :username")
.setParameter("username", "%" + (filter != null ? filter.toLowerCase() : "") +
"%")
.getResultList();
}
+ @SuppressWarnings("unchecked")
public List<String> listRoles()
{
- return lookupEntityManager().createQuery(
- "select r." + roleNameProperty.getName() + " from " + roleClass.getName() + " r").getResultList();
+ return (List<String>) lookupEntityManager().createQuery(
+ "select r." + roleNameProperty.getName() + " from " + roleEntityClass.getName() + " r").getResultList();
}
public List<Principal> listMembers(String role)
@@ -936,20 +919,21 @@
return members;
}
+ @SuppressWarnings("unchecked")
private List<String> listUserMembers(String role)
{
Object roleEntity = lookupRole(role);
- if (xrefClass == null)
+ if (xrefEntityClass == null)
{
- return lookupEntityManager().createQuery("select u." + userPrincipalProperty.getName() +
- " from " + userClass.getName() + " u where :role member of u." + userRolesProperty.getName())
+ return (List<String>) lookupEntityManager().createQuery("select u." + userPrincipalProperty.getName() +
+ " from " + userEntityClass.getName() + " u where :role member of u." + userRolesProperty.getName())
.setParameter("role", roleEntity)
.getResultList();
}
else
{
- List xrefs = lookupEntityManager().createQuery("select x from " + xrefClass.getName() + " x where x." +
+ List<?> xrefs = lookupEntityManager().createQuery("select x from " + xrefEntityClass.getName() + " x where x." +
xrefRoleProperty.getName() + " = :role")
.setParameter("role", roleEntity)
.getResultList();
@@ -967,14 +951,15 @@
}
+ @SuppressWarnings("unchecked")
private List<String> listRoleMembers(String role)
{
if (roleGroupsProperty.isSet())
{
Object roleEntity = lookupRole(role);
- return lookupEntityManager().createQuery("select r." + roleNameProperty.getName() +
- " from " + roleClass.getName() + " r where :role member of r." + roleGroupsProperty.getName())
+ return (List<String>) lookupEntityManager().createQuery("select r." + roleNameProperty.getName() +
+ " from " + roleEntityClass.getName() + " r where :role member of r." + roleGroupsProperty.getName())
.setParameter("role", roleEntity)
.getResultList();
}
@@ -982,6 +967,7 @@
return null;
}
+ @SuppressWarnings("unchecked")
public List<String> listGrantableRoles()
{
StringBuilder roleQuery = new StringBuilder();
@@ -989,7 +975,7 @@
roleQuery.append("select r.");
roleQuery.append(roleNameProperty.getName());
roleQuery.append(" from ");
- roleQuery.append(roleClass.getName());
+ roleQuery.append(roleEntityClass.getName());
roleQuery.append(" r");
if (roleConditionalProperty.isSet())
@@ -999,7 +985,7 @@
roleQuery.append(" = false");
}
- return lookupEntityManager().createQuery(roleQuery.toString()).getResultList();
+ return (List<String>) lookupEntityManager().createQuery(roleQuery.toString()).getResultList();
}
protected void persistEntity(Object entity)
@@ -1017,28 +1003,28 @@
lookupEntityManager().remove(entity);
}
- public Class getUserClass()
+ public Class<?> getUserEntityClass()
{
- return userClass;
+ return userEntityClass;
}
- public void setUserClass(Class userClass)
+ public void setUserEntityClass(Class<?> userEntityClass)
{
- this.userClass = userClass;
+ this.userEntityClass = userEntityClass;
}
- public Class getRoleClass()
+ public Class<?> getRoleEntityClass()
{
- return roleClass;
+ return roleEntityClass;
}
- public void setRoleClass(Class roleClass)
+ public void setRoleEntityClass(Class<?> roleEntityClass)
{
- this.roleClass = roleClass;
+ this.roleEntityClass = roleEntityClass;
}
private EntityManager lookupEntityManager()
{
- return entityManager.getValue();
+ return manager.getInstanceByType(EntityManager.class);
}
}
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/management/LdapIdentityStore.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/management/LdapIdentityStore.java 2009-04-29 23:00:22 UTC (rev 10727)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/management/LdapIdentityStore.java 2009-04-29 23:56:18 UTC (rev 10728)
@@ -627,7 +627,7 @@
roleFilter.append(")");
- NamingEnumeration answer = ctx.search(getUserContextDN(), roleFilter.toString(), filterArgs, controls);
+ NamingEnumeration<?> answer = ctx.search(getUserContextDN(), roleFilter.toString(), filterArgs, controls);
while (answer.hasMore())
{
SearchResult sr = (SearchResult) answer.next();
@@ -678,7 +678,7 @@
String roleFilter = "(&(" + getObjectClassAttribute() + "={0})(" + getRoleNameAttribute() + "={1}))";
Object[] filterArgs = { getRoleObjectClasses(), role};
- NamingEnumeration answer = ctx.search(getRoleContextDN(), roleFilter, filterArgs, controls);
+ NamingEnumeration<?> answer = ctx.search(getRoleContextDN(), roleFilter, filterArgs, controls);
while (answer.hasMore())
{
SearchResult sr = (SearchResult) answer.next();
@@ -864,7 +864,7 @@
controls.setTimeLimit(getSearchTimeLimit());
Object[] filterArgs = {name};
- NamingEnumeration answer = ctx.search(getUserContextDN(), userFilter, filterArgs, controls);
+ NamingEnumeration<?> answer = ctx.search(getUserContextDN(), userFilter, filterArgs, controls);
while (answer.hasMore())
{
SearchResult sr = (SearchResult) answer.next();
@@ -1057,7 +1057,7 @@
filterArgs[i] = getRoleObjectClasses()[i];
}
- NamingEnumeration answer = ctx.search( getRoleContextDN(), roleFilter.toString(),
+ NamingEnumeration<?> answer = ctx.search( getRoleContextDN(), roleFilter.toString(),
filterArgs, controls);
while (answer.hasMore())
{
@@ -1094,7 +1094,6 @@
public List<String> listGrantableRoles()
{
- // TODO should we support conditional roles with LDAP?
return listRoles();
}
@@ -1134,7 +1133,7 @@
userFilter.append(")");
- NamingEnumeration answer = ctx.search(getUserContextDN(), userFilter.toString(), filterArgs, controls);
+ NamingEnumeration<?> answer = ctx.search(getUserContextDN(), userFilter.toString(), filterArgs, controls);
while (answer.hasMore())
{
SearchResult sr = (SearchResult) answer.next();
@@ -1205,7 +1204,7 @@
filterArgs[i] = getUserObjectClasses()[i];
}
- NamingEnumeration answer = ctx.search(getUserContextDN(), userFilter.toString(), filterArgs, controls);
+ NamingEnumeration<?> answer = ctx.search(getUserContextDN(), userFilter.toString(), filterArgs, controls);
while (answer.hasMore())
{
SearchResult sr = (SearchResult) answer.next();
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/management/NoSuchRoleException.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/management/NoSuchRoleException.java 2009-04-29 23:00:22 UTC (rev 10727)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/management/NoSuchRoleException.java 2009-04-29 23:56:18 UTC (rev 10728)
@@ -7,6 +7,8 @@
*/
public class NoSuchRoleException extends RuntimeException
{
+ private static final long serialVersionUID = 7711431103948571607L;
+
public NoSuchRoleException(String message)
{
super(message);
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/management/NoSuchUserException.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/management/NoSuchUserException.java 2009-04-29 23:00:22 UTC (rev 10727)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/management/NoSuchUserException.java 2009-04-29 23:56:18 UTC (rev 10728)
@@ -7,6 +7,8 @@
*/
public class NoSuchUserException extends RuntimeException
{
+ private static final long serialVersionUID = -6117983356287782094L;
+
public NoSuchUserException(String message)
{
super(message);
15 years, 6 months
Seam SVN: r10727 - modules/trunk/parent.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-04-29 19:00:22 -0400 (Wed, 29 Apr 2009)
New Revision: 10727
Modified:
modules/trunk/parent/pom.xml
Log:
add relative path to version-matrix so you don't have to go build it first
Modified: modules/trunk/parent/pom.xml
===================================================================
--- modules/trunk/parent/pom.xml 2009-04-29 18:20:45 UTC (rev 10726)
+++ modules/trunk/parent/pom.xml 2009-04-29 23:00:22 UTC (rev 10727)
@@ -7,6 +7,7 @@
<groupId>org.jboss.seam</groupId>
<artifactId>seam-version-matrix</artifactId>
<version>3.0.0-SNAPSHOT</version>
+ <relativePath>../version-matrix/pom.xml</relativePath>
</parent>
<artifactId>seam-parent</artifactId>
15 years, 6 months
Seam SVN: r10726 - modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-04-29 14:20:45 -0400 (Wed, 29 Apr 2009)
New Revision: 10726
Modified:
modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockFacesContext.java
Log:
add some additional JSF 2.0 method impl
Modified: modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockFacesContext.java
===================================================================
--- modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockFacesContext.java 2009-04-29 18:20:16 UTC (rev 10725)
+++ modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockFacesContext.java 2009-04-29 18:20:45 UTC (rev 10726)
@@ -25,6 +25,7 @@
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
@@ -37,6 +38,7 @@
import javax.faces.application.ApplicationFactory;
import javax.faces.application.FacesMessage;
import javax.faces.application.FacesMessage.Severity;
+import javax.faces.component.UINamingContainer;
import javax.faces.component.UIViewRoot;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
@@ -64,6 +66,8 @@
*/
private final Map<String, List<FacesMessage>> messages = new LinkedHashMap<String, List<FacesMessage>>();
+ private Map<Object, Object> attributes = new HashMap<Object, Object>();
+
private ExternalContext externalContext;
private ResponseWriter responseWriter;
@@ -78,17 +82,35 @@
private PhaseId currentPhaseId;
+ private boolean postback;
+
public MockFacesContext()
{
+ attributes.put(UINamingContainer.SEPARATOR_CHAR_PARAM_NAME, ':');
}
+ public MockFacesContext(boolean postback)
+ {
+ this();
+ this.postback = postback;
+ }
+
public MockFacesContext(Application application)
{
+ this();
this.application = application;
}
+ public MockFacesContext(Application application, boolean postback)
+ {
+ this();
+ this.application = application;
+ this.postback = postback;
+ }
+
public MockFacesContext(ExternalContext externalContext, Application application)
{
+ this();
this.externalContext = externalContext;
this.application = application;
}
@@ -97,8 +119,9 @@
// Application
public MockFacesContext(ExternalContext externalContext)
{
- application = ((ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY)).getApplication();
- renderKitFactory = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
+ this();
+ this.application = ((ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY)).getApplication();
+ this.renderKitFactory = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
this.externalContext = externalContext;
}
@@ -172,6 +195,12 @@
}
@Override
+ public Map<Object, Object> getAttributes()
+ {
+ return attributes;
+ }
+
+ @Override
public RenderKit getRenderKit()
{
if (getViewRoot() == null || getViewRoot().getRenderKitId() == null)
@@ -278,6 +307,17 @@
this.currentPhaseId = phaseId;
}
+ @Override
+ public boolean isPostback()
+ {
+ return postback;
+ }
+
+ public void setPostback(boolean postback)
+ {
+ this.postback = postback;
+ }
+
public MockFacesContext setCurrent()
{
setCurrentInstance(this);
15 years, 6 months