Spring booking-faces example broken, once updated to PF 3.1

Components, Ajax Framework, Utilities and More.
Post Reply
smaines
Posts: 23
Joined: 08 Feb 2012, 19:14

08 Feb 2012, 22:16

SYNOPSIS

The distribution of Spring Webflow 2.3.0 includes a sample app, booking-faces which features PrimeFaces 2.2.1. When upgraded to PrimeFaces 3.1, the paginator component ceases to work correctly. Details, and a patch to create the upgraded sample app are included below. I can post the app itself if I get attachment priviledges. Note that the version of SpringWebflow itself is not changed.


BACKGROUND

I am starting a new project, and am very interested in using Spring Webflow and PrimeFaces. This decision was supported in part by my study of the booking-faces example provided by Spring which utilized PrimeFaces.

As I'd like to start on the latest production versions possible, and know that they still play well together, I undertook the exercise of upgrading the booking-faces example (from the Spring Webflow 2.3.0.RELEASE) to use those versions. When I did so, the paginator ceased to paginate, and the "View Hotel" button threw exceptions consistent with losing the searchCriteria object in the flow context.

The process by which I did the upgrade involved three steps,
  • * Changing pom.xml for the new versions
    * Changing to the new prime namespace url
    * Changing one method signature to reflect use of enum SortOrder
Given that it worked before, and the upgrade was so conservative, it should simply work, and yet does not.


DETAILS ON THE UPGRADE

1) Changing pom.xml

(note that Mojarra 2.0.8 is used here, as there is apparently an issue with Tomcat/Jetty and Mojarra 2.1.x, see this StackOverflow post)

Code: Select all

<org.springframework-version>3.1.0.RELEASE</org.springframework-version>
<org.springsecurity-version>3.1.0.RELEASE</org.springsecurity-version>
<org.springwebflow-version>2.3.0.RELEASE</org.springwebflow-version>
<jsf-version>2.0.8</jsf-version>
<primefaces-version>3.1</primefaces-version>
...also this bit below,

Code: Select all

		
<dependency>
     <groupId>org.springframework.webflow</groupId>
     <artifactId>spring-faces</artifactId>
     <version>${org.springwebflow-version}</version>
</dependency>
2) Changing to new prime namespace url

Code: Select all

$ find src/ -type f|xargs sed -i 's/primefaces.prime.com.tr/primefaces.org/g'
3) Changing org.springframework.webflow.samples.booking.HotelLazyDataModel to reflect underlying signature change to SortOrder.

Code: Select all

	@Override
	public List<Hotel> load(int first, int pageSize, String sortField,SortOrder sortOrder, Map<String, String> filters) {
	     searchCriteria.setCurrentPage(first / pageSize + 1);
             return bookingService.findHotels(searchCriteria, first, sortField,(sortOrder==SortOrder.ASCENDING));
	}

SAMPLE APP (ATTACH PERMISSION NEEDED)

I have a cleanly modified sample app I'd like to attach, which may be run (to failure) with,

Code: Select all

$ tar xzvf booking-faces-updates.tgz # archive compressed is 216K
$ cd booking-faces-updates
$ mvn clean tomcat:run                    # mine is Apache Tomcat/6.0.29, also tried 7.0.12 in Eclipse and Jetty 6.1.16
...but I don't seem to be able to post attachments just now. Perhaps a moderator could grant me the requisite priviledges.


OR USE PATCH AGAINST spring-webflow-2.3.0.RELEASE.zip

Until I can attach things in posts, here is a patch off of the Spring Webflow 2.3.0.RELEASE

Code: Select all

$ unzip spring-webflow-2.3.0.RELEASE.zip
$ cp -r spring-webflow-2.3.0.RELEASE/projects/spring-webflow-samples/booking-faces booking-faces-updated
$ patch -p1 -u -d booking-faces-updated < following.patch
And here, of course, what should be pasted into a file following.patch:

Code: Select all

