renamed to faces

This commit is contained in:
Keith Donald
2008-02-27 17:16:56 +00:00
parent 4671605b79
commit 87f081eba4
54 changed files with 1 additions and 1 deletions

View File

@@ -0,0 +1,33 @@
# $Header$
# Contains filterable project settings. Setting placeholders in filterable project text
# files will be replaced with these values when the 'statics' build target is run.
#
# You may add static settings directly to this source file in the format:
# setting=value e.g MY_SETTING=myvalue
# This is appropriate usage if you know the setting value will never change.
#
# At build time this source file is copied to the ${target.dir} where additional
# dynamic settings may be appended using the <propertyfile> task. Use this approach
# when a setting value depends on the build or the local user's environment.
#
# An example of this approach is shown below:
#
# build.xml
# <target name="build.prepare" depends="common-targets.build.prepare">
# <!-- Append additional local settings that are applicable to this project -->
# <propertyfile file="${target.filter.file}">
# <!-- key=the name of the setting
# value=the property in your build.properties file that has the local setting value -->
# <entry key="MY_LOCAL_SETTING" value="${my.local.setting}" />
# </propertyfile>
# </target>
#
# This allows for dynamic replacement values that are sourced from local properties files to facilitate
# local user settings.
#
# To refer to filterable settings within project source files like config files, JSPs, or
# other text files use the standard ant placeholder format:
# @SETTING_NAME@ e.g, @MY_SETTING@ and @MY_LOCAL_SETTING@
#
# Your settings:

View File

@@ -0,0 +1,20 @@
log4j.rootCategory=WARN, stdout, logfile
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n
log4j.appender.logfile=org.apache.log4j.RollingFileAppender
log4j.appender.logfile.File=${@PROJECT_WEBAPP_NAME@.root}/@PROJECT_WEBAPP_NAME@.log
log4j.appender.logfile.MaxFileSize=512KB
# Keep three backup files
log4j.appender.logfile.MaxBackupIndex=3
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
#Pattern to output : date priority [category] - <message>line_separator
log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - <%m>%n
#Enable webflow debug logging
log4j.category.org.springframework.webflow=DEBUG
log4j.category.org.springframework.binding=DEBUG

View File

@@ -0,0 +1,194 @@
package org.springframework.webflow.samples.booking;
import java.io.Serializable;
import java.math.BigDecimal;
import java.text.DateFormat;
import java.util.Calendar;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import org.springframework.binding.message.MessageBuilder;
import org.springframework.binding.message.MessageContext;
/**
* A Hotel Booking made by a User.
*/
@Entity
public class Booking implements Serializable {
private static final long serialVersionUID = 1171567558348174963L;
private Long id;
private User user;
private Hotel hotel;
private Date checkinDate;
private Date checkoutDate;
private String creditCard;
private String creditCardName;
private int creditCardExpiryMonth;
private int creditCardExpiryYear;
private boolean smoking;
private int beds;
public Booking() {
}
public Booking(Hotel hotel, User user) {
this.hotel = hotel;
this.user = user;
Calendar calendar = Calendar.getInstance();
setCheckinDate(calendar.getTime());
calendar.add(Calendar.DAY_OF_MONTH, 1);
setCheckoutDate(calendar.getTime());
}
@Transient
public BigDecimal getTotal() {
return hotel.getPrice().multiply(new BigDecimal(getNights()));
}
@Transient
public int getNights() {
return (int) (checkoutDate.getTime() - checkinDate.getTime()) / 1000 / 60 / 60 / 24;
}
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@Basic
@Temporal(TemporalType.DATE)
public Date getCheckinDate() {
return checkinDate;
}
public void setCheckinDate(Date datetime) {
this.checkinDate = datetime;
}
@ManyToOne
public Hotel getHotel() {
return hotel;
}
public void setHotel(Hotel hotel) {
this.hotel = hotel;
}
@ManyToOne
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
@Basic
@Temporal(TemporalType.DATE)
public Date getCheckoutDate() {
return checkoutDate;
}
public void setCheckoutDate(Date checkoutDate) {
this.checkoutDate = checkoutDate;
}
public String getCreditCard() {
return creditCard;
}
public void setCreditCard(String creditCard) {
this.creditCard = creditCard;
}
@Transient
public String getDescription() {
DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM);
return hotel == null ? null : hotel.getName() + ", " + df.format(getCheckinDate()) + " to "
+ df.format(getCheckoutDate());
}
public boolean isSmoking() {
return smoking;
}
public void setSmoking(boolean smoking) {
this.smoking = smoking;
}
public int getBeds() {
return beds;
}
public void setBeds(int beds) {
this.beds = beds;
}
public String getCreditCardName() {
return creditCardName;
}
public void setCreditCardName(String creditCardName) {
this.creditCardName = creditCardName;
}
public int getCreditCardExpiryMonth() {
return creditCardExpiryMonth;
}
public void setCreditCardExpiryMonth(int creditCardExpiryMonth) {
this.creditCardExpiryMonth = creditCardExpiryMonth;
}
public int getCreditCardExpiryYear() {
return creditCardExpiryYear;
}
public void setCreditCardExpiryYear(int creditCardExpiryYear) {
this.creditCardExpiryYear = creditCardExpiryYear;
}
public void validate(MessageContext context) {
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_MONTH, -1);
if (checkinDate.before(calendar.getTime())) {
context.addMessage(new MessageBuilder().source("checkinDate").defaultText(
"Check in date must be a future date").error().build());
} else if (!checkinDate.before(checkoutDate)) {
context.addMessage(new MessageBuilder().source("checkoutDate").defaultText(
"Check out date must be later than check in date").error().build());
}
}
@Override
public String toString() {
return "Booking(" + user + "," + hotel + ")";
}
}

View File

