diff --git a/spring-webflow-samples/jsf-booking/.classpath b/spring-webflow-samples/jsf-booking/.classpath new file mode 100644 index 00000000..efd17915 --- /dev/null +++ b/spring-webflow-samples/jsf-booking/.classpath @@ -0,0 +1,197 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-webflow-samples/jsf-booking/.metadata/src/main/webapp/WEB-INF/faces-config.pageflow b/spring-webflow-samples/jsf-booking/.metadata/src/main/webapp/WEB-INF/faces-config.pageflow new file mode 100644 index 00000000..fb45bbcd --- /dev/null +++ b/spring-webflow-samples/jsf-booking/.metadata/src/main/webapp/WEB-INF/faces-config.pageflow @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/spring-webflow-samples/jsf-booking/.project b/spring-webflow-samples/jsf-booking/.project new file mode 100644 index 00000000..5e1f1505 --- /dev/null +++ b/spring-webflow-samples/jsf-booking/.project @@ -0,0 +1,30 @@ + + jsf-booking + Spring Web Flow Number Guess JSF Example + + + + org.eclipse.jdt.core.javabuilder + + + org.eclipse.wst.common.project.facet.core.builder + + + org.eclipse.wst.validation.validationbuilder + + + org.springframework.ide.eclipse.core.springbuilder + + + org.hibernate.eclipse.console.hibernateBuilder + + + + org.springframework.ide.eclipse.core.springnature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.jdt.core.javanature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jem.workbench.JavaEMFNature + org.hibernate.eclipse.console.hibernateNature + + \ No newline at end of file diff --git a/spring-webflow-samples/jsf-booking/.settings/org.eclipse.jdt.ui.prefs b/spring-webflow-samples/jsf-booking/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 00000000..e0d5724c --- /dev/null +++ b/spring-webflow-samples/jsf-booking/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,53 @@ +#Thu Aug 09 13:12:30 EDT 2007 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +formatter_profile=_Spring Java Conventions +formatter_settings_version=11 +instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=false +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.format_source_code=true +sp_cleanup.make_local_variable_final=false +sp_cleanup.make_parameters_final=false +sp_cleanup.make_private_fields_final=true +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=true +sp_cleanup.on_save_use_additional_actions=false +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=false +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=false +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=false +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=false +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=false +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/spring-webflow-samples/jsf-booking/.settings/org.eclipse.jpt.core.prefs b/spring-webflow-samples/jsf-booking/.settings/org.eclipse.jpt.core.prefs new file mode 100644 index 00000000..102d5856 --- /dev/null +++ b/spring-webflow-samples/jsf-booking/.settings/org.eclipse.jpt.core.prefs @@ -0,0 +1,5 @@ +#Thu Aug 09 13:12:30 EDT 2007 +eclipse.preferences.version=1 +instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true +org.eclipse.jpt.core.discoverAnnotatedClasses=true +org.eclipse.jpt.core.platform=generic diff --git a/spring-webflow-samples/jsf-booking/.settings/org.eclipse.jst.common.project.facet.core.prefs b/spring-webflow-samples/jsf-booking/.settings/org.eclipse.jst.common.project.facet.core.prefs new file mode 100644 index 00000000..7a3d18a6 --- /dev/null +++ b/spring-webflow-samples/jsf-booking/.settings/org.eclipse.jst.common.project.facet.core.prefs @@ -0,0 +1,5 @@ +#Thu Aug 09 13:12:30 EDT 2007 +classpath.helper/org.eclipse.jdt.launching.JRE_CONTAINER/owners=jst.java\:5.0 +classpath.helper/org.eclipse.jst.server.core.container\:\:org.eclipse.jst.server.tomcat.runtimeTarget\:\:Apache\ Tomcat\ v5.5/owners=jst.web\:2.4 +eclipse.preferences.version=1 +instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true diff --git a/spring-webflow-samples/jsf-booking/.settings/org.eclipse.wst.common.component b/spring-webflow-samples/jsf-booking/.settings/org.eclipse.wst.common.component new file mode 100644 index 00000000..262baacc --- /dev/null +++ b/spring-webflow-samples/jsf-booking/.settings/org.eclipse.wst.common.component @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/spring-webflow-samples/jsf-booking/.settings/org.eclipse.wst.common.project.facet.core.xml b/spring-webflow-samples/jsf-booking/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 00000000..cddf50bf --- /dev/null +++ b/spring-webflow-samples/jsf-booking/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/spring-webflow-samples/jsf-booking/.settings/org.eclipse.wst.validation.prefs b/spring-webflow-samples/jsf-booking/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 00000000..f5f51015 --- /dev/null +++ b/spring-webflow-samples/jsf-booking/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,7 @@ +#Thu Aug 09 13:12:30 EDT 2007 +DELEGATES_PREFERENCE=delegateValidatorListorg.eclipse.wst.wsdl.validation.internal.eclipse.WSDLDelegatingValidator\=org.eclipse.wst.wsdl.validation.internal.eclipse.Validator;org.eclipse.wst.xsd.core.internal.validation.eclipse.XSDDelegatingValidator\=org.eclipse.wst.xsd.core.internal.validation.eclipse.Validator; +USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.wst.html.internal.validation.HTMLValidator;org.eclipse.wst.xml.core.internal.validation.eclipse.Validator;org.eclipse.wst.dtd.core.internal.validation.eclipse.Validator;org.eclipse.wst.wsdl.validation.internal.eclipse.WSDLDelegatingValidator;org.eclipse.jst.j2ee.internal.web.validation.UIWarValidator;org.eclipse.jst.jsp.core.internal.validation.JSPELValidator;org.eclipse.jst.jsp.core.internal.validation.JSPJavaValidator;org.eclipse.jst.jsp.core.internal.validation.JSPDirectiveValidator;org.eclipse.wst.common.componentcore.internal.ModuleCoreValidator;org.eclipse.wst.wsi.ui.internal.WSIMessageValidator;org.eclipse.wst.xsd.core.internal.validation.eclipse.XSDDelegatingValidator; +USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.wst.html.internal.validation.HTMLValidator;org.eclipse.wst.xml.core.internal.validation.eclipse.Validator;org.eclipse.wst.dtd.core.internal.validation.eclipse.Validator;org.eclipse.wst.wsdl.validation.internal.eclipse.WSDLDelegatingValidator;org.eclipse.jst.j2ee.internal.web.validation.UIWarValidator;org.eclipse.jst.jsp.core.internal.validation.JSPELValidator;org.eclipse.jst.jsp.core.internal.validation.JSPJavaValidator;org.eclipse.jst.jsp.core.internal.validation.JSPDirectiveValidator;org.eclipse.wst.common.componentcore.internal.ModuleCoreValidator;org.eclipse.wst.wsi.ui.internal.WSIMessageValidator;org.eclipse.wst.xsd.core.internal.validation.eclipse.XSDDelegatingValidator; +USER_PREFERENCE=overrideGlobalPreferencesfalse +eclipse.preferences.version=1 +instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true diff --git a/spring-webflow-samples/jsf-booking/.settings/org.hibernate.eclipse.console.prefs b/spring-webflow-samples/jsf-booking/.settings/org.hibernate.eclipse.console.prefs new file mode 100644 index 00000000..8b1cd5cf --- /dev/null +++ b/spring-webflow-samples/jsf-booking/.settings/org.hibernate.eclipse.console.prefs @@ -0,0 +1,5 @@ +#Thu Aug 09 13:12:30 EDT 2007 +default.configuration=jsf-booking +eclipse.preferences.version=1 +hibernate3.enabled=true +instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true diff --git a/spring-webflow-samples/jsf-booking/.settings/org.springframework.ide.eclipse.core.prefs b/spring-webflow-samples/jsf-booking/.settings/org.springframework.ide.eclipse.core.prefs new file mode 100644 index 00000000..f55808e4 --- /dev/null +++ b/spring-webflow-samples/jsf-booking/.settings/org.springframework.ide.eclipse.core.prefs @@ -0,0 +1,42 @@ +#Wed Feb 27 11:35:00 EST 2008 +eclipse.preferences.version=1 +instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true +org.springframework.ide.eclipse.core.builders.enable.aopreferencemodelbuilder=true +org.springframework.ide.eclipse.core.builders.enable.osgibundleupdater=true +org.springframework.ide.eclipse.core.enable.project.preferences=false +org.springframework.ide.eclipse.core.validator.enable.com.springsource.sts.bestpractices.beansvalidator=true +org.springframework.ide.eclipse.core.validator.enable.org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.enable.org.springframework.ide.eclipse.core.springvalidator=true +org.springframework.ide.eclipse.core.validator.enable.org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.sts.bestpractices.legacyxmlusage.jndiobjectfactory-com.springsource.sts.bestpractices.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanAlias-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanClass-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanConstructorArgument-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanDefinition-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanDefinitionHolder-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanFactory-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanInitDestroyMethod-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanProperty-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanReference-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.methodOverride-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.parsingProblems-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.requiredProperty-org.springframework.ide.eclipse.beans.core.beansvalidator=false +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.core.springClasspath-org.springframework.ide.eclipse.core.springvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.action-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.actionstate-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.attribute-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.attributemapper-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.beanaction-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.evaluationaction-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.evaluationresult-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.exceptionhandler-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.import-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.inputattribute-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.mapping-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.outputattribute-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.set-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.state-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.subflowstate-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.transition-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.variable-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.webflowstate-org.springframework.ide.eclipse.webflow.core.validator=true diff --git a/spring-webflow-samples/jsf-booking/.springBeans b/spring-webflow-samples/jsf-booking/.springBeans new file mode 100644 index 00000000..5d292705 --- /dev/null +++ b/spring-webflow-samples/jsf-booking/.springBeans @@ -0,0 +1,14 @@ + + + 1 + + + + + + + src/main/webapp/WEB-INF/web-application-config.xml + + + + diff --git a/spring-webflow-samples/jsf-booking/build.xml b/spring-webflow-samples/jsf-booking/build.xml new file mode 100644 index 00000000..48ec38a9 --- /dev/null +++ b/spring-webflow-samples/jsf-booking/build.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/spring-webflow-samples/jsf-booking/ivy.xml b/spring-webflow-samples/jsf-booking/ivy.xml new file mode 100644 index 00000000..f7dbfec7 --- /dev/null +++ b/spring-webflow-samples/jsf-booking/ivy.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/faces/support/RequestLoggingPhaseListener.java b/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/faces/support/RequestLoggingPhaseListener.java new file mode 100644 index 00000000..6a87eff2 --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/faces/support/RequestLoggingPhaseListener.java @@ -0,0 +1,50 @@ +/* + * Copyright 2004-2008 the original authorimport javax.faces.event.PhaseEvent; +import javax.faces.event.PhaseId; +import javax.faces.event.PhaseListener; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.faces.support; + +import javax.faces.event.PhaseEvent; +import javax.faces.event.PhaseId; +import javax.faces.event.PhaseListener; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * {@link PhaseListener} that logs the execution of the individual phases of the JSF lifecycle. Useful during JSF + * application development in order to detect unreported JSF errors that cause the lifecycle to short-circuit. Turn + * logging level to DEBUG to see its output. + * + * @author Jeremy Grelle + */ +public class RequestLoggingPhaseListener implements PhaseListener { + + private Log logger = LogFactory.getLog(RequestLoggingPhaseListener.class); + + public void afterPhase(PhaseEvent event) { + // no-op + } + + public void beforePhase(PhaseEvent event) { + if (logger.isDebugEnabled()) { + logger.debug("Entering JSF Phase: " + event.getPhaseId()); + } + } + + public PhaseId getPhaseId() { + return PhaseId.ANY_PHASE; + } + +} diff --git a/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/Booking.java b/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/Booking.java new file mode 100644 index 00000000..80851349 --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/Booking.java @@ -0,0 +1,179 @@ +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; + +/** + * 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; + } + + @Override + public String toString() { + return "Booking(" + user + "," + hotel + ")"; + } + +} diff --git a/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/BookingController.java b/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/BookingController.java new file mode 100644 index 00000000..223c8aa0 --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/BookingController.java @@ -0,0 +1,87 @@ +package org.springframework.webflow.samples.booking; + +import java.util.Calendar; + +import javax.faces.application.FacesMessage; +import javax.faces.context.FacesContext; + +public class BookingController { + + private static final String REVIEW_BOOKING_OUTCOME = "reviewBooking"; + + private BookingService bookingService; + + private Long hotelId; + + private Hotel hotel = new Hotel(); + + private Booking booking = new Booking(hotel, new User()); + + private boolean initialized = false; + + public String processBooking() { + FacesContext context = FacesContext.getCurrentInstance(); + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.DAY_OF_MONTH, -1); + boolean valid = true; + if (booking.getCheckinDate().before(calendar.getTime())) { + context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, + "Check in date must be a future date.", "Check in date must be a future date.")); + valid = false; + } else if (!booking.getCheckinDate().before(booking.getCheckoutDate())) { + context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, + "Check out date must be later than check in date", + "Check out date must be later than check in date")); + valid = false; + } + if (valid) { + return REVIEW_BOOKING_OUTCOME; + } else { + return null; + } + } + + public String confirm() { + bookingService.saveBooking(booking); + FacesContext.getCurrentInstance().getExternalContext().getSessionMap().remove("booking"); + return "confirm"; + } + + public String cancel() { + FacesContext.getCurrentInstance().getExternalContext().getSessionMap().remove("booking"); + return "cancel"; + } + + public Long getHotelId() { + return hotelId; + } + + public void setHotelId(Long hotelId) { + if (hotelId != null && hotelId != 0 && !initialized) { + booking = bookingService.createBooking(hotelId, "jeremy"); + FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("booking", booking); + initialized = true; + } + this.hotelId = hotelId; + } + + public Hotel getHotel() { + return hotel; + } + + public void setHotel(Hotel hotel) { + this.hotel = hotel; + } + + public Booking getBooking() { + return booking; + } + + public void setBooking(Booking booking) { + this.booking = booking; + } + + public void setBookingService(BookingService bookingService) { + this.bookingService = bookingService; + } +} diff --git a/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/BookingService.java b/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/BookingService.java new file mode 100644 index 00000000..955b5a40 --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/BookingService.java @@ -0,0 +1,52 @@ +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 findBookings(String username); + + /** + * Find hotels available for booking by some criteria. + * @param criteria the search criteria + * @return a list of hotels meeting the criteria + */ + public List findHotels(SearchCriteria criteria); + + /** + * Find hotels by their identifier. + * @param id the hotel id + * @return the hotel + */ + public Hotel findHotelById(Long id); + + /** + * Create a new, transient hotel booking instance for the given user. + * @param hotelId the hotelId + * @param userName the user name + * @return the new transient booking instance + */ + public Booking createBooking(Long hotelId, String userName); + + /** + * Cancel an existing booking. + * @param booking the booking to cancel + */ + public void cancelBooking(Booking booking); + + /** + * Save a new booking. + * @param booking the booking to save + */ + public void saveBooking(Booking booking); + +} diff --git a/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/Hotel.java b/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/Hotel.java new file mode 100644 index 00000000..3715a98a --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/Hotel.java @@ -0,0 +1,110 @@ +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; + } + + public Booking createBooking(User user) { + return new Booking(this, user); + } + + @Override + public String toString() { + return "Hotel(" + name + "," + address + "," + city + "," + zip + ")"; + } +} diff --git a/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/HotelController.java b/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/HotelController.java new file mode 100644 index 00000000..8d32150f --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/HotelController.java @@ -0,0 +1,29 @@ +package org.springframework.webflow.samples.booking; + +public class HotelController { + + private BookingService bookingService; + + private Long hotelId; + + private Hotel hotel; + + public Hotel getHotel() { + if (hotel == null && hotelId != null) { + hotel = bookingService.findHotelById(hotelId); + } + return hotel; + } + + public void setBookingService(BookingService bookingService) { + this.bookingService = bookingService; + } + + public void setHotelId(Long hotelId) { + this.hotelId = hotelId; + } + + public Long getHotelId() { + return hotelId; + } +} diff --git a/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/JpaBookingService.java b/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/JpaBookingService.java new file mode 100644 index 00000000..1e11cae6 --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/JpaBookingService.java @@ -0,0 +1,92 @@ +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; +import org.springframework.util.StringUtils; + +/** + * 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("bookingService") +@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 findBookings(String username) { + if (username != null) { + return em.createQuery("select b from Booking b where b.user.username = :username order by b.checkinDate") + .setParameter("username", username).getResultList(); + } else { + return null; + } + } + + @Transactional(readOnly = true) + @SuppressWarnings("unchecked") + public List 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); + } + + @Transactional(readOnly = true) + public Booking createBooking(Long hotelId, String username) { + Hotel hotel = em.find(Hotel.class, hotelId); + User user = findUser(username); + return new Booking(hotel, user); + } + + // read-write transactional methods + @Transactional + public void cancelBooking(Booking booking) { + booking = em.find(Booking.class, booking.getId()); + if (booking != null) { + em.remove(booking); + } + } + + // read-write transactional methods + @Transactional + public void saveBooking(Booking booking) { + em.persist(booking); + } + + // helpers + + private String getSearchPattern(SearchCriteria criteria) { + if (StringUtils.hasText(criteria.getSearchString())) { + return "'%" + criteria.getSearchString().toLowerCase().replace('*', '%') + "%'"; + } else { + return "'%'"; + } + } + + private User findUser(String username) { + return (User) em.createQuery("select u from User u where u.username = :username").setParameter("username", + username).getSingleResult(); + } + +} \ No newline at end of file diff --git a/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/ReferenceData.java b/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/ReferenceData.java new file mode 100644 index 00000000..4c499aaf --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/ReferenceData.java @@ -0,0 +1,83 @@ +package org.springframework.webflow.samples.booking; + +import java.util.ArrayList; +import java.util.List; + +import javax.faces.model.SelectItem; + +import org.springframework.stereotype.Service; + +@Service +public class ReferenceData { + + private List bedOptions; + + private List smokingOptions; + + private List creditCardExpMonths; + + private List creditCardExpYears; + + private List pageSizeOptions; + + public List getBedOptions() { + if (bedOptions == null) { + bedOptions = new ArrayList(); + 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 getSmokingOptions() { + if (smokingOptions == null) { + smokingOptions = new ArrayList(); + smokingOptions.add(new SelectItem(Boolean.TRUE, "Smoking")); + smokingOptions.add(new SelectItem(Boolean.FALSE, "Non-Smoking")); + } + return smokingOptions; + } + + public List getCreditCardExpMonths() { + if (creditCardExpMonths == null) { + creditCardExpMonths = new ArrayList(); + 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 getCreditCardExpYears() { + if (creditCardExpYears == null) { + creditCardExpYears = new ArrayList(); + creditCardExpYears.add(new SelectItem(new Integer(2008), "2008")); + creditCardExpYears.add(new SelectItem(new Integer(2009), "2009")); + creditCardExpYears.add(new SelectItem(new Integer(2010), "2010")); + creditCardExpYears.add(new SelectItem(new Integer(2010), "2011")); + creditCardExpYears.add(new SelectItem(new Integer(2010), "2012")); + } + return creditCardExpYears; + } + + public List getPageSizeOptions() { + if (pageSizeOptions == null) { + pageSizeOptions = new ArrayList(); + 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; + } + +} diff --git a/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/SearchController.java b/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/SearchController.java new file mode 100644 index 00000000..b5981e95 --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/SearchController.java @@ -0,0 +1,65 @@ +package org.springframework.webflow.samples.booking; + +import java.util.List; + +import javax.faces.event.ActionEvent; +import javax.faces.model.DataModel; +import javax.faces.model.ListDataModel; + +public class SearchController { + + private BookingService bookingService; + + private SearchCriteria searchCriteria = new SearchCriteria(); + + private DataModel hotels = null; + + private DataModel bookings = null; + + public String search() { + searchCriteria.resetPage(); + executeSearch(); + return "reviewHotels"; + } + + public void nextListener(ActionEvent event) { + searchCriteria.nextPage(); + executeSearch(); + } + + public void prevListener(ActionEvent event) { + searchCriteria.previousPage(); + executeSearch(); + } + + private void executeSearch() { + hotels = new ListDataModel(); + hotels.setWrappedData(bookingService.findHotels(searchCriteria)); + } + + public SearchCriteria getSearchCriteria() { + return searchCriteria; + } + + public void setBookingService(BookingService bookingService) { + this.bookingService = bookingService; + } + + public DataModel getHotels() { + return hotels; + } + + public DataModel getBookings() { + if (bookings == null) { + bookings = new ListDataModel(bookingService.findBookings("jeremy")); + } + return bookings; + } + + public void cancelBookingListener(ActionEvent event) { + Booking booking = (Booking) bookings.getRowData(); + bookingService.cancelBooking(booking); + ((List) bookings.getWrappedData()).remove(booking); + } + +} diff --git a/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/SearchCriteria.java b/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/SearchCriteria.java new file mode 100644 index 00000000..0a1b92dc --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/SearchCriteria.java @@ -0,0 +1,66 @@ +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; + } + + public void nextPage() { + page++; + } + + public void previousPage() { + page--; + } + + public void resetPage() { + page = 0; + } + + public String toString() { + return "[Search Criteria searchString = '" + searchString + "'"; + } +} \ No newline at end of file diff --git a/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/User.java b/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/User.java new file mode 100644 index 00000000..494e9ddd --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/User.java @@ -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 + ")"; + } +} diff --git a/spring-webflow-samples/jsf-booking/src/main/resources/META-INF/persistence.xml b/spring-webflow-samples/jsf-booking/src/main/resources/META-INF/persistence.xml new file mode 100644 index 00000000..f4e3d6a7 --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,18 @@ + + + + org.hibernate.ejb.HibernatePersistence + org.springframework.webflow.samples.booking.User + org.springframework.webflow.samples.booking.Booking + org.springframework.webflow.samples.booking.Hotel + + + + + + + + \ No newline at end of file diff --git a/spring-webflow-samples/jsf-booking/src/main/resources/import.sql b/spring-webflow-samples/jsf-booking/src/main/resources/import.sql new file mode 100644 index 00000000..9a7ed4a9 --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/resources/import.sql @@ -0,0 +1,27 @@ +insert into Customer (username, name) values ('keith', 'Keith') +insert into Customer (username, name) values ('erwin', 'Erwin') +insert into Customer (username, name) values ('jeremy', 'Jeremy') +insert into Customer (username, name) values ('scott', 'Scott') +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, 60, 'Jameson Inn', '890 Palm Bay Rd NE', 'Palm Bay', 'FL', '32905', 'USA') +insert into Hotel (id, price, name, address, city, state, zip, country) values (3, 199, 'Chilworth Manor', 'The Cottage, Southampton Business Park', 'Southampton', 'Hants', 'SO16 7JF', 'UK') +insert into Hotel (id, price, name, address, city, state, zip, country) values (4, 120, 'Marriott Courtyard', 'Tower Place, Buckhead', 'Atlanta', 'GA', '30305', 'USA') +insert into Hotel (id, price, name, address, city, state, zip, country) values (5, 180, 'Doubletree', 'Tower Place, Buckhead', 'Atlanta', 'GA', '30305', 'USA') +insert into Hotel (id, price, name, address, city, state, zip, country) values (6, 450, 'W Hotel', 'Union Square, Manhattan', 'NY', 'NY', '10011', 'USA') +insert into Hotel (id, price, name, address, city, state, zip, country) values (7, 450, 'W Hotel', 'Lexington Ave, Manhattan', 'NY', 'NY', '10011', 'USA') +insert into Hotel (id, price, name, address, city, state, zip, country) values (8, 250, 'Hotel Rouge', '1315 16th Street NW', 'Washington', 'DC', '20036', 'USA') +insert into Hotel (id, price, name, address, city, state, zip, country) values (9, 300, '70 Park Avenue Hotel', '70 Park Avenue', 'NY', 'NY', '10011', 'USA') +insert into Hotel (id, price, name, address, city, state, zip, country) values (10, 300, 'Conrad Miami', '1395 Brickell Ave', 'Miami', 'FL', '33131', 'USA') +insert into Hotel (id, price, name, address, city, state, zip, country) values (11, 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 (12, 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 (13, 160, 'Marriot Downtown', '55 Fourth Street', 'San Francisco', 'CA', '94103', 'USA') +insert into Hotel (id, price, name, address, city, state, zip, country) values (14, 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 (15, 210, 'Hilton Tel Aviv', 'Independence Park', 'Tel Aviv', '', '63405', 'Israel') +insert into Hotel (id, price, name, address, city, state, zip, country) values (16, 240, 'InterContinental Tokyo Bay', 'Takeshiba Pier', 'Tokyo', '', '105', 'Japan') +insert into Hotel (id, price, name, address, city, state, zip, country) values (17, 130, 'Hotel Beaulac', ' Esplanade Léopold-Robert 2', 'Neuchatel', '', '2000', 'Switzerland') +insert into Hotel (id, price, name, address, city, state, zip, country) values (18, 140, 'Conrad Treasury Place', 'William & George Streets', 'Brisbane', 'QLD', '4001', 'Australia') +insert into Hotel (id, price, name, address, city, state, zip, country) values (19, 230, 'Ritz Carlton', '1228 Sherbrooke St', 'West Montreal', 'Quebec', 'H3G1H6', 'Canada') +insert into Hotel (id, price, name, address, city, state, zip, country) values (20, 460, 'Ritz Carlton', 'Peachtree Rd, Buckhead', 'Atlanta', 'GA', '30326', 'USA') +insert into Hotel (id, price, name, address, city, state, zip, country) values (21, 220, 'Swissotel', '68 Market Street', 'Sydney', 'NSW', '2000', 'Australia') +insert into Hotel (id, price, name, address, city, state, zip, country) values (22, 250, 'Meliá White House', 'Albany Street', 'Regents Park London', '', 'NW13UP', 'Great Britain') +insert into Hotel (id, price, name, address, city, state, zip, country) values (23, 210, 'Hotel Allegro', '171 West Randolph Street', 'Chicago', 'IL', '60601', 'USA') \ No newline at end of file diff --git a/spring-webflow-samples/jsf-booking/src/main/resources/log4j.xml b/spring-webflow-samples/jsf-booking/src/main/resources/log4j.xml new file mode 100644 index 00000000..f88f08cb --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/resources/log4j.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-webflow-samples/jsf-booking/src/main/webapp/META-INF/MANIFEST.MF b/spring-webflow-samples/jsf-booking/src/main/webapp/META-INF/MANIFEST.MF new file mode 100644 index 00000000..58630c02 --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/webapp/META-INF/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + diff --git a/spring-webflow-samples/jsf-booking/src/main/webapp/WEB-INF/classes/log4j.properties b/spring-webflow-samples/jsf-booking/src/main/webapp/WEB-INF/classes/log4j.properties new file mode 100644 index 00000000..992d816d --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/webapp/WEB-INF/classes/log4j.properties @@ -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 \ No newline at end of file diff --git a/spring-webflow-samples/jsf-booking/src/main/webapp/WEB-INF/faces-config.xml b/spring-webflow-samples/jsf-booking/src/main/webapp/WEB-INF/faces-config.xml new file mode 100644 index 00000000..6d4df42b --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/webapp/WEB-INF/faces-config.xml @@ -0,0 +1,108 @@ + + + + + + bookingController + org.springframework.webflow.samples.booking.BookingController + request + + + searchController + org.springframework.webflow.samples.booking.SearchController + request + + bookingService + #{bookingService} + + + + hotelController + org.springframework.webflow.samples.booking.HotelController + request + + bookingService + #{bookingService} + + + hotelId + #{param.id} + + + + bookingController + org.springframework.webflow.samples.booking.BookingController + request + + bookingService + #{bookingService} + + + hotelId + #{hotelController.hotelId} + + + booking + #{booking} + + + + searchCriteria + org.springframework.webflow.samples.booking.SearchCriteria + request + + + + + + changeSearch + /main/enterSearchCriteria.xhtml + + + + reviewHotels + /main/reviewHotels.xhtml + + + + select + /main/reviewHotel.xhtml + + + + book + /booking/enterBookingDetails.xhtml + + + + revise + /booking/enterBookingDetails.xhtml + + + + cancel + /main/enterSearchCriteria.xhtml + + + + confirm + /main/enterSearchCriteria.xhtml + + + + reviewBooking + /booking/reviewBooking.xhtml + + + + + org.springframework.web.jsf.SpringBeanVariableResolver + com.sun.facelets.FaceletViewHandler + + + + org.springframework.faces.support.RequestLoggingPhaseListener + + \ No newline at end of file diff --git a/spring-webflow-samples/jsf-booking/src/main/webapp/WEB-INF/layouts/standard.xhtml b/spring-webflow-samples/jsf-booking/src/main/webapp/WEB-INF/layouts/standard.xhtml new file mode 100644 index 00000000..99d22c52 --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/webapp/WEB-INF/layouts/standard.xhtml @@ -0,0 +1,57 @@ + + + + + + Spring Faces: Hotel Booking Sample Application + + + + + + + + + + +
+ +
+
+ + + + + + +

