Updated to use the latest 2.0M4 enhancements.
This commit is contained in:
@@ -45,14 +45,14 @@ public class SearchCriteria implements Serializable {
|
||||
/**
|
||||
* Increase the current page
|
||||
*/
|
||||
public void nextPageListener(ActionEvent event) {
|
||||
public void nextPage() {
|
||||
page++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrease the current page
|
||||
*/
|
||||
public void prevPageListener(ActionEvent event) {
|
||||
public void prevPage() {
|
||||
page--;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,9 @@
|
||||
<property name="viewFactoryCreator">
|
||||
<bean class="org.springframework.faces.webflow.JsfViewFactoryCreator"/>
|
||||
</property>
|
||||
<property name="conversionService">
|
||||
<bean class="org.springframework.faces.model.converter.FacesConversionService"/>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- Installs a listener that manages JPA persistence contexts for flows that require them -->
|
||||
|
||||
@@ -13,42 +13,44 @@
|
||||
<h2>Hotel Results</h2>
|
||||
<p>
|
||||
<b>Search Criteria:</b> #{searchCriteria}<br/>
|
||||
<sf:commandLink value="Edit Criteria" action="changeSearch" renderIds="hotelSearchFragment"/>
|
||||
<sf:commandLink value="Edit Criteria" action="changeSearch"/>
|
||||
</p>
|
||||
<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>
|
||||
<!-- @TODO - THIS LINK DOES NOT WORK ON MYFACES 1.2.0 WHEN AJAX IS ENABLED BECAUSE THEY HAVE NOT IMPLEMENTED UIData.invokeOnComponent -->
|
||||
<sf:commandLink id="viewHotelLink" value="View Hotel" action="selectHotel"/>
|
||||
</h:column>
|
||||
</h:dataTable>
|
||||
<div class="next">
|
||||
<sf:commandLink id="nextPageLink" value="More Results" actionListener="#{searchCriteria.nextPageListener}"
|
||||
rendered="#{not empty hotels and hotels.rowCount == searchCriteria.pageSize}"
|
||||
processIds="displayHotelsForm"/>
|
||||
</div>
|
||||
<div class="prev">
|
||||
<sf:commandLink id="prevPageLink" value="Previous results" actionListener="#{searchCriteria.prevPageListener}"
|
||||
rendered="#{searchCriteria.page > 0}"
|
||||
processIds="displayHotelsForm"/>
|
||||
</div>
|
||||
<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>
|
||||
<!-- @TODO - THIS LINK DOES NOT WORK ON MYFACES 1.2.0 WHEN AJAX IS ENABLED BECAUSE THEY HAVE NOT IMPLEMENTED UIData.invokeOnComponent -->
|
||||
<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>
|
||||
|
||||
@@ -21,12 +21,12 @@
|
||||
<div class="searchGroup">
|
||||
<div class="searchField">
|
||||
<sf:clientTextValidator promptMessage="Search hotels by name, address, city or zip.">
|
||||
<h:inputText id="searchString" value="#{searchCriteria.searchString}" style="width: 165px; height: 15px;"/>
|
||||
<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="#{searchCriteria.pageSize}" id="pageSize">
|
||||
<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"/>
|
||||
|
||||
@@ -10,7 +10,14 @@
|
||||
|
||||
<start-actions>
|
||||
<action method="initCurrentUser" bean="mainActions" />
|
||||
<action method="findCurrentUserBookings" bean="mainActions" />
|
||||
<bean-action bean="bookingService" method="findBookings">
|
||||
<method-arguments>
|
||||
<argument expression="#{user.username}"/>
|
||||
</method-arguments>
|
||||
<method-result name="#{flowScope.bookings}" type="selectOneDataModel"/>
|
||||
</bean-action>
|
||||
<!-- <evaluate-action expression="#{bookingService.findBookings(user.username)}" result="#{flowScope.bookings}"
|
||||
type="selectOneDataModel"/> -->
|
||||
</start-actions>
|
||||
|
||||
<start-state idref="displayMain"/>
|
||||
@@ -22,14 +29,34 @@
|
||||
|
||||
<view-state id="findHotels" view="displayHotels.xhtml">
|
||||
<render-actions>
|
||||
<action method="findHotels" bean="mainActions" />
|
||||
<bean-action bean="bookingService" method="findHotels">
|
||||
<method-arguments>
|
||||
<argument expression="#{searchCriteria.searchString}"/>
|
||||
<argument expression="#{searchCriteria.pageSize}"/>
|
||||
<argument expression="#{searchCriteria.page}"/>
|
||||
</method-arguments>
|
||||
<method-result name="#{flowScope.hotels}" type="selectOneDataModel"/>
|
||||
</bean-action>
|
||||
<!-- <evaluate-action expression="#{bookingService.findHotels(searchCriteria.searchString, searchCriteria.pageSize, searchCriteria.page)}"
|
||||
result="#{flowScope.hotels}" type="selectOneDataModel"/> -->
|
||||
</render-actions>
|
||||
<transition on="previous" to="findHotels">
|
||||
<evaluate-action expression="#{searchCriteria.prevPage()}"/>
|
||||
<set attribute="#{flashScope.renderIds}" value="searchResultsFragment"/>
|
||||
</transition>
|
||||
<transition on="next" to="findHotels">
|
||||
<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="java.lang.Boolean"/>
|
||||
<entry-actions>
|
||||
<set attribute="#{flashScope.renderIds}" value="hotelSearchFragment"/>
|
||||
</entry-actions>
|
||||
<transition on="findHotels" to="findHotels" />
|
||||
</view-state>
|
||||
|
||||
@@ -61,7 +88,14 @@
|
||||
</action-state>
|
||||
|
||||
<action-state id="reloadCurrentUserBookings">
|
||||
<action method="findCurrentUserBookings" bean="mainActions" />
|
||||
<bean-action bean="bookingService" method="findBookings">
|
||||
<method-arguments>
|
||||
<argument expression="#{user.username}"/>
|
||||
</method-arguments>
|
||||
<method-result name="#{flowScope.bookings}" type="selectOneDataModel"/>
|
||||
</bean-action>
|
||||
<!-- <evaluate-action expression="#{bookingService.findBookings(user.username)}" result="#{flowScope.bookings}"
|
||||
type="selectOneDataModel"/> -->
|
||||
<transition on="success" to="displayMain" />
|
||||
</action-state>
|
||||
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
<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("/swf-booking-jsf/spring/resources/css-framework/css/tools.css");
|
||||
@import url("/swf-booking-jsf/spring/resources/css-framework/css/typo.css");
|
||||
@import url("/swf-booking-jsf/spring/resources/css-framework/css/forms.css");
|
||||
@import url("/swf-booking-jsf/spring/resources/css-framework/css/layout-navtop-localleft.css");
|
||||
@import url("/swf-booking-jsf/spring/resources/css-framework/css/layout.css");
|
||||
@import url("/swf-booking-jsf/spring/resources/css/booking.css");
|
||||
@import url("${facesContext.externalContext.requestContextPath}/spring/resources/css-framework/css/tools.css");
|
||||
@import url("${facesContext.externalContext.requestContextPath}/spring/resources/css-framework/css/typo.css");
|
||||
@import url("${facesContext.externalContext.requestContextPath}/spring/resources/css-framework/css/forms.css");
|
||||
@import url("${facesContext.externalContext.requestContextPath}/spring/resources/css-framework/css/layout-navtop-localleft.css");
|
||||
@import url("${facesContext.externalContext.requestContextPath}/spring/resources/css-framework/css/layout.css");
|
||||
@import url("${facesContext.externalContext.requestContextPath}/spring/resources/css/booking.css");
|
||||
</style>
|
||||
<ui:insert name="headIncludes"/>
|
||||
</head>
|
||||
@@ -26,16 +26,16 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id="branding" class="spring">
|
||||
<img src="/swf-booking-jsf/images/header.jpg" alt="foo bar"/>
|
||||
<img src="${facesContext.externalContext.requestContextPath}/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="/swf-booking-jsf/images/diplomat.jpg" />
|
||||
<img src="${facesContext.externalContext.requestContextPath}/images/diplomat.jpg" />
|
||||
</a>
|
||||
<a href="http://www.thespringexperience.com">
|
||||
<img src="/swf-booking-jsf/images/tse.gif" />
|
||||
<img src="${facesContext.externalContext.requestContextPath}/images/tse.gif" />
|
||||
</a>
|
||||
<p>
|
||||
The features illustrated in this sample are just the beginning.
|
||||
@@ -49,7 +49,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id="footer" class="clearfix spring">
|
||||
<a href="http://www.springframework.org"><img src="/swf-booking-jsf/images/powered-by-spring.png" /></a>
|
||||
<a href="http://www.springframework.org"><img src="${facesContext.externalContext.requestContextPath}/images/powered-by-spring.png" /></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user