@@ -0,0 +1,37 @@
package org.springframework.webflow.samples.booking;
import java.util.List;
/**
* A service interface for retrieving hotels and bookings from a backing repository. Also supports the ability to cancel
* a booking.
*/
public interface BookingService {
/**
* Find bookings made by the given user
* @param username the user's name
* @return their bookings
*/
public List<Booking> findBookings(User user);
/**
* Find hotels available for booking by some criteria.
* @param criteria the search criteria
* @return a list of hotels meeting the criteria
*/
public List<Hotel> findHotels(SearchCriteria criteria);
/**
* Find hotels by their identifier.
* @param id the hotel id
* @return the hotel
*/
public Hotel findHotelById(Long id);
/**
* Cancel an existing booking.
* @param id the booking id
*/
public void cancelBooking(Booking booking);
}

View File

@@ -0,0 +1,106 @@
package org.springframework.webflow.samples.booking;
import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
/**
* A hotel where users may book stays.
*/
@Entity
public class Hotel implements Serializable {
private static final long serialVersionUID = 4011346719502656269L;
private Long id;
private String name;
private String address;
private String city;
private String state;
private String zip;
private String country;
private BigDecimal price;
@Id
@GeneratedValue
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getZip() {
return zip;
}
public void setZip(String zip) {
this.zip = zip;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
@Column(precision = 6, scale = 2)
public BigDecimal getPrice() {
return price;
}
public void setPrice(BigDecimal price) {
this.price = price;
}
@Override
public String toString() {
return "Hotel(" + name + "," + address + "," + city + "," + zip + ")";
}
}

View File

@@ -0,0 +1,67 @@
package org.springframework.webflow.samples.booking;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* A JPA-based implementation of the Booking Service. Delegates to a JPA entity manager to issue data access calls
* against the backing repository. The EntityManager reference is provided by the managing container (Spring)
* automatically.
*/
@Service
@Repository
public class JpaBookingService implements BookingService {
private EntityManager em;
@PersistenceContext
public void setEntityManager(EntityManager em) {
this.em = em;
}
@Transactional(readOnly = true)
@SuppressWarnings("unchecked")
public List<Booking> findBookings(User user) {
return em.createQuery("select b from Booking b where b.user.username = :username order by b.checkinDate")
.setParameter("username", user.getName()).getResultList();
}
@Transactional(readOnly = true)
@SuppressWarnings("unchecked")
public List<Hotel> findHotels(SearchCriteria criteria) {
String pattern = getSearchPattern(criteria);
return em.createQuery(
"select h from Hotel h where lower(h.name) like " + pattern + " or lower(h.city) like " + pattern
+ " or lower(h.zip) like " + pattern + " or lower(h.address) like " + pattern).setMaxResults(
criteria.getPageSize()).setFirstResult(criteria.getPage() * criteria.getPageSize()).getResultList();
}
@Transactional(readOnly = true)
public Hotel findHotelById(Long id) {
return em.find(Hotel.class, id);
}
// read-write transactional methods
@Transactional
public void cancelBooking(Booking booking) {
em.remove(booking);
}
// helpers
private String getSearchPattern(SearchCriteria criteria) {
if (criteria.getSearchString().length() > 0) {
return "'%'" + criteria.getSearchString().toLowerCase().replace('*', '%') + "%'";
} else {
return "'%";
}
}
}

View File

@@ -0,0 +1,68 @@
package org.springframework.webflow.samples.booking;
import java.io.Serializable;
/**
* A backing bean for the main hotel search form. Encapsulates the criteria needed to perform a hotel search.
*/
public class SearchCriteria implements Serializable {
private static final long serialVersionUID = 1L;
/**
* The user-provided search criteria for finding Hotels.
*/
private String searchString = "";
/**
* The maximum page size of the Hotel result list
*/
private int pageSize = 5;
/**
* The current page of the Hotel result list.
*/
private int page;
public String getSearchString() {
return searchString;
}
public void setSearchString(String searchString) {
this.searchString = searchString;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
/**
* Increase the current page
*/
public void nextPage() {
page++;
}
/**
* Decrease the current page
*/
public void prevPage() {
page--;
}
public String toString() {
return "searchString = '" + searchString + "'";
}
}

View File

@@ -0,0 +1,62 @@
package org.springframework.webflow.samples.booking;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* A user who can book hotels.
*/
@Entity
@Table(name = "Customer")
public class User implements Serializable {
private static final long serialVersionUID = -3652559447682574722L;
private String username;
private String password;
private String name;
public User() {
}
public User(String username, String password, String name) {
this.username = username;
this.password = password;
this.name = name;
}
@Id
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public String toString() {
return "User(" + username + ")";
}
}

View File

@@ -0,0 +1,94 @@
package org.springframework.webflow.samples.booking.web;
import java.util.ArrayList;
import java.util.List;
import javax.faces.model.SelectItem;
import javax.persistence.EntityManager;
import org.springframework.stereotype.Service;
import org.springframework.webflow.samples.booking.Booking;
import org.springframework.webflow.samples.booking.Hotel;
import org.springframework.webflow.samples.booking.User;
@Service
public class FlowHelper {
private List<SelectItem> bedOptions;
private List<SelectItem> smokingOptions;
private List<SelectItem> creditCardExpMonths;
private List<SelectItem> creditCardExpYears;
private List<SelectItem> pageSizeOptions;
public List<SelectItem> getBedOptions() {
if (bedOptions == null) {
bedOptions = new ArrayList<SelectItem>();
bedOptions.add(new SelectItem(new Integer(1), "One king-size bed"));
bedOptions.add(new SelectItem(new Integer(2), "Two double beds"));
bedOptions.add(new SelectItem(new Integer(3), "Three beds"));
}
return bedOptions;
}
public List<SelectItem> getSmokingOptions() {
if (smokingOptions == null) {
smokingOptions = new ArrayList<SelectItem>();
smokingOptions.add(new SelectItem(Boolean.TRUE, "Smoking"));
smokingOptions.add(new SelectItem(Boolean.FALSE, "Non-Smoking"));
}
return smokingOptions;
}
public List<SelectItem> getCreditCardExpMonths() {
if (creditCardExpMonths == null) {
creditCardExpMonths = new ArrayList<SelectItem>();
creditCardExpMonths.add(new SelectItem(new Integer(1), "Jan"));
creditCardExpMonths.add(new SelectItem(new Integer(2), "Feb"));
creditCardExpMonths.add(new SelectItem(new Integer(3), "Mar"));
creditCardExpMonths.add(new SelectItem(new Integer(4), "Apr"));
creditCardExpMonths.add(new SelectItem(new Integer(5), "May"));
creditCardExpMonths.add(new SelectItem(new Integer(6), "Jun"));
creditCardExpMonths.add(new SelectItem(new Integer(7), "Jul"));
creditCardExpMonths.add(new SelectItem(new Integer(8), "Aug"));
creditCardExpMonths.add(new SelectItem(new Integer(9), "Sep"));
creditCardExpMonths.add(new SelectItem(new Integer(10), "Oct"));
creditCardExpMonths.add(new SelectItem(new Integer(11), "Nov"));
creditCardExpMonths.add(new SelectItem(new Integer(12), "Dec"));
}
return creditCardExpMonths;
}
public List<SelectItem> getCreditCardExpYears() {
if (creditCardExpYears == null) {
creditCardExpYears = new ArrayList<SelectItem>();
creditCardExpYears.add(new SelectItem(new Integer(2005), "2005"));
creditCardExpYears.add(new SelectItem(new Integer(2006), "2006"));
creditCardExpYears.add(new SelectItem(new Integer(2007), "2007"));
creditCardExpYears.add(new SelectItem(new Integer(2008), "2008"));
creditCardExpYears.add(new SelectItem(new Integer(2009), "2009"));
creditCardExpYears.add(new SelectItem(new Integer(2010), "2010"));
}
return creditCardExpYears;
}
public List<SelectItem> getPageSizeOptions() {
if (pageSizeOptions == null) {
pageSizeOptions = new ArrayList<SelectItem>();
pageSizeOptions.add(new SelectItem(new Integer(5), "5"));
pageSizeOptions.add(new SelectItem(new Integer(10), "10"));
pageSizeOptions.add(new SelectItem(new Integer(20), "20"));
}
return pageSizeOptions;
}
public Booking createBooking(Hotel hotel, User user, EntityManager em) {
Booking booking = new Booking(hotel, user);
em.persist(booking);
return booking;
}
}

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="bookingDatabase">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>org.springframework.webflow.samples.booking.User</class>
<class>org.springframework.webflow.samples.booking.Booking</class>
<class>org.springframework.webflow.samples.booking.Hotel</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
</properties>
</persistence-unit>
</persistence>

View File

@@ -0,0 +1,22 @@
insert into Customer (username, password, name) values ('springer', 'springrocks', 'Springer')
insert into Hotel (id, price, name, address, city, state, zip, country) values (1, 199, 'Westin Diplomat', '3555 S. Ocean Drive', 'Hollywood', 'FL', '33019', 'USA')
insert into Hotel (id, price, name, address, city, state, zip, country) values (2, 120, 'Marriott Courtyard', 'Tower Place, Buckhead', 'Atlanta', 'GA', '30305', 'USA')
insert into Hotel (id, price, name, address, city, state, zip, country) values (3, 180, 'Doubletree', 'Tower Place, Buckhead', 'Atlanta', 'GA', '30305', 'USA')
insert into Hotel (id, price, name, address, city, state, zip, country) values (4, 450, 'W Hotel', 'Union Square, Manhattan', 'NY', 'NY', '10011', 'USA')
insert into Hotel (id, price, name, address, city, state, zip, country) values (5, 450, 'W Hotel', 'Lexington Ave, Manhattan', 'NY', 'NY', '10011', 'USA')
insert into Hotel (id, price, name, address, city, state, zip, country) values (6, 250, 'Hotel Rouge', '1315 16th Street NW', 'Washington', 'DC', '20036', 'USA')
insert into Hotel (id, price, name, address, city, state, zip, country) values (7, 300, '70 Park Avenue Hotel', '70 Park Avenue', 'NY', 'NY', '10011', 'USA')
insert into Hotel (id, price, name, address, city, state, zip, country) values (8, 300, 'Conrad Miami', '1395 Brickell Ave', 'Miami', 'FL', '33131', 'USA')
insert into Hotel (id, price, name, address, city, state, zip, country) values (9, 80, 'Sea Horse Inn', '2106 N Clairemont Ave', 'Eau Claire', 'WI', '54703', 'USA')
insert into Hotel (id, price, name, address, city, state, zip, country) values (10, 90, 'Super 8 Eau Claire Campus Area', '1151 W Macarthur Ave', 'Eau Claire', 'WI', '54701', 'USA')
insert into Hotel (id, price, name, address, city, state, zip, country) values (11, 160, 'Marriot Downtown', '55 Fourth Street', 'San Francisco', 'CA', '94103', 'USA')
insert into Hotel (id, price, name, address, city, state, zip, country) values (12, 200, 'Hilton Diagonal Mar', 'Passeig del Taulat 262-264', 'Barcelona', 'Catalunya', '08019', 'Spain')
insert into Hotel (id, price, name, address, city, state, zip, country) values (13, 210, 'Hilton Tel Aviv', 'Independence Park', 'Tel Aviv', '', '63405', 'Israel')
insert into Hotel (id, price, name, address, city, state, zip, country) values (14, 240, 'InterContinental Tokyo Bay', 'Takeshiba Pier', 'Tokyo', '', '105', 'Japan')
insert into Hotel (id, price, name, address, city, state, zip, country) values (15, 130, 'Hotel Beaulac', ' Esplanade L<>opold-Robert 2', 'Neuchatel', '', '2000', 'Switzerland')
insert into Hotel (id, price, name, address, city, state, zip, country) values (16, 140, 'Conrad Treasury Place', 'William & George Streets', 'Brisbane', 'QLD', '4001', 'Australia')
insert into Hotel (id, price, name, address, city, state, zip, country) values (17, 230, 'Ritz Carlton', '1228 Sherbrooke St', 'West Montreal', 'Quebec', 'H3G1H6', 'Canada')
insert into Hotel (id, price, name, address, city, state, zip, country) values (18, 460, 'Ritz Carlton', 'Peachtree Rd, Buckhead', 'Atlanta', 'GA', '30326', 'USA')
insert into Hotel (id, price, name, address, city, state, zip, country) values (19, 220, 'Swissotel', '68 Market Street', 'Sydney', 'NSW', '2000', 'Australia')
insert into Hotel (id, price, name, address, city, state, zip, country) values (20, 250, 'Meli<EFBFBD> White House', 'Albany Street', 'Regents Park London', '', 'NW13UP', 'Great Britain')
insert into Hotel (id, price, name, address, city, state, zip, country) values (21, 210, 'Hotel Allegro', '171 West Randolph Street', 'Chicago', 'IL', '60601', 'USA')

View File

@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<!-- Appenders -->
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p: %c - %m%n" />
</layout>
</appender>
<logger name="org.springframework.beans">
<level value="warn" />
</logger>
<logger name="org.springframework.jdbc">
<level value="warn" />
</logger>
<logger name="org.springframework.transaction">
<level value="warn" />
</logger>
<logger name="org.springframework.orm">
<level value="warn" />
</logger>
<logger name="org.springframework.web">
<level value="debug" />
</logger>
<logger name="org.springframework.webflow">
<level value="debug" />
</logger>
<!-- Root Logger -->
<root>
<priority value="warn" />
<appender-ref ref="console" />
</root>
</log4j:configuration>

View File

@@ -0,0 +1,2 @@
Manifest-Version: 1.0

View File

@@ -0,0 +1,11 @@
log4j.rootCategory=INFO, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n
# Enable web flow logging
log4j.category.org.springframework.webflow=DEBUG
log4j.category.org.springframework.faces=DEBUG
log4j.category.org.springframework.binding=DEBUG
log4j.category.org.springframework.transaction=DEBUG

View File

@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow
http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
<attribute name="description" value="The flow that handles the process of booking a hotel for a user" />
<!--
Indicates this flow requires a persistence context
One will be created automatically when this flow starts; all data access will use it automatically
-->
<attribute name="persistenceContext" value="true" />
<input-mapper>
<mapping source="#{id}" target="#{flowScope.id}" />
</input-mapper>
<start-state idref="loadHotel"/>
<action-state id="loadHotel">
<evaluate-action expression="#{bookingService.findHotelById(id)}" result="#{flowScope.hotel}" />
<transition on="success" to="createBooking"/>
</action-state>
<action-state id="createBooking">
<evaluate-action expression="#{flowHelper.createBooking(hotel, user, entityManager)}" result="#{flowScope.booking}" />
<transition on="success" to="enterBookingDetails" />
</action-state>
<view-state id="enterBookingDetails" view="bookingForm.xhtml">
<transition on="proceed" to="confirmBooking">
<evaluate-action expression="booking.validate(messageContext)" />
</transition>
<transition on="cancel" to="cancel" />
</view-state>
<view-state id="confirmBooking" view="confirmBooking.xhtml">
<transition on="confirm" to="bookingAuthorized" />
<transition on="revise" to="enterBookingDetails" />
<transition on="cancel" to="cancel" />
</view-state>
<end-state id="cancel">
<!-- Indicates any changes to managed persistent entities should NOT be committed to the database -->
<attribute name="commit" value="false" type="boolean" />
</end-state>
<end-state id="bookingAuthorized">
<!-- Indicates changes to managed persistent entities should be committed to the database at this point -->
<attribute name="commit" value="true" type="boolean" />
</end-state>
</flow>

View File

@@ -0,0 +1,132 @@
<!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:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:sf="http://www.springframework.org/tags/faces"
template="/WEB-INF/layouts/standard.xhtml">
<ui:define name="content">
<div class="section">
<h2>Book Hotel</h2>
<h:form id="booking">
<h:messages errorClass="errors" />
<fieldset>
<div class="field">
<div class="label">Name:</div>
<div class="output">#{hotel.name}</div>
</div>
<div class="field">
<div class="label">Address:</div>
<div class="output">#{hotel.address}</div>
</div>
<div class="field">
<div class="label">City, State:</div>
<div class="output">#{hotel.city}, #{hotel.state}</div>
</div>
<div class="field">
<div class="label">Zip:</div>
<div class="output">#{hotel.zip}</div>
</div>
<div class="field">
<div class="label">Country:</div>
<div class="output">#{hotel.country}</div>
</div>
<div class="field">
<div class="label">Nightly rate:</div>
<div class="output">
<h:outputText value="#{hotel.price}">
<f:convertNumber type="currency" currencySymbol="$"/>
</h:outputText>
</div>
</div>
<div class="field">
<div class="label">
<h:outputLabel for="checkinDate">Check In Date:</h:outputLabel>
</div>
<div class="input">
<sf:clientDateValidator required="true" >
<h:inputText id="checkinDate" value="#{booking.checkinDate}" required="true">
<f:convertDateTime pattern="yyyy-MM-dd" timeZone="EST"/>
</h:inputText>
</sf:clientDateValidator>
</div>
</div>
<div class="field">
<div class="label">
<h:outputLabel for="checkoutDate">Check Out Date:</h:outputLabel>
</div>
<div class="input">
<sf:clientDateValidator required="true">
<h:inputText id="checkoutDate" value="#{booking.checkoutDate}" required="true">
<f:convertDateTime pattern="yyyy-MM-dd" timeZone="EST"/>
</h:inputText>
</sf:clientDateValidator>
</div>
</div>
<div class="field">
<div class="label">
<h:outputLabel for="beds">Room Preference:</h:outputLabel>
</div>
<div class="input">
<h:selectOneMenu id="beds" value="#{booking.beds}">
<f:selectItems value="#{bookingOptions.bedOptions}"/>
</h:selectOneMenu>
</div>
</div>
<div class="field">
<div class="label">
<h:outputLabel for="smoking">Smoking Preference:</h:outputLabel>
</div>
<div id="radio" class="input">
<h:selectOneRadio id="smoking" value="#{booking.smoking}" layout="pageDirection">
<f:selectItems value="#{bookingOptions.smokingOptions}"/>
</h:selectOneRadio>
</div>
</div>
<div class="field">
<div class="label">
<h:outputLabel for="creditCard">Credit Card #:</h:outputLabel>
</div>
<div class="input">
<sf:clientTextValidator required="true" regExp="[0-9]{16}" invalidMessage="A 16-digit credit card number is required.">
<h:inputText id="creditCard" value="#{booking.creditCard}" required="true"/>
</sf:clientTextValidator>
</div>
</div>
<div class="field">
<div class="label">
<h:outputLabel for="creditCardName">Credit Card Name:</h:outputLabel>
</div>
<div class="input">
<sf:clientTextValidator required="true">
<h:inputText id="creditCardName" value="#{booking.creditCardName}" required="true"/>
</sf:clientTextValidator>
</div>
</div>
<div class="field">
<div class="label">
<h:outputLabel for="creditCardExpiryMonth">Credit Card Expiry:</h:outputLabel>
</div>
<div class="input">
<h:selectOneMenu id="creditCardExpiryMonth" value="#{booking.creditCardExpiryMonth}">
<f:selectItems value="#{bookingOptions.creditCardExpMonths}" />
</h:selectOneMenu>
<h:selectOneMenu id="creditCardExpiryYear" value="#{booking.creditCardExpiryYear}">
<f:selectItems value="#{bookingOptions.creditCardExpYears}"/>
</h:selectOneMenu>
</div>
</div>
<div class="buttonGroup">
<sf:validateAllOnClick>
<h:commandButton id="proceed" action="proceed" value="Proceed"/>
</sf:validateAllOnClick>
<h:commandButton id="cancel" immediate="true" value="Cancel" action="cancel"/>
</div>
</fieldset>
</h:form>
</div>
</ui:define>
</ui:composition>

View File

@@ -0,0 +1,68 @@
<!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:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:sf="http://www.springframework.org/tags/faces"
template="/WEB-INF/layouts/standard.xhtml">
<ui:define name="content">
<div class="section">
<h1>Confirm Hotel Booking</h1>
</div>
<div class="section">
<h:form id="confirm">
<fieldset>
<div class="field">
<div class="label">Name:</div>
<div class="output">#{hotel.name}</div>
</div>
<div class="field">
<div class="label">Address:</div>
<div class="output">#{hotel.address}</div>
</div>
<div class="field">
<div class="label">City, State:</div>
<div class="output">#{hotel.city}, #{hotel.state}</div>
</div>
<div class="field">
<div class="label">Zip:</div>
<div class="output">#{hotel.zip}</div>
</div>
<div class="field">
<div class="label">Country:</div>
<div class="output">#{hotel.country}</div>
</div>
<div class="field">
<div class="label">Total payment:</div>
<div class="output">
<h:outputText value="#{booking.total}">
<f:convertNumber type="currency" currencySymbol="$"/>
</h:outputText>
</div>
</div>
<div class="field">
<div class="label">Check In Date:</div>
<div class="output"><h:outputText value="#{booking.checkinDate}"/></div>
</div>
<div class="field">
<div class="label">Check Out Date:</div>
<div class="output"><h:outputText value="#{booking.checkoutDate}"/></div>
</div>
<div class="field">
<div class="label">Credit Card #:</div>
<div class="output">#{booking.creditCard}</div>
</div>
<div class="buttonGroup">
<h:commandButton id="confirm" value="Confirm" action="confirm"/>&#160;
<h:commandButton id="revise" value="Revise" action="revise"/>&#160;
<h:commandButton id="cancel" value="Cancel" action="cancel"/>
</div>
</fieldset>
</h:form>
</div>
</ui:define>
</ui:composition>

View File

@@ -0,0 +1,55 @@
<!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:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:sf="http://www.springframework.org/tags/faces"
template="/WEB-INF/layouts/standard.xhtml">
<ui:define name="content">
<h:form id="displayHotelsForm">
<div class="section">
<sf:commandLink ajaxEnabled="false" value="Return to Main" action="changeSearch"/>
<h2>Hotel Results</h2>
<p>
<b>Search Criteria:</b> #{searchCriteria}<br/>
<sf:commandLink value="Edit Criteria" action="changeSearch"/>
</p>
<ui:fragment id="searchResultsFragment">
<div id="searchResults">
<h:outputText id="noHotelsTxt" value="No Hotels Found" rendered="#{hotels.rowCount == 0}"/>
<h:dataTable id="hotels" styleClass="summary" value="#{hotels}" var="hotel" rendered="#{hotels.rowCount > 0}">
<h:column>
<f:facet name="header">Name</f:facet>
#{hotel.name}
</h:column>
<h:column>
<f:facet name="header">Address</f:facet>
#{hotel.address}
</h:column>
<h:column>
<f:facet name="header">City, State</f:facet>
#{hotel.city}, #{hotel.state}, #{hotel.country}
</h:column>
<h:column>
<f:facet name="header">Zip</f:facet>
#{hotel.zip}
</h:column>
<h:column>
<f:facet name="header">Action</f:facet>
<sf:commandLink id="viewHotelLink" value="View Hotel" action="selectHotel"/>
</h:column>
</h:dataTable>
<div class="next">
<sf:commandLink id="nextPageLink" value="More Results" action="next" rendered="#{not empty hotels and hotels.rowCount == searchCriteria.pageSize}"/>
</div>
<div class="prev">
<sf:commandLink id="prevPageLink" value="Previous results" action="previous" rendered="#{searchCriteria.page > 0}"/>
</div>
</div>
</ui:fragment>
</div>
</h:form>
</ui:define>
</ui:composition>

View File

@@ -0,0 +1,57 @@
<!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:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:sf="http://www.springframework.org/tags/faces"
template="/WEB-INF/layouts/standard.xhtml">
<ui:define name="content">
<div class="section">
<h2>View Hotel</h2>
<div class="field">
<div class="label">Name:</div>
<div class="output">#{hotel.name}</div>
</div>
<div class="field">
<div class="label">Address:</div>
<div class="output">#{hotel.address}</div>
</div>
<div class="field">
<div class="label">City:</div>
<div class="output">#{hotel.city}</div>
</div>
<div class="field">
<div class="label">State:</div>
<div class="output">#{hotel.state}</div>
</div>
<div class="field">
<div class="label">Zip:</div>
<div class="output">#{hotel.zip}</div>
</div>
<div class="field">
<div class="label">Country:</div>
<div class="output">#{hotel.country}</div>
</div>
<div class="field">
<div class="label">Nightly rate:</div>
<div class="output">
<h:outputText value="#{hotel.price}">
<f:convertNumber type="currency" currencySymbol="$"/>
</h:outputText>
</div>
</div>
</div>
<div class="section">
<h:form id="hotel">
<fieldset class="buttonGroup">
<h:commandButton id="book" action="book" value="Book Hotel"/>
<h:commandButton id="cancel" action="cancel" value="Back to Search"/>
</fieldset>
</h:form>
</div>
</ui:define>
</ui:composition>

View File

@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow
http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
<attribute name="description" value="The main flow of the application lets a user search for hotels to book" />
<var name="searchCriteria" class="org.springframework.webflow.samples.booking.SearchCriteria" />
<start-actions>
<evaluate-action expression="#{bookingService.findBookings(currentUser)}" result="#{flowScope.bookings}" type="dataModel" />
</start-actions>
<start-state idref="displayMain" />
<view-state id="displayMain" view="main.xhtml">
<transition on="findHotels" to="displayHotels" />
<transition on="cancelBooking" to="cancelBooking" />
</view-state>
<view-state id="displayHotels" view="displayHotels.xhtml">
<render-actions>
<evaluate-action expression="#{bookingService.findHotels(searchCriteria)}" result="#{flowScope.hotels}" type="dataModel" />
</render-actions>
<transition on="previous">
<evaluate-action expression="#{searchCriteria.prevPage()}" />
<set attribute="#{flashScope.renderIds}" value="searchResultsFragment" />
</transition>
<transition on="next">
<evaluate-action expression="#{searchCriteria.nextPage()}" />
<set attribute="#{flashScope.renderIds}" value="searchResultsFragment" />
</transition>
<transition on="selectHotel" to="displayHotel" />
<transition on="changeSearch" to="editSearchPopup" />
</view-state>
<view-state id="editSearchPopup" view="main.xhtml">
<attribute name="modal" value="true" type="boolean" />
<entry-actions>
<set attribute="#{flashScope.renderIds}" value="hotelSearchFragment" />
</entry-actions>
<transition on="findHotels" to="displayHotels" />
</view-state>
<view-state id="displayHotel" view="hotelDetails.xhtml">
<render-actions>
<set attribute="#{hotel}" value="#{hotels.selectedRow}" scope="request" />
</render-actions>
<transition on="book" to="bookHotel" />
<transition on="cancel" to="displayMain" />
</view-state>
<subflow-state id="bookHotel" flow="booking">
<attribute-mapper>
<input-mapper>
<mapping source="#{hotels.selectedRow.id}" target="#{id}" />
</input-mapper>
</attribute-mapper>
<transition on="bookingAuthorized" to="reloadCurrentUserBookings" />
<transition on="cancel" to="displayMain" />
</subflow-state>
<action-state id="cancelBooking">
<bean-action method="cancelBooking" bean="bookingService">
<method-arguments>
<argument expression="#{bookings.selectedRow}" parameter-type="long" />
</method-arguments>
</bean-action>
<transition on="success" to="reloadCurrentUserBookings" />
</action-state>
<action-state id="reloadCurrentUserBookings">
<evaluate-action expression="#{bookingService.findBookings(currentUser)}" result="#{flowScope.bookings}" type="dataModel" />
<transition on="success" to="displayMain" />
</action-state>
</flow>

View File

@@ -0,0 +1,82 @@
<!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:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:sf="http://www.springframework.org/tags/faces"
template="/WEB-INF/layouts/standard.xhtml">
<ui:define name="content">
<ui:fragment id="hotelSearchFragment">
<div id="hotelSearch" class="section">
<span class="errors">
<h:messages globalOnly="true"/>
</span>
<h2>Search Hotels</h2>
<h:form id="mainForm"><br/><br/>
<fieldset>
<div class="searchGroup">
<div class="searchField">
<sf:clientTextValidator promptMessage="Search hotels by name, address, city, or zip.">
<h:inputText id="searchString" value="#{flowScope.searchCriteria.searchString}" style="width: 165px; height: 15px;"/>
</sf:clientTextValidator>
</div>
<div class="searchSize">
<h:outputLabel for="pageSize">Maximum results:</h:outputLabel>
<h:selectOneMenu value="#{flowScope.searchCriteria.pageSize}" id="pageSize">
<f:selectItem itemLabel="5" itemValue="5"/>
<f:selectItem itemLabel="10" itemValue="10"/>
<f:selectItem itemLabel="20" itemValue="20"/>
</h:selectOneMenu>
</div>
<div class="searchButton">
<sf:commandButton id="findHotels" value="Find Hotels" processIds="hotelSearchFragment" action="findHotels"/>
</div>
</div>
</fieldset>
</h:form>
</div>
</ui:fragment>
<ui:fragment id="bookingsFragment">
<div class="section">
<h:form id="bookingsForm">
<h2>Current Hotel Bookings</h2>
<h:outputText value="No Bookings Found" rendered="#{bookings.rowCount == 0}"/>
<h:dataTable id="bookings" styleClass="summary" value="#{bookings}" var="booking" rendered="#{bookings.rowCount > 0}">
<h:column>
<f:facet name="header">Name</f:facet>
#{booking.hotel.name}
</h:column>
<h:column>
<f:facet name="header">Address</f:facet>
#{booking.hotel.address}
</h:column>
<h:column>
<f:facet name="header">City, State</f:facet>
#{booking.hotel.city}, #{booking.hotel.state}
</h:column>
<h:column>
<f:facet name="header">Check in date</f:facet>
<h:outputText value="#{booking.checkinDate}"/>
</h:column>
<h:column>
<f:facet name="header">Check out date</f:facet>
<h:outputText value="#{booking.checkoutDate}"/>
</h:column>
<h:column>
<f:facet name="header">Confirmation number</f:facet>
#{booking.id}
</h:column>
<h:column>
<f:facet name="header">Action</f:facet>
<sf:commandLink id="cancel" value="Cancel" ajaxEnabled="false" processIds="bookingsFragment" action="cancelBooking"/>
</h:column>
</h:dataTable>
</h:form>
</div>
</ui:fragment>
</ui:define>
</ui:composition>

View File

@@ -0,0 +1,40 @@
<!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:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:sf="http://www.springframework.org/tags/faces"
template="/template.xhtml">
<ui:define name="content">
<div class="section">
<h1>Welcome to the Spring Faces Sample Application</h1>
<p>
This hotel booking sample application illustrates "Spring Faces", Spring's first-class support for Java Server Faces (JSF).
Spring Faces integrates Spring, Spring Web Flow, Dojo, Ext, and Facelets to provide a
compelling solution for developing rich web applications with JSF.
</p>
<p>
Currently, Spring Faces is released as a component of the Spring Web Flow distribution,
and has been available beginning with Spring Web Flow 2.0.
</p>
<p>
The key features illustrated in this sample include:
</p>
<ul>
<li>A unified navigation model</li>
<li>A robust state management model</li>
<li>Modularization of web application functionality by domain responsibility</li>
<li>Flow-managed persistence contexts with the Java Persistence API (JPA)</li>
<li>Unified Expression Language (EL) integration</li>
<li>Client-side validation with Dojo and Ext</li>
<li>Spring IDE integration, with support for graphical flow modeling</li>
</ul>
<p align="right">
<a href="spring/main">Start your hotel booking experience</a>
</p>
</div>
</ui:define>
</ui:composition>

View File

@@ -0,0 +1,52 @@
<!DOCTYPE html 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"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Spring Faces: Hotel Booking Sample Application</title>
<style type="text/css" media="screen">
@import url("${request.contextPath}/resources/css-framework/css/tools.css");
@import url("${request.contextPath}/resources/css-framework/css/typo.css");
@import url("${request.contextPath}/resources/css-framework/css/forms.css");
@import url("${request.contextPath}/resources/css-framework/css/layout-navtop-localleft.css");
@import url("${request.contextPath}/resources/css-framework/css/layout.css");
@import url("${request.contextPath}/styles/booking.css");
</style>
<ui:insert name="headIncludes"/>
</head>
<body class="tundra spring">
<div id="page">
<div id="header" class="clearfix spring">
<div id="welcome">
<div class="left">Spring Faces: Hotel Booking Sample Application</div>
<div class="right">
Welcome, #{currentUser.name}
</div>
</div>
<div id="branding" class="spring">
<img src="${request.contextPath}/images/header.jpg" alt="foo bar"/>
</div>
</div>
<div id="content" class="clearfix spring">
<div id="local" class="spring">
<a href="http://www.thespringexperience.com">
<img src="${request.contextPath}/images/diplomat.jpg" />
</a>
<a href="http://www.thespringexperience.com">
<img src="${request.contextPath}/images/tse.gif" />
</a>
<p>
</p>
</div>
<div id="main">
<ui:insert name="content"/>
</div>
</div>
<div id="footer" class="clearfix spring">
<a href="http://www.springframework.org"><img src="${request.contextPath}/images/powered-by-spring.png" /></a>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:webflow="http://www.springframework.org/schema/webflow-config"
xmlns:faces="http://www.springframework.org/schema/faces-config"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/webflow-config
http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.0.xsd
http://www.springframework.org/schema/faces-config
http://www.springframework.org/schema/faces-config/spring-faces-config-2.0.xsd">
<!-- Activates annotation-based bean configuration -->
<context:annotation-config />
<!-- Instructs Spring to perfrom declarative transaction managemenet on annotated classes -->
<tx:annotation-driven />
<!-- Handles requests to the Spring Web Flow system -->
<bean name="/flows/*" class="org.springframework.webflow.mvc.FlowController">
<constructor-arg ref="flowExecutor" />
</bean>
<!-- Executes flows: the central entry point into the Spring Web Flow system -->
<webflow:flow-executor id="flowExecutor" flow-registry="flowRegistry">
<webflow:flow-execution-listeners>
<webflow:listener ref="jpaFlowExecutionListener" criteria="*" />
</webflow:flow-execution-listeners>
</webflow:flow-executor>
<!-- The registry of executable flow definitions -->
<webflow:flow-registry id="flowRegistry" flow-builder-services="facesFlowBuilderServices">
<webflow:flow-location path="/WEB-INF/flows/*/*-flow.xml" />
</webflow:flow-registry>
<!-- Installs a listener that manages JPA persistence contexts for flows that require them -->
<bean id="jpaFlowExecutionListener" class="org.springframework.webflow.persistence.JpaFlowExecutionListener">
<constructor-arg ref="entityManagerFactory" />
<constructor-arg ref="transactionManager" />
</bean>
<!-- Configures the Spring Web Flow JSF integration -->
<faces:flow-builder-services id="facesFlowBuilderServices" />
<!-- Drives transactions using local JPA APIs -->
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<!-- Creates a EntityManagerFactory for use with the Hibernate JPA provider and a simple in-memory data source populated with test data -->
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />
</property>
</bean>
<!-- Deploys a in-memory "booking" datasource populated -->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="org.hsqldb.jdbcDriver" />
<property name="url" value="jdbc:hsqldb:mem:booking" />
<property name="username" value="sa" />
<property name="password" value="" />
</bean>
</beans>

View File

@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<!-- Use JSF view templates saved as *.xhtml, for use with Facelets -->
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<!-- Enables special Facelets debug output during development -->
<context-param>
<param-name>facelets.DEVELOPMENT</param-name>
<param-value>true</param-value>
</context-param>
<!-- Causes Facelets to refresh templates during development -->
<context-param>
<param-name>facelets.REFRESH_PERIOD</param-name>
<param-value>1</param-value>
</context-param>
<!-- Serves static resource content from .jar files such as spring-faces.jar -->
<servlet>
<servlet-name>Resources Servlet</servlet-name>
<servlet-class>org.springframework.faces.ui.resource.ResourceServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<!-- Map all /resources requests to the Resource Servlet for handling -->
<servlet-mapping>
<servlet-name>Resources Servlet</servlet-name>
<url-pattern>/resources/*</url-pattern>
</servlet-mapping>
<!-- The front controller of this Spring Web application, responsible for handling all application requests -->
<servlet>
<servlet-name>Spring Web MVC Dispatcher Servlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/web-application-config.xml</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<!-- Map all /spring requests to the Dispatcher Servlet for handling -->
<servlet-mapping>
<servlet-name>Spring Web MVC Dispatcher Servlet</servlet-name>
<url-pattern>/spring/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 325 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@@ -0,0 +1,5 @@
<html>
<head>
<meta http-equiv="Refresh" content="0; URL=/spring/intro">
</head>
</html>

View File

@@ -0,0 +1,193 @@
a, a:link a:active {
color: black;
background-color: white;
text-decoration: underline;
}
a:visited {
color: black;
background-color: transparent;
}
a:hover {
color: white;
background-color: #65a242;
text-decoration: none;
}
body.spring {
background-color: #9cac7c;
}
#header.spring {
margin: 0 0 1em 0;
padding: 0px 0px;
background-color : #414f23;
}
#branding.spring {
float: none;
width: 100%;
margin: 10px 0 0 0;
padding: 0 0 0 0;
text-align: none;
}
#welcome {
padding: 10px 10px;
}
#welcome div.left {
float: left;
}
#welcome div.right {
float: right;
}
#content.spring form div,
#content.spring form p {
padding: 0px;
margin: 0 0 .5em 0;
}
#content.spring {
width: 740px;
background: #fff url(../images/bg.gif) 0 0 repeat;
margin-bottom: 0px;
}
#content .section {
width: 505px;
float: left;
}
#content.spring input[type="submit"], input[type="button"], button {
font-weight: bold;
color: #fff;
height: 20px;
background: #fff url(../images/btn.bg.gif) 0 0 repeat-x;
border-style: none;
vertical-align: middle;
}
#content.spring button
{
font-size: 1em;
font-family: arial,helvetica,verdana,sans-serif;
margin-top: 0pt;
margin-right: 0pt;
margin-bottom: 0pt;
margin-left: 0pt;
padding-top: 2px;
padding-right: 2px;
padding-bottom: 2px;
padding-left: 2px;
}
#content.spring button
{
vertical-align: middle;
}
.errors {
font-weight: bold;
text-align: center;
color: #600;
}
.errors ul {
list-style: none;
}
#content .field {
float:left;
}
#content .field .label {
float: left;
padding-top: 5px;
padding-right: 5px;
font-weight: bold;
width: 150px;
text-align: right;
}
#content .field .output {
float: left;
width: 250px;
padding-top: 5px;
text-align: left;
}
#content .field .input {
float: left;
width: 250px;
text-align: left;
}
#content .searchGroup {
width: 35%;
text-align: right;
}
#content .buttonGroup {
width: 90%;
float: left;
text-align: center;
}
#content .buttonGroup input[type="submit"], .buttonGroup input[type="button"] {
margin-right: 5px;
}
#content .prev {
float: right;
}
#content .next {
float: right;
}
#content .next a {
margin-left: 20px;
}
#content .summary {
width: 100%;
border: 1px solid #414f23;
border-collapse: collapse;
}
#content .summary thead th {
border-left: 1px solid #414f23;
background: #fff url(../images/th.bg.gif) 0 100% repeat-x;
border-bottom: 1px solid #414f23;
padding: 6px;
text-align: left;
font-size: small;
}
#content .summary tbody td {
border-left: 1px solid #9cac7c;
padding: 4px;
border-bottom: 1px solid #9cac7c;
font-size: 8pt;
}
#local.spring{
width: 215px;
}
#footer.spring {
padding: 25px 0;
background-color : white;
border-top: 1px solid #C3BBB6;
}
#footer.spring img {
float: right;
padding-right: 20px;
}