+

+
+
+ +
+
+ +
+ + +
+ \ No newline at end of file diff --git a/spring-webflow-samples/jsf-booking/src/main/webapp/WEB-INF/web-application-config.xml b/spring-webflow-samples/jsf-booking/src/main/webapp/WEB-INF/web-application-config.xml new file mode 100644 index 00000000..c7c97035 --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/webapp/WEB-INF/web-application-config.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-webflow-samples/jsf-booking/src/main/webapp/WEB-INF/web.xml b/spring-webflow-samples/jsf-booking/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 00000000..7bfe3828 --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,53 @@ + + + + + contextConfigLocation + + /WEB-INF/web-application-config.xml + + + + + + javax.faces.DEFAULT_SUFFIX + .xhtml + + + + + facelets.DEVELOPMENT + true + + + + + facelets.REFRESH_PERIOD + 1 + + + + org.springframework.web.context.ContextLoaderListener + + + + + Faces Servlet + javax.faces.webapp.FacesServlet + 1 + + + + + Faces Servlet + *.faces + + + + index.html + + + \ No newline at end of file diff --git a/spring-webflow-samples/jsf-booking/src/main/webapp/booking/enterBookingDetails.xhtml b/spring-webflow-samples/jsf-booking/src/main/webapp/booking/enterBookingDetails.xhtml new file mode 100644 index 00000000..a43f477c --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/webapp/booking/enterBookingDetails.xhtml @@ -0,0 +1,130 @@ + + + + + +
+

