diff --git a/spring-webflow-samples/booking-faces/ivy.xml b/spring-webflow-samples/booking-faces/ivy.xml index 32e20645..8b86c340 100755 --- a/spring-webflow-samples/booking-faces/ivy.xml +++ b/spring-webflow-samples/booking-faces/ivy.xml @@ -21,11 +21,10 @@ - - + @@ -46,10 +45,23 @@ - + + + + + diff --git a/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/faces-config-12.xml b/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/faces-config-12.xml new file mode 100644 index 00000000..a1d74854 --- /dev/null +++ b/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/faces-config-12.xml @@ -0,0 +1,17 @@ + + + + + + + + com.sun.facelets.FaceletViewHandler + + \ No newline at end of file diff --git a/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/faces-config.xml b/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/faces-config.xml index 8a0d7056..21e273da 100644 --- a/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/faces-config.xml +++ b/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/faces-config.xml @@ -1,11 +1,9 @@ - - + + - - - - com.sun.facelets.FaceletViewHandler - - \ No newline at end of file + + + diff --git a/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/flows/booking/enterBookingDetails.xhtml b/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/flows/booking/enterBookingDetails.xhtml index c557e619..994fde42 100644 --- a/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/flows/booking/enterBookingDetails.xhtml +++ b/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/flows/booking/enterBookingDetails.xhtml @@ -89,6 +89,13 @@ +
Credit Card #: diff --git a/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/layouts/standard.xhtml b/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/layouts/standard.xhtml index c5021baa..d36634d8 100644 --- a/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/layouts/standard.xhtml +++ b/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/layouts/standard.xhtml @@ -2,7 +2,8 @@ diff --git a/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/login.xhtml b/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/login.xhtml index 65a947ca..54676e32 100755 --- a/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/login.xhtml +++ b/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/login.xhtml @@ -1,7 +1,7 @@ diff --git a/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/web.xml b/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/web.xml index 9efa7c31..f1651ec4 100755 --- a/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/web.xml +++ b/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/web.xml @@ -20,8 +20,8 @@ - facelets.DEVELOPMENT - true + javax.faces.PROJECT_STAGE + Development @@ -29,7 +29,13 @@ javax.faces.FACELETS_REFRESH_PERIOD 1 - + + + + javax.faces.PARTIAL_STATE_SAVING + false + + charEncodingFilter @@ -60,17 +66,6 @@ /* - - - com.sun.faces.config.ConfigureListener - - - - org.springframework.web.context.ContextLoaderListener diff --git a/spring-webflow-samples/booking-portlet-faces/.classpath b/spring-webflow-samples/booking-portlet-faces/.classpath index 87b33ef0..984143e6 100644 --- a/spring-webflow-samples/booking-portlet-faces/.classpath +++ b/spring-webflow-samples/booking-portlet-faces/.classpath @@ -7,6 +7,6 @@ - + diff --git a/spring-webflow-samples/booking-portlet-faces/.settings/org.eclipse.jdt.core.prefs b/spring-webflow-samples/booking-portlet-faces/.settings/org.eclipse.jdt.core.prefs index dc8ffbcd..94a557d8 100644 --- a/spring-webflow-samples/booking-portlet-faces/.settings/org.eclipse.jdt.core.prefs +++ b/spring-webflow-samples/booking-portlet-faces/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,13 @@ -#Thu Aug 09 13:12:30 EDT 2007 +#Wed Jun 02 12:02:05 BST 2010 eclipse.preferences.version=1 instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.source=1.5 diff --git a/spring-webflow-samples/booking-portlet-faces/.settings/org.eclipse.wst.common.component b/spring-webflow-samples/booking-portlet-faces/.settings/org.eclipse.wst.common.component index 4e8683b7..f5560e71 100644 --- a/spring-webflow-samples/booking-portlet-faces/.settings/org.eclipse.wst.common.component +++ b/spring-webflow-samples/booking-portlet-faces/.settings/org.eclipse.wst.common.component @@ -3,7 +3,6 @@ - diff --git a/spring-webflow-samples/booking-portlet-faces/ivy.xml b/spring-webflow-samples/booking-portlet-faces/ivy.xml index 8b5aa945..8b79bc56 100644 --- a/spring-webflow-samples/booking-portlet-faces/ivy.xml +++ b/spring-webflow-samples/booking-portlet-faces/ivy.xml @@ -21,7 +21,6 @@ - @@ -46,9 +45,11 @@ - + + + diff --git a/spring-webflow-samples/booking-portlet-faces/lib/jsf-portlet-1.2.5-src.zip b/spring-webflow-samples/booking-portlet-faces/lib/jsf-portlet-1.2.5-src.zip deleted file mode 100644 index db95cf6e..00000000 Binary files a/spring-webflow-samples/booking-portlet-faces/lib/jsf-portlet-1.2.5-src.zip and /dev/null differ diff --git a/spring-webflow-samples/booking-portlet-faces/lib/jsf-portlet.jar b/spring-webflow-samples/booking-portlet-faces/lib/jsf-portlet.jar deleted file mode 100644 index e1f1b830..00000000 Binary files a/spring-webflow-samples/booking-portlet-faces/lib/jsf-portlet.jar and /dev/null differ diff --git a/spring-webflow-samples/booking-portlet-faces/readme.txt b/spring-webflow-samples/booking-portlet-faces/readme.txt new file mode 100644 index 00000000..c14f9a26 --- /dev/null +++ b/spring-webflow-samples/booking-portlet-faces/readme.txt @@ -0,0 +1,15 @@ + +The current status of this sample as of June 2, 2010 is 'not working'. + +See notes below on combining JSF 1.2, Portlet 2.0, and Facelets. + +JSF 2 is not yet supported by any jsf-portlet bridge implementation. +The jsf-portlet bridges by Sun and Apache MyFaces support JSF 1.2. + +Portlet 2.0 (required by Spring 3 and Spring Web Flow 2.1) is supported by Apache MyFaces only. + +Official Facelets support is missing from both implementations. While there are some +suggestions on how to create a PortletFaceletsViewHandler on the Apache MyFaces user +list (see the thread referenced in the JavaDoc of the PortletFaceletsViewHandler in +this project), the suggested solution doesn't appear to be complete. + diff --git a/spring-webflow-samples/booking-portlet-faces/src/main/java/org/springframework/webflow/samples/PortletFaceletViewHandler.java b/spring-webflow-samples/booking-portlet-faces/src/main/java/org/springframework/webflow/samples/PortletFaceletViewHandler.java new file mode 100644 index 00000000..821e710d --- /dev/null +++ b/spring-webflow-samples/booking-portlet-faces/src/main/java/org/springframework/webflow/samples/PortletFaceletViewHandler.java @@ -0,0 +1,172 @@ +/** + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * 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.webflow.samples; + +import java.io.IOException; +import java.io.Writer; +import java.util.Map; +import java.util.logging.Level; + +import javax.faces.FacesException; +import javax.faces.application.ViewHandler; +import javax.faces.context.ExternalContext; +import javax.faces.context.FacesContext; +import javax.faces.context.ResponseWriter; +import javax.faces.render.RenderKit; +import javax.portlet.MimeResponse; +import javax.portlet.faces.Bridge; + +import com.sun.facelets.FaceletViewHandler; + +/** + * See: http://www.mail-archive.com/users@myfaces.apache.org/msg55213.html + */ +public class PortletFaceletViewHandler extends FaceletViewHandler { + + public PortletFaceletViewHandler(ViewHandler parent) { + super(new FaceletViewHandler(parent)); + } + + protected ResponseWriter createResponseWriter(FacesContext context) throws IOException, FacesException { + // Only override if in a portlet request + if (context.getExternalContext().getRequestMap().get(Bridge.PORTLET_LIFECYCLE_PHASE) == null) { + return super.createResponseWriter(context); + } + + ExternalContext extContext = context.getExternalContext(); + RenderKit renderKit = context.getRenderKit(); + // Avoid a cryptic NullPointerException when the renderkit ID + // is incorrectly set + if (renderKit == null) { + String id = context.getViewRoot().getRenderKitId(); + throw new IllegalStateException("No render kit was available for id \"" + id + "\""); + } + + MimeResponse response = (MimeResponse) extContext.getResponse(); + + // get our content type + String contentType = (String) extContext.getRequestMap().get("facelets.ContentType"); + + // get the encoding + String encoding = (String) extContext.getRequestMap().get("facelets.Encoding"); + + ResponseWriter writer; + // append */* to the contentType so createResponseWriter will succeed no matter + // the requested contentType. + if (contentType != null && !contentType.equals("*/*")) { + contentType += ",*/*"; + } + // Create a dummy ResponseWriter with a bogus writer, + // so we can figure out what content type the ReponseWriter + // is really going to ask for + try { + writer = renderKit.createResponseWriter(NullWriter.Instance, contentType, encoding); + } catch (IllegalArgumentException e) { + // Added because of an RI bug prior to 1.2_05-b3. Might as well leave it in case other impls have the same + // problem. + // https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=613 + log.fine("The impl didn't correctly handled '*/*' in the content type list. Trying '*/*' directly."); + writer = renderKit.createResponseWriter(NullWriter.Instance, "*/*", encoding); + } + + // Override the JSF provided content type if necessary + contentType = getResponseContentType(context, writer.getContentType()); + encoding = getResponseEncoding(context, writer.getCharacterEncoding()); + + // apply them to the response + response.setContentType(contentType + "; charset=" + encoding); + + // removed 2005.8.23 to comply with J2EE 1.3 + // response.setCharacterEncoding(encoding); + + // Now, clone with the real writer + writer = writer.cloneWithWriter(response.getWriter()); + + return writer; + } + + /** + * Generate the encoding + * + * @param context + * @param orig + * @return + */ + protected String getResponseEncoding(FacesContext context, String orig) { + String encoding = orig; + + // see if we need to override the encoding + Map m = context.getExternalContext().getRequestMap(); + Map sm = context.getExternalContext().getSessionMap(); + + // 1. check the request attribute + if (m.containsKey("facelets.Encoding")) { + encoding = (String) m.get("facelets.Encoding"); + if (log.isLoggable(Level.FINEST)) { + log.finest("Facelet specified alternate encoding '" + encoding + "'"); + } + sm.put(CHARACTER_ENCODING_KEY, encoding); + } + + // 2. get it from request + if (encoding == null) { + encoding = context.getExternalContext().getResponseCharacterEncoding(); + } + + // 3. get it from the session + if (encoding == null) { + encoding = (String) sm.get(CHARACTER_ENCODING_KEY); + if (log.isLoggable(Level.FINEST)) { + log.finest("Session specified alternate encoding '" + encoding + "'"); + } + } + + // 4. default it + if (encoding == null) { + encoding = "UTF-8"; + if (log.isLoggable(Level.FINEST)) { + log.finest("ResponseWriter created had a null CharacterEncoding, defaulting to UTF-8"); + } + } + + return encoding; + } + + protected static class NullWriter extends Writer { + + static final NullWriter Instance = new NullWriter(); + + public void write(char[] buffer) { + } + + public void write(char[] buffer, int off, int len) { + } + + public void write(String str) { + } + + public void write(int c) { + } + + public void write(String str, int off, int len) { + } + + public void close() { + } + + public void flush() { + } + } + +} \ No newline at end of file diff --git a/spring-webflow-samples/booking-portlet-faces/src/main/webapp/WEB-INF/faces-config.xml b/spring-webflow-samples/booking-portlet-faces/src/main/webapp/WEB-INF/faces-config.xml index 8a0d7056..b06693cc 100644 --- a/spring-webflow-samples/booking-portlet-faces/src/main/webapp/WEB-INF/faces-config.xml +++ b/spring-webflow-samples/booking-portlet-faces/src/main/webapp/WEB-INF/faces-config.xml @@ -6,6 +6,6 @@ - com.sun.facelets.FaceletViewHandler + org.springframework.webflow.samples.PortletFaceletViewHandler \ No newline at end of file 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 index b18dfd6c..d95db370 100644 --- 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 @@ -1,17 +1,17 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/spring-webflow-samples/jsf-booking/ivy.xml b/spring-webflow-samples/jsf-booking/ivy.xml index 8f5b8b1b..a3a9baaa 100644 --- a/spring-webflow-samples/jsf-booking/ivy.xml +++ b/spring-webflow-samples/jsf-booking/ivy.xml @@ -21,13 +21,12 @@ - - - + + - + diff --git a/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/jsf/BookingController.java b/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/jsf/BookingController.java index b54d4b66..4bd4081e 100644 --- a/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/jsf/BookingController.java +++ b/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/jsf/BookingController.java @@ -3,22 +3,30 @@ package org.springframework.webflow.samples.booking.jsf; import java.util.Calendar; import javax.faces.application.FacesMessage; +import javax.faces.bean.ManagedBean; +import javax.faces.bean.ManagedProperty; +import javax.faces.bean.RequestScoped; import javax.faces.context.FacesContext; import org.springframework.webflow.samples.booking.Booking; import org.springframework.webflow.samples.booking.BookingService; import org.springframework.webflow.samples.booking.Hotel; +@ManagedBean +@RequestScoped public class BookingController { + @ManagedProperty("#{bookingService}") private BookingService bookingService; + @ManagedProperty("#{hotelController.hotelId}") private Long hotelId; - private Hotel hotel = new Hotel(); - + @ManagedProperty("#{booking}") private Booking booking; + private Hotel hotel = new Hotel(); + private boolean initialized = false; public void setBookingService(BookingService bookingService) { diff --git a/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/jsf/HotelController.java b/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/jsf/HotelController.java index 1be30b22..64392dc1 100644 --- a/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/jsf/HotelController.java +++ b/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/jsf/HotelController.java @@ -1,12 +1,20 @@ package org.springframework.webflow.samples.booking.jsf; +import javax.faces.bean.ManagedBean; +import javax.faces.bean.ManagedProperty; +import javax.faces.bean.RequestScoped; + import org.springframework.webflow.samples.booking.BookingService; import org.springframework.webflow.samples.booking.Hotel; +@ManagedBean +@RequestScoped public class HotelController { + @ManagedProperty("#{bookingService}") private BookingService bookingService; + @ManagedProperty("#{param.id}") private Long hotelId; private Hotel hotel; diff --git a/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/jsf/SearchController.java b/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/jsf/SearchController.java index 2f8944bc..23617fb1 100644 --- a/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/jsf/SearchController.java +++ b/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/jsf/SearchController.java @@ -2,6 +2,9 @@ package org.springframework.webflow.samples.booking.jsf; import java.util.List; +import javax.faces.bean.ManagedBean; +import javax.faces.bean.ManagedProperty; +import javax.faces.bean.RequestScoped; import javax.faces.event.ActionEvent; import javax.faces.model.DataModel; import javax.faces.model.ListDataModel; @@ -10,6 +13,8 @@ import org.springframework.webflow.samples.booking.Booking; import org.springframework.webflow.samples.booking.BookingService; import org.springframework.webflow.samples.booking.SearchCriteria; +@ManagedBean +@RequestScoped public class SearchController { private SearchCriteria searchCriteria; @@ -18,6 +23,7 @@ public class SearchController { private DataModel hotels; + @ManagedProperty("#{bookingService}") private BookingService bookingService; public void setBookingService(BookingService bookingService) { 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 index da3c88b6..e01318c3 100644 --- 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 @@ -1,77 +1,13 @@ - - - - + + org.springframework.web.jsf.SpringBeanVariableResolver - com.sun.facelets.FaceletViewHandler - - - searchController - org.springframework.webflow.samples.booking.jsf.SearchController - request - - bookingService - #{bookingService} - - - - - hotelController - org.springframework.webflow.samples.booking.jsf.HotelController - request - - bookingService - #{bookingService} - - - hotelId - #{param.id} - - - - bookingController - org.springframework.webflow.samples.booking.jsf.BookingController - request - - bookingService - #{bookingService} - - - hotelId - #{hotelController.hotelId} - - - booking - #{booking} - - - - - /main/enterSearchCriteria.xhtml - - reviewHotels - /main/reviewHotels.xhtml - - - - - /main/reviewHotels.xhtml - - changeSearch - /main/enterSearchCriteria.xhtml - - - select - /main/reviewHotel.xhtml - - - /main/reviewHotel.xhtml @@ -80,14 +16,6 @@ - - /booking/enterBookingDetails.xhtml - - reviewBooking - /booking/reviewBooking.xhtml - - - /booking/reviewBooking.xhtml 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 index c5acc75b..3d213db3 100644 --- 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 @@ -2,7 +2,7 @@ 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 index 06b4937b..0bd2b02b 100644 --- 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 @@ -19,8 +19,8 @@ - facelets.DEVELOPMENT - true + javax.faces.PROJECT_STAGE + Development @@ -29,17 +29,6 @@ 1 - - - com.sun.faces.config.ConfigureListener - - - - org.springframework.web.context.ContextLoaderListener 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 index a43f477c..e84464e1 100644 --- a/spring-webflow-samples/jsf-booking/src/main/webapp/booking/enterBookingDetails.xhtml +++ b/spring-webflow-samples/jsf-booking/src/main/webapp/booking/enterBookingDetails.xhtml @@ -3,7 +3,6 @@ xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" - xmlns:sf="http://www.springframework.org/tags/faces" template="/WEB-INF/layouts/standard.xhtml"> @@ -46,11 +45,9 @@ Check In Date:
- - - - - + + +
@@ -58,11 +55,9 @@ Check Out Date:
- - - - - + + +
@@ -90,9 +85,7 @@ Credit Card #:
- - - +
@@ -100,9 +93,7 @@ Credit Card Name:
- - - +
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 index 097f4440..7b4441a5 100644 --- a/spring-webflow-samples/jsf-booking/src/main/webapp/main/reviewHotels.xhtml +++ b/spring-webflow-samples/jsf-booking/src/main/webapp/main/reviewHotels.xhtml @@ -11,7 +11,7 @@

Hotel Results

- +