diff -Naur booking-faces/pom.xml booking-faces-update/pom.xml
--- booking-faces/pom.xml	2012-02-08 13:33:44.026288234 -0800
+++ booking-faces-update/pom.xml	2012-02-08 11:27:29.279979372 -0800
@@ -8,11 +8,12 @@
 	<name>Hotel Booking : Spring MVC + Web Flow + JSF/PrimeFaces</name>
 	<version>2.3.0.RELEASE</version>
 	<properties>
-		<org.springframework-version>3.0.5.RELEASE</org.springframework-version>
-		<org.springsecurity-version>3.0.2.RELEASE</org.springsecurity-version>
+		<org.springframework-version>3.1.0.RELEASE</org.springframework-version>
+		<org.springsecurity-version>3.1.0.RELEASE</org.springsecurity-version>
+		<org.springwebflow-version>2.3.0.RELEASE</org.springwebflow-version>
 		<org.slf4j-version>1.5.10</org.slf4j-version>
-		<jsf-version>2.0.3</jsf-version>
-		<primefaces-version>2.2.1</primefaces-version>
+		<jsf-version>2.0.8</jsf-version>
+		<primefaces-version>3.1</primefaces-version>
 	</properties>
 	<dependencies>
 		<!-- Spring -->
@@ -46,7 +47,7 @@
 		<dependency>
 			<groupId>org.springframework.webflow</groupId>
 			<artifactId>spring-faces</artifactId>
-			<version>${project.version}</version>
+			<version>${org.springwebflow-version}</version>
 		</dependency>
 		<dependency>
 			<groupId>org.springframework.security</groupId>
diff -Naur booking-faces/src/main/java/org/springframework/webflow/samples/booking/HotelLazyDataModel.java booking-faces-update/src/main/java/org/springframework/webflow/samples/booking/HotelLazyDataModel.java
--- booking-faces/src/main/java/org/springframework/webflow/samples/booking/HotelLazyDataModel.java	2012-02-08 13:33:44.017288315 -0800
+++ booking-faces-update/src/main/java/org/springframework/webflow/samples/booking/HotelLazyDataModel.java	2012-02-08 11:31:59.935511959 -0800
@@ -7,6 +7,7 @@
 import java.util.Map;
 
 import org.primefaces.model.LazyDataModel;
+import org.primefaces.model.SortOrder;
 
 public class HotelLazyDataModel extends LazyDataModel<Hotel> {
 
@@ -23,11 +24,11 @@
 	this.bookingService = bookingService;
     }
 