Book Hotel

+ + +
+
+
Name:
+
#{bookingController.booking.hotel.name}
+
+
+
Address:
+
#{bookingController.booking.hotel.address}
+
+
+
City, State:
+
#{bookingController.booking.hotel.city}, #{bookingController.booking.hotel.state}
+
+
+
Zip:
+
#{bookingController.booking.hotel.zip}
+
+
+
Country:
+
#{bookingController.booking.hotel.country}
+
+
+
Nightly rate:
+
+ + + +
+
+
+
+ Check In Date: +
+
+ + + + + +
+
+
+
+ Check Out Date: +
+
+ + + + + +
+
+
+
+ Room Preference: +
+
+ + + +
+
+
+
+ Smoking Preference: +
+
+ + + +
+
+
+
+ Credit Card #: +
+
+ + + +
+
+
+
+ Credit Card Name: +
+
+ + + +
+
+
+
+ Expiration Date: +
+
+ + + + + + +
+
+
+   + +
+
+
+
+ +
+
\ No newline at end of file diff --git a/spring-webflow-samples/jsf-booking/src/main/webapp/booking/reviewBooking.xhtml b/spring-webflow-samples/jsf-booking/src/main/webapp/booking/reviewBooking.xhtml new file mode 100644 index 00000000..d4d43235 --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/webapp/booking/reviewBooking.xhtml @@ -0,0 +1,76 @@ + + + + + +
+