-    @Override
-    public List<Hotel> load(int first, int pageSize, String sortField, boolean sortOrder, Map<String, String> filters) {
+	@Override
+	public List<Hotel> load(int first, int pageSize, String sortField,SortOrder sortOrder, Map<String, String> filters) {
 	searchCriteria.setCurrentPage(first / pageSize + 1);
-	return bookingService.findHotels(searchCriteria, first, sortField, sortOrder);
-    }
+	return bookingService.findHotels(searchCriteria, first, sortField,(sortOrder==SortOrder.ASCENDING));
+	}
 
     @Override
     public int getRowCount() {
diff -Naur booking-faces/src/main/webapp/WEB-INF/flows/booking/enterBookingDetails.xhtml booking-faces-update/src/main/webapp/WEB-INF/flows/booking/enterBookingDetails.xhtml
--- booking-faces/src/main/webapp/WEB-INF/flows/booking/enterBookingDetails.xhtml	2012-02-08 13:33:44.025288243 -0800
+++ booking-faces-update/src/main/webapp/WEB-INF/flows/booking/enterBookingDetails.xhtml	2012-02-08 11:29:39.815813774 -0800
@@ -3,7 +3,7 @@
 	    		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:p="http://primefaces.prime.com.tr/ui"
+	  			xmlns:p="http://primefaces.org/ui"
 				template="/WEB-INF/layouts/standard.xhtml">
 <ui:define name="notes">
 	<p>
diff -Naur booking-faces/src/main/webapp/WEB-INF/flows/booking/reviewBooking.xhtml booking-faces-update/src/main/webapp/WEB-INF/flows/booking/reviewBooking.xhtml
--- booking-faces/src/main/webapp/WEB-INF/flows/booking/reviewBooking.xhtml	2012-02-08 13:33:44.025288243 -0800
+++ booking-faces-update/src/main/webapp/WEB-INF/flows/booking/reviewBooking.xhtml	2012-02-08 11:29:39.814813783 -0800
@@ -3,7 +3,7 @@
 	    		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:p="http://primefaces.prime.com.tr/ui"
+	  			xmlns:p="http://primefaces.org/ui"
 				template="/WEB-INF/layouts/standard.xhtml">
 <ui:define name="notes">
 	<p>
diff -Naur booking-faces/src/main/webapp/WEB-INF/flows/main/enterSearchCriteria.xhtml booking-faces-update/src/main/webapp/WEB-INF/flows/main/enterSearchCriteria.xhtml
--- booking-faces/src/main/webapp/WEB-INF/flows/main/enterSearchCriteria.xhtml	2012-02-08 13:33:44.025288243 -0800
+++ booking-faces-update/src/main/webapp/WEB-INF/flows/main/enterSearchCriteria.xhtml	2012-02-08 11:29:39.813813792 -0800
@@ -3,7 +3,7 @@
 	    		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:p="http://primefaces.prime.com.tr/ui"
+	  			xmlns:p="http://primefaces.org/ui"
 				template="/WEB-INF/layouts/standard.xhtml">
 
 <ui:define name="notes">
diff -Naur booking-faces/src/main/webapp/WEB-INF/flows/main/reviewHotels.xhtml booking-faces-update/src/main/webapp/WEB-INF/flows/main/reviewHotels.xhtml
--- booking-faces/src/main/webapp/WEB-INF/flows/main/reviewHotels.xhtml	2012-02-08 13:33:44.025288243 -0800
+++ booking-faces-update/src/main/webapp/WEB-INF/flows/main/reviewHotels.xhtml	2012-02-08 11:29:39.812813801 -0800
@@ -3,7 +3,7 @@
 	    		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:p="http://primefaces.prime.com.tr/ui"
+	  			xmlns:p="http://primefaces.org/ui"
 				template="/WEB-INF/layouts/standard.xhtml">
 <ui:define name="notes">
 	<p>
diff -Naur booking-faces/src/main/webapp/WEB-INF/flows/main/reviewHotel.xhtml booking-faces-update/src/main/webapp/WEB-INF/flows/main/reviewHotel.xhtml
--- booking-faces/src/main/webapp/WEB-INF/flows/main/reviewHotel.xhtml	2012-02-08 13:33:44.025288243 -0800
+++ booking-faces-update/src/main/webapp/WEB-INF/flows/main/reviewHotel.xhtml	2012-02-08 11:29:39.812813801 -0800
@@ -3,7 +3,7 @@
 	    		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:p="http://primefaces.prime.com.tr/ui"
+	  			xmlns:p="http://primefaces.org/ui"
 				template="/WEB-INF/layouts/standard.xhtml">
 <ui:define name="notes">
 	<p>
diff -Naur booking-faces/src/main/webapp/WEB-INF/layouts/standard.xhtml booking-faces-update/src/main/webapp/WEB-INF/layouts/standard.xhtml
--- booking-faces/src/main/webapp/WEB-INF/layouts/standard.xhtml	2012-02-08 13:33:44.024288252 -0800
+++ booking-faces-update/src/main/webapp/WEB-INF/layouts/standard.xhtml	2012-02-08 11:29:39.806813855 -0800
@@ -4,7 +4,7 @@
 	xmlns:f="http://java.sun.com/jsf/core"
 	xmlns:c="http://java.sun.com/jsp/jstl/core"
 	xmlns:ui="http://java.sun.com/jsf/facelets"
-	xmlns:p="http://primefaces.prime.com.tr/ui">
+	xmlns:p="http://primefaces.org/ui">
 
 <f:view contentType="text/html">
 

Any help appreciated,

-SM
Last edited by smaines on 11 Feb 2012, 20:06, edited 3 times in total.

smaines
Posts: 23
Joined: 08 Feb 2012, 19:14

09 Feb 2012, 01:56

Brief autoreply to point out that I have added material to my original post, including a patch of the original webflow example which illustrates the problem I've encountered, as well as a few clarifications.

-SM

smaines
Posts: 23
Joined: 08 Feb 2012, 19:14

10 Feb 2012, 17:48

Could I get attachment priviledges, please, so I can upload the sample app itself? Is there something else I have neglected to provide? I've not put in stack traces, as they are easily reproduced from the clear sample code, but if that would help somehow, I could do so.

-SM

smaines
Posts: 23
Joined: 08 Feb 2012, 19:14

11 Feb 2012, 20:05

Rewritten for further clarity, readability,

-SM

smaines
Posts: 23
Joined: 08 Feb 2012, 19:14

12 Feb 2012, 08:01

Just confirmed that the problem(s) occurs when upgrading PrimeFaces upgraded to 3.1, but leaving the other Spring versions unchanged. So, this seems quite certain to be a PrimeFaces 3.1 problem.

Is it possible that PrimeFaces is somehow stepping on the flow context?

Entered this on Google defect tracker as Issue 3551. Note that, although it is a defect report, it shows erroneously as a feature request.

-SM

smaines
Posts: 23
Joined: 08 Feb 2012, 19:14

13 Feb 2012, 04:24

Just established that PrimeFaces 3.0.1 Paginator also fails, but that 2.2.1 succeeds across Mojarra (2.0.3 and 2.0.8), using Spring (3.0.5 and 3.1.0), Spring Webflow (2.3.0), Spring Security (3.0.2 and 3.1.0), run on both Tomcat (6 and 7) and Jetty (6.1.16) (see defect report, issue 3511)

-SM

smaines
Posts: 23
Joined: 08 Feb 2012, 19:14

16 Feb 2012, 10:16

Just established that PF 3.1.1 also fails in booking-faces app. I've updated the issue (3511) on Google.

Please look at the sample app. Note patch is only relative to original booking-faces, the apps in all the archives are each ready to go, and simply run,

$ mvn clean tomcat:run

Have I somehow updated the app incorrectly, or is PrimeFaces 3.1.x (and 3.0.1) simply incompatable with the production version of Spring WebFlow 2.3.0.RELEASE- actually any Webflow 2.3.x- until Spring fixes it?

Please have a look at the sample app,

-SM

smaines
Posts: 23
Joined: 08 Feb 2012, 19:14

17 Mar 2012, 03:56

This is related to, and possibly resolved by, https://jira.springsource.org/browse/SWF-1527

hififrank
Posts: 1
Joined: 19 Mar 2012, 21:34

19 Mar 2012, 21:54

Here is my experience for upgreading PF 2.21 to 3.2:

1. I had the working project for booking-face 2.21 created before.
2. I replaced the old primefaces-2.2.1.zip with primefaces-3.2.jar in lib folder
3. changed name space to xmlns:p="http://primefaces.org/ui in all *.xhtml files.
4. modified the HotelLazyDataModel.java file to correct the compilation error: boolean -> SortOrder......
5. this is the key step: remove the page attribute in following tag in reviewHotels.xhtml page:

<p:dataTable id="hotels" var="h" value="#{hotels}" paginator="true" dynamic="true" lazy="true"
rows="#{searchCriteria.pageSize}" page="#{searchCrtieria.currentPage}">


It seems that the attribute [page="#{searchCrtieria.currentPage}"] not only make the data table pagenation not working, but also damaged the link on top of the table and the submit button below.

No other changes.

Then the demo project working same as before.

Hope it is useful for others.

Post Reply
  • Information
  • Who is online

    Users browsing this forum: Bing [Bot] and 19 guests