Confirm Hotel Booking

+
+ +
+ +
+
+
Name:
+
#{booking.hotel.name}
+
+
+
Address:
+
#{booking.hotel.address}
+
+
+
City, State:
+
#{booking.hotel.city}, #{booking.hotel.state}
+
+
+
Zip:
+
#{booking.hotel.zip}
+
+
+
Country:
+
#{booking.hotel.country}
+
+
+
Total payment:
+
+ + + +
+
+
+
Check In Date:
+
+ + + +
+
+
+
Check Out Date:
+
+ + + +
+
+
+
Credit Card #:
+
#{booking.creditCard}
+
+
+   +   + +
+
+
+
+ +
+
\ No newline at end of file diff --git a/spring-webflow-samples/jsf-booking/src/main/webapp/css-framework/css/forms.css b/spring-webflow-samples/jsf-booking/src/main/webapp/css-framework/css/forms.css new file mode 100644 index 00000000..f92b8058 --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/webapp/css-framework/css/forms.css @@ -0,0 +1,100 @@ +/* A CSS Framework by Mike Stenhouse of Content with Style */ + +/* FORM ELEMENTS */ + form { + margin:0; + padding:0; + } + form div, + form p { + font-size: 1em; + margin: 0 0 1em 0; + padding: 0; + } + label { + font-weight: bold; + } + fieldset { + border: 1px solid #eee; + padding: 5px 10px; + margin: 0 0 1.5em 0; + } + fieldset legend { + color: #666; + font-size: 1.1em; + font-weight: bold; + margin: 0 0 0 0px; + padding: 0; + background-color: white; + } + * html fieldset legend { + margin: 0 0 10px -10px; + } + fieldset ul { + list-style: none; + margin: 0 0 1.5em 0; + padding: 0; + } + fieldset ul li { + list-style: none; + margin: 0 0 0.5em 0; + padding: 0; + } + + + input, select, textarea { + font-size:1em; + font-family: arial, helvetica, verdana, sans-serif; + + margin: 0; + padding: 2px; + } + + input, select { + vertical-align:middle; + } + textarea { + width: 200px; + height: 8em; + } + + input.check { + border: none; + width: auto; + height: auto; + margin: 0; + } + input.radio { + border: none; + width: auto; + height: auto; + margin: 0; + } + input.file { + height: auto; + width: 250px; + } + input.readonly { + background-color: transparent; + border: none; + } + input.button { + width: 10em; + border:1px solid black; + background-color: #ddd; + } + input.image { + border: none; + width: auto; + height: auto; + } + + form div.submit { + margin: 1em 0; + } + form div.submit input { + height: 2em; + width: 15em; + } +/* END FORM ELEMENTS */ + \ No newline at end of file diff --git a/spring-webflow-samples/jsf-booking/src/main/webapp/css-framework/css/layout-1col.css b/spring-webflow-samples/jsf-booking/src/main/webapp/css-framework/css/layout-1col.css new file mode 100644 index 00000000..0215f837 --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/webapp/css-framework/css/layout-1col.css @@ -0,0 +1,27 @@ +/* A CSS Framework by Mike Stenhouse of Content with Style */ + +@import url("nav-horizontal.css"); + +/* NAV BAR AT THE TOP AND ONE COLUMN OF CONTENT */ + div#content { + position: relative; + width: 701px; + + margin: 0 auto 20px auto; + padding: 0; + + text-align: left; + } + div#main { + width: 100%; + } + div#local { + display: none; + } + div#sub { + display: none; + } + div#nav { + display: none; + } +/* END CONTENT */ \ No newline at end of file diff --git a/spring-webflow-samples/jsf-booking/src/main/webapp/css-framework/css/layout-navleft-1col.css b/spring-webflow-samples/jsf-booking/src/main/webapp/css-framework/css/layout-navleft-1col.css new file mode 100644 index 00000000..1d596bf8 --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/webapp/css-framework/css/layout-navleft-1col.css @@ -0,0 +1,31 @@ +/* A CSS Framework by Mike Stenhouse of Content with Style */ + +@import url("nav-vertical.css"); + +/* NAV BAR ON THE LEFT AND ONE COLUMN OF CONTENT */ + div#content { + position: relative; + width: 780px; + + margin: 0 auto 20px auto; + padding: 0; + + text-align: left; + } + div#main { + float: right; + width: 560px; + display: inline; + } + div#local { + display: none; + } + div#sub { + display: none; + } + div#nav { + float: left; + width: 200px; + display: inline; + } +/* END CONTENT */ \ No newline at end of file diff --git a/spring-webflow-samples/jsf-booking/src/main/webapp/css-framework/css/layout-navleft-2col.css b/spring-webflow-samples/jsf-booking/src/main/webapp/css-framework/css/layout-navleft-2col.css new file mode 100644 index 00000000..5cba5628 --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/webapp/css-framework/css/layout-navleft-2col.css @@ -0,0 +1,39 @@ +/* A CSS Framework by Mike Stenhouse of Content with Style */ + +@import url("nav-vertical.css"); + +/* NAV BAR ON THE LEFT AND TWO COLUMNS OF CONTENT */ + div#content { + position: relative; + width: 780px; + + margin: 0 auto 20px auto; + padding: 0; + + text-align: left; + } + div#main { + float: right; + width: 340px; + display: inline; + + margin-right: 220px; + margin-left: -220px; + } + div#local { + display: none; + } + div#sub { + float: right; + width: 200px; + display: inline; + + margin-right: -340px; + margin-left: 200px; + } + div#nav { + float: left; + width: 200px; + display: inline; + } +/* END CONTENT */ \ No newline at end of file diff --git a/spring-webflow-samples/jsf-booking/src/main/webapp/css-framework/css/layout-navtop-1col.css b/spring-webflow-samples/jsf-booking/src/main/webapp/css-framework/css/layout-navtop-1col.css new file mode 100644 index 00000000..ef413731 --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/webapp/css-framework/css/layout-navtop-1col.css @@ -0,0 +1,32 @@ +/* A CSS Framework by Mike Stenhouse of Content with Style */ + +@import url("nav-horizontal.css"); + +/* NAV BAR AT THE TOP AND ONE COLUMN OF CONTENT */ + div#content { + position: relative; + width: 701px; + + margin: 0 auto 20px auto; + padding: 0; + + text-align: left; + } + div#main { + width: 100%; + } + div#local { + width: 100%; + } + div#sub { + width: 100%; + } + div#nav { + position: absolute; + top: -15px; + left: 0; + width: 100%; + + text-align: left; + } +/* END CONTENT */ \ No newline at end of file diff --git a/spring-webflow-samples/jsf-booking/src/main/webapp/css-framework/css/layout-navtop-3col.css b/spring-webflow-samples/jsf-booking/src/main/webapp/css-framework/css/layout-navtop-3col.css new file mode 100644 index 00000000..352af577 --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/webapp/css-framework/css/layout-navtop-3col.css @@ -0,0 +1,43 @@ +/* A CSS Framework by Mike Stenhouse of Content with Style */ + +@import url("nav-horizontal.css"); + +/* NAV BAR AT THE TOP, LOCAL NAV ON THE LEFT AND TWO COLUMNS OF CONTENT */ + div#content { + position: relative; + width: 701px; + + margin: 0 auto 20px auto; + padding: 0; + + text-align: left; + } + div#main { + float: left; + width: 300px; + display: inline; + + margin-right: -200px; + margin-left: 200px; + } + div#sub { + float: right; + width: 180px; + display: inline; + } + div#local { + float: left; + width: 180px; + display: inline; + + margin-left: -300px; + } + div#nav { + position: absolute; + top: -15px; + left: 0; + width: 701px; + + text-align: left; + } +/* END CONTENT */ \ No newline at end of file diff --git a/spring-webflow-samples/jsf-booking/src/main/webapp/css-framework/css/layout-navtop-localleft.css b/spring-webflow-samples/jsf-booking/src/main/webapp/css-framework/css/layout-navtop-localleft.css new file mode 100644 index 00000000..a63a7c01 --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/webapp/css-framework/css/layout-navtop-localleft.css @@ -0,0 +1,36 @@ +/* A CSS Framework by Mike Stenhouse of Content with Style */ + +@import url("nav-horizontal.css"); + +/* NAV BAR AT THE TOP, LOCAL NAVIGATION ON THE LEFT AND ONE COLUMN OF CONTENT */ + div#content { + position: relative; + width: 701px; + + margin: 0 auto 20px auto; + padding: 0; + + text-align: left; + } + div#main { + float: right; + width: 500px; + display: inline; + } + div#local { + float: left; + width: 200px; + display: inline; + } + div#sub { + display: none; + } + div#nav { + position: absolute; + top: -15px; + left: 0; + width: 100%; + + text-align: left; + } +/* END CONTENT */ \ No newline at end of file diff --git a/spring-webflow-samples/jsf-booking/src/main/webapp/css-framework/css/layout-navtop-subright.css b/spring-webflow-samples/jsf-booking/src/main/webapp/css-framework/css/layout-navtop-subright.css new file mode 100644 index 00000000..7f219a4b --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/webapp/css-framework/css/layout-navtop-subright.css @@ -0,0 +1,36 @@ +/* A CSS Framework by Mike Stenhouse of Content with Style */ + +@import url("nav-horizontal.css"); + +/* NAV BAR AT THE TOP AND TWO COLUMNS OF CONTENT */ + div#content { + position: relative; + width: 701px; + + margin: 0 auto 20px auto; + padding: 0; + + text-align: left; + } + div#main { + float: left; + width: 480px; + display: inline; + } + div#sub { + float: right; + width: 200px; + display: inline; + } + div#local { + display: none; + } + div#nav { + position: absolute; + top: -15px; + left: 0; + width: 100%; + + text-align: left; + } +/* END CONTENT */ \ No newline at end of file diff --git a/spring-webflow-samples/jsf-booking/src/main/webapp/css-framework/css/layout.css b/spring-webflow-samples/jsf-booking/src/main/webapp/css-framework/css/layout.css new file mode 100644 index 00000000..57958b5d --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/webapp/css-framework/css/layout.css @@ -0,0 +1,125 @@ +/* A CSS Framework by Mike Stenhouse of Content with Style */ + +/* SITE SPECIFIC LAYOUT */ + body { + margin: 0; + padding: 0; + + background: white; + + text-align: center; + } + div#page { + width: 780px; + + margin: 0 auto; + padding: 0; + + background: white; + text-align: center; + } + + /* HEADER */ + div#header { + margin: 0 0 5em 0; + padding: 40px 20px; + + color: white; + background: black; + + text-align: left; + } + div#branding { + float: left; + width: 40%; + + margin: 0; + padding: 10px 0 10px 20px; + + text-align: left; + } + div#search { + float: right; + width: 49%; + + margin: 0; + padding: 16px 20px 0 0; + + text-align: right; + } + /* END HEADER */ + + + /* CONTENT */ + div#content { + + } + + /* MAIN */ + div#main { + + } + /* END MAIN */ + + /* SUB */ + div#sub { + + } + /* END SUB */ + + /* END CONTENT */ + + + /* FOOTER */ + div#footer { + color: white; + background-color: black; + } + div#footer p { + font-size: 0.8em; + + margin: 0; + padding: 15px; + } + /* END FOOTER */ +/* END LAYOUT */ + + + + +/* UL.SUBNAV */ + ul.subnav { + margin: 0; + padding: 0; + + font-size: 0.8em; + list-style: none; + } + ul.subnav li { + margin: 0 0 1em 0; + padding: 0; + list-style: none; + } + ul.subnav li a, + ul.subnav li a:link, + ul.subnav li a:visited, + ul.subnav li a:active { + text-decoration: none; + font-weight: bold; + color: black; + } + ul.subnav li a:hover { + text-decoration: underline; + } + ul.subnav li strong { + padding: 0 0 0 12px; + background: url("../i/subnav-highlight.gif") left top no-repeat transparent; + } + ul.subnav li strong a, + ul.subnav li strong a:link, + ul.subnav li strong a:visited, + ul.subnav li strong a:active { + color: white; + background-color: black; + } +/* END UL.SUBNAV */ diff --git a/spring-webflow-samples/jsf-booking/src/main/webapp/css-framework/css/nav-horizontal.css b/spring-webflow-samples/jsf-booking/src/main/webapp/css-framework/css/nav-horizontal.css new file mode 100644 index 00000000..8a8e3196 --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/webapp/css-framework/css/nav-horizontal.css @@ -0,0 +1,80 @@ +/* A CSS Framework by Mike Stenhouse of Content with Style */ + +/* NAV */ + div#nav { + font-size: 0.8em; + } + * html div#nav { + /* hide ie/mac \*/ + height: 1%; + /* end hide */ + } + div#nav div.wrapper { + position: absolute; + left: 0; + bottom: 0; + width: 100%; + } + div#nav ul { + width: auto; + width: 100%; + + margin: 0; + padding: 0; + + line-height: 1em; + list-style: none; + } + div#nav li { + float: left; + display: inline; + + list-style: none; + + margin: 0; + padding: 0; + + line-height: 1em; + border-right: 1px solid #aaa; + } + div#nav li.last { + border-right: none; + } + div#nav a, + div#nav a:link, + div#nav a:active, + div#nav a:visited { + display: inline-block; + /* hide from ie/mac \*/ + display: block; + /* end hide */ + font-weight: bold; + text-decoration: none; + + margin: 0; + padding: 5px 38px 5px 38px; + + color: black; + background: #ddd; + } + div#nav a:hover { + text-decoration: underline; + } + div#nav strong { + display: inline-block; + /* hide from ie/mac \*/ + display: block; + /* end hide */ + + color: white; + background: black; + } + div#nav strong a, + div#nav strong a:link, + div#nav strong a:active, + div#nav strong a:visited, + div#nav strong a:hover { + color: white; + background-color: black; + } +/* END NAV */ \ No newline at end of file diff --git a/spring-webflow-samples/jsf-booking/src/main/webapp/css-framework/css/nav-vertical.css b/spring-webflow-samples/jsf-booking/src/main/webapp/css-framework/css/nav-vertical.css new file mode 100644 index 00000000..1f57bd25 --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/webapp/css-framework/css/nav-vertical.css @@ -0,0 +1,79 @@ +/* A CSS Framework by Mike Stenhouse of Content with Style */ + +/* NAV */ + div#nav { + font-size: 0.8em; + } + * html div#nav { + /* hide ie/mac \*/ + height: 1%; + /* end hide */ + } + div#nav div.wrapper { + width: 100%; + + background: #ddd; + } + div#nav ul { + width: auto; + width: 100%; + + margin: 0; + padding: 0; + + line-height: 1em; + list-style: none; + } + div#nav li { + display: block; + + list-style: none; + + margin: 0; + padding: 0; + + line-height: 1em; + } + * html div#nav li { + /* hide ie/mac \*/ + height: 1%; + /* end hide */ + } + div#nav li.last { + + } + div#nav a, + div#nav a:link, + div#nav a:active, + div#nav a:visited { + display: block; + + font-weight: bold; + text-decoration: none; + + margin: 0; + padding: 5px 10px 5px 10px; + + color: black; + background: white; + } + div#nav a:hover { + color: white; + background: black; + text-decoration: underline; + } + div#nav strong { + display: block; + + color: white; + background: black; + } + div#nav strong a, + div#nav strong a:link, + div#nav strong a:active, + div#nav strong a:visited, + div#nav strong a:hover { + color: white; + background-color: black; + } +/* END NAV */ \ No newline at end of file diff --git a/spring-webflow-samples/jsf-booking/src/main/webapp/css-framework/css/tools.css b/spring-webflow-samples/jsf-booking/src/main/webapp/css-framework/css/tools.css new file mode 100644 index 00000000..3219ebd8 --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/webapp/css-framework/css/tools.css @@ -0,0 +1,68 @@ +/* A CSS Framework by Mike Stenhouse of Content with Style */ + +/* clearing */ + .stretch, + .clear { + clear:both; + height:1px; + margin:0; + padding:0; + font-size: 15px; + line-height: 1px; + } + .clearfix:after { + content: "."; + display: block; + height: 0; + clear: both; + visibility: hidden; + } + * html>body .clearfix { + display: inline-block; + width: 100%; + } + + * html .clearfix { + /* Hides from IE-mac \*/ + height: 1%; + /* End hide from IE-mac */ + } +/* end clearing */ + + +/* replace */ + .replace { + display:block; + + background-repeat: no-repeat; + background-position: left top; + background-color:transparent; + } + /* tidy these up */ + .replace * { + text-indent: -10000px; + display:block; + + background-repeat: no-repeat; + background-position: left top; + background-color:transparent; + } + .replace a { + text-indent:0; + } + .replace a span { + text-indent:-10000px; + } +/* end replace */ + + +/* accessibility */ + span.accesskey { + text-decoration:none; + } + .accessibility { + position: absolute; + top: -999em; + left: -999em; + } +/* end accessibility */ \ No newline at end of file diff --git a/spring-webflow-samples/jsf-booking/src/main/webapp/css-framework/css/typo.css b/spring-webflow-samples/jsf-booking/src/main/webapp/css-framework/css/typo.css new file mode 100644 index 00000000..b159e6dc --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/webapp/css-framework/css/typo.css @@ -0,0 +1,177 @@ +/* A CSS Framework by Mike Stenhouse of Content with Style */ + +/* TYPOGRAPHY */ + body { + text-align: left; + font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; + font-size: 76%; + line-height: 1em; + color: #333; + } + div { + font-size: 1em; + } + img { + border: 0; + } + +/* LINKS */ + a, + a:link + a:active { + color: blue; + background-color: white; + text-decoration: underline; + } + a:visited { + color: purple; + background-color: transparent; + } + a:hover { + color: white; + background-color: black; + text-decoration: none; + } +/* END LINKS */ + +/* HEADINGS */ + h1 { + font-size: 2em; + line-height: 1.5em; + margin: 0 0 0.5em 0; + padding: 0; + color: black; + } + h2 { + font-size: 1.5em; + line-height: 1.5em; + margin: 0 0 0.5em 0; + padding: 0; + color: black; + } + h3 { + font-size: 1.3em; + line-height: 1.3em; + margin: 0 0 0.5em 0; + padding:0; + color: black; + } + h4 { + font-size: 1.2em; + line-height: 1.3em; + margin: 0 0 0.25em 0; + padding: 0; + color: black; + } + h5 { + font-size: 1.1em; + line-height: 1.3em; + margin: 0 0 0.25em 0; + padding: 0; + color: black; + } + h6 { + font-size: 1em; + line-height: 1.3em; + margin: 0 0 0.25em 0; + padding: 0; + color: black; + } +/* END HEADINGS */ + +/* TEXT */ + p { + font-size: 1em; + margin: 0 0 1.5em 0; + padding: 0; + line-height:1.4em; + } + blockquote { + border-left:10px solid #ddd; + margin-left:10px; + } + pre { + font-family: monospace; + font-size: 1.0em; + } + strong, b { + font-weight: bold; + } + em, i { + font-style:italic; + } + code { + font-family: "Courier New", Courier, monospace; + font-size: 1em; + white-space: pre; + } +/* END TEXT */ + +/* LISTS */ + ul { + line-height:1.4em; + margin: 0 0 1.5em 0; + padding: 0; + } + ul li { + margin: 0 0 0.25em 30px; + padding: 0; + } + ol { + font-size: 1.0em; + line-height: 1.4em; + margin: 0 0 1.5em 0; + padding: 0; + } + ol li { + font-size: 1.0em; + margin: 0 0 0.25em 30px; + padding: 0; + } + dl { + margin: 0 0 1.5em 0; + padding: 0; + line-height: 1.4em; + } + dl dt { + font-weight: bold; + margin: 0.25em 0 0.25em 0; + padding: 0; + } + dl dd { + margin: 0 0 0 30px; + padding: 0; + } +/* END LISTS */ + + +/* TABLE */ + table { + font-size: 1em; + margin: 0 0 1.5em 0; + padding: 0; + } + table caption { + font-weight: bold; + margin: 0 0 0 0; + padding: 0 0 1.5em 0; + } + th { + font-weight: bold; + text-align: left; + } + td { + font-size: 1em; + } +/* END TABLE */ + + hr { + display: none; + } + div.hr { + height: 1px; + margin: 1.5em 10px; + border-bottom: 1px dotted black; + } + +/* END TYPOGRAPHY */ \ No newline at end of file diff --git a/spring-webflow-samples/jsf-booking/src/main/webapp/images/bg.gif b/spring-webflow-samples/jsf-booking/src/main/webapp/images/bg.gif new file mode 100644 index 00000000..013cfa6f Binary files /dev/null and b/spring-webflow-samples/jsf-booking/src/main/webapp/images/bg.gif differ diff --git a/spring-webflow-samples/jsf-booking/src/main/webapp/images/btn.bg.gif b/spring-webflow-samples/jsf-booking/src/main/webapp/images/btn.bg.gif new file mode 100644 index 00000000..87256cf4 Binary files /dev/null and b/spring-webflow-samples/jsf-booking/src/main/webapp/images/btn.bg.gif differ diff --git a/spring-webflow-samples/jsf-booking/src/main/webapp/images/diplomat.jpg b/spring-webflow-samples/jsf-booking/src/main/webapp/images/diplomat.jpg new file mode 100644 index 00000000..e1d0c9cd Binary files /dev/null and b/spring-webflow-samples/jsf-booking/src/main/webapp/images/diplomat.jpg differ diff --git a/spring-webflow-samples/jsf-booking/src/main/webapp/images/header.jpg b/spring-webflow-samples/jsf-booking/src/main/webapp/images/header.jpg new file mode 100644 index 00000000..0be0d4d7 Binary files /dev/null and b/spring-webflow-samples/jsf-booking/src/main/webapp/images/header.jpg differ diff --git a/spring-webflow-samples/jsf-booking/src/main/webapp/images/input.bg.gif b/spring-webflow-samples/jsf-booking/src/main/webapp/images/input.bg.gif new file mode 100644 index 00000000..8ebf87e3 Binary files /dev/null and b/spring-webflow-samples/jsf-booking/src/main/webapp/images/input.bg.gif differ diff --git a/spring-webflow-samples/jsf-booking/src/main/webapp/images/powered-by-spring.png b/spring-webflow-samples/jsf-booking/src/main/webapp/images/powered-by-spring.png new file mode 100644 index 00000000..e773b170 Binary files /dev/null and b/spring-webflow-samples/jsf-booking/src/main/webapp/images/powered-by-spring.png differ diff --git a/spring-webflow-samples/jsf-booking/src/main/webapp/images/th.bg.gif b/spring-webflow-samples/jsf-booking/src/main/webapp/images/th.bg.gif new file mode 100644 index 00000000..4663cf51 Binary files /dev/null and b/spring-webflow-samples/jsf-booking/src/main/webapp/images/th.bg.gif differ diff --git a/spring-webflow-samples/jsf-booking/src/main/webapp/images/tse.gif b/spring-webflow-samples/jsf-booking/src/main/webapp/images/tse.gif new file mode 100644 index 00000000..b1fa98cf Binary files /dev/null and b/spring-webflow-samples/jsf-booking/src/main/webapp/images/tse.gif differ diff --git a/spring-webflow-samples/jsf-booking/src/main/webapp/index.html b/spring-webflow-samples/jsf-booking/src/main/webapp/index.html new file mode 100644 index 00000000..f3ce71ae --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/webapp/index.html @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/spring-webflow-samples/jsf-booking/src/main/webapp/intro.xhtml b/spring-webflow-samples/jsf-booking/src/main/webapp/intro.xhtml new file mode 100644 index 00000000..256a1c12 --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/webapp/intro.xhtml @@ -0,0 +1,38 @@ + + + + + +
+

Welcome to Spring Travel

+

+ This reference application illustrates Spring Faces, + a software library that integrates Spring and JavaServerFaces technology to power rich web applications. +

+

+ The key features illustrated in this sample include: +

+
    +
  • A declarative navigation model enabling full browser button support and dynamic navigation rules
  • +
  • A fine-grained state management model, including support for ConversationScope and ViewScope
  • +
  • Modularization of web application functionality by domain use case, illustrating project structure best-practices
  • +
  • Managed persistence contexts with the Java Persistence API (JPA)
  • +
  • Unified Expression Language (EL) integration
  • +
  • Spring Security integration
  • +
  • Declarative page authoring with Facelets, including applying reusable page layouts
  • +
  • A lightweight component library for Ajax and client-side validation that employs progressive enhancement techniques
  • +
  • Exception handling support across all layers of the application
  • +
  • Spring IDE tooling integration, with support for graphical flow modeling and visualization
  • +
+

+ Start your Spring Travel experience +

+
+ +
+
\ No newline at end of file diff --git a/spring-webflow-samples/jsf-booking/src/main/webapp/main/enterSearchCriteria.xhtml b/spring-webflow-samples/jsf-booking/src/main/webapp/main/enterSearchCriteria.xhtml new file mode 100644 index 00000000..e9fdaed5 --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/webapp/main/enterSearchCriteria.xhtml @@ -0,0 +1,77 @@ + + + + + +
+ + + +

Search Hotels

+ +
+
+
+ +
+
+ Maximum results: + + + +
+
+ +
+
+
+
+
+ +
+ +

Current Hotel Bookings

+ + + + Name + #{booking.hotel.name} + + + Address + #{booking.hotel.address} + + + City, State + #{booking.hotel.city}, #{booking.hotel.state} + + + Check in date + + + + + + Check out date + + + + + + Confirmation number + #{booking.id} + + + Action + + + +
+
+ +
+
\ No newline at end of file diff --git a/spring-webflow-samples/jsf-booking/src/main/webapp/main/reviewHotel.xhtml b/spring-webflow-samples/jsf-booking/src/main/webapp/main/reviewHotel.xhtml new file mode 100644 index 00000000..5928e67a --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/webapp/main/reviewHotel.xhtml @@ -0,0 +1,58 @@ + + + + + +
+

View Hotel

+
+
Name:
+
#{hotelController.hotel.name}
+
+
+
Address:
+
#{hotelController.hotel.address}
+
+
+
City:
+
#{hotelController.hotel.city}
+
+
+
State:
+
#{hotelController.hotel.state}
+
+
+
Zip:
+
#{hotelController.hotel.zip}
+
+
+
Country:
+
#{hotelController.hotel.country}
+
+
+
Nightly rate:
+
+ + + +
+
+
+ +
+ +
+   + +
+
+
+ +
+
\ No newline at end of file diff --git a/spring-webflow-samples/jsf-booking/src/main/webapp/main/reviewHotels.xhtml b/spring-webflow-samples/jsf-booking/src/main/webapp/main/reviewHotels.xhtml new file mode 100644 index 00000000..097f4440 --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/webapp/main/reviewHotels.xhtml @@ -0,0 +1,57 @@ + + + + + + +
+

Hotel Results

+

+ +

+ +
+ + + + Name + #{hotel.name} + + + Address + #{hotel.address} + + + City, State + #{hotel.city}, #{hotel.state}, #{hotel.country} + + + Zip + #{hotel.zip} + + + Action + View Hotel + + + + +
+
+ + + +
+ +
+
+
+
\ No newline at end of file diff --git a/spring-webflow-samples/jsf-booking/src/main/webapp/styles/booking.css b/spring-webflow-samples/jsf-booking/src/main/webapp/styles/booking.css new file mode 100644 index 00000000..54c6c24d --- /dev/null +++ b/spring-webflow-samples/jsf-booking/src/main/webapp/styles/booking.css @@ -0,0 +1,187 @@ + a, a:visited, a:link, a:active { + color: #59924B; + background-color: transparent; + text-decoration: none; + font-weight: bold; + } + + a:hover { + color: white; + background-color: #65a242; + text-decoration: none; + font-weight: bold; + } + + 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; + margin-bottom: 5px; + } + + #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: left; + 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%; + } + + #content .buttonGroup { + clear: both; + text-align: right; + } + + #content .buttonGroup input[type="submit"], .buttonGroup input[type="button"] { + margin-right: 5px; + } + + #content .previous { + 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; + } \ No newline at end of file