Employee.web: Changed from using FlashScope to SessionScoped criteria
diff --git a/jpa/employee/employee.model/src/main/java/eclipselink/example/jpa/employee/services/EmployeeCriteria.java b/jpa/employee/employee.model/src/main/java/eclipselink/example/jpa/employee/services/EmployeeCriteria.java
index 18a02a3..25f1de2 100644
--- a/jpa/employee/employee.model/src/main/java/eclipselink/example/jpa/employee/services/EmployeeCriteria.java
+++ b/jpa/employee/employee.model/src/main/java/eclipselink/example/jpa/employee/services/EmployeeCriteria.java
@@ -12,9 +12,6 @@
  ******************************************************************************/
 package eclipselink.example.jpa.employee.services;
 
-import java.io.Serializable;
-
-import javax.enterprise.context.SessionScoped;
 import javax.persistence.EntityManager;
 import javax.persistence.EntityManagerFactory;
 import javax.persistence.criteria.CriteriaBuilder;
@@ -36,9 +33,7 @@
  * @author dclarke
  * @since EclipseLInk 2.4.2
  */
-@SessionScoped
-public class EmployeeCriteria implements Serializable {
-    private static final long serialVersionUID = 1L;
+public class EmployeeCriteria {
 
     private String firstName = "%";
 
@@ -155,4 +150,10 @@
         return null;
     }
 
+    public void reset() {
+        this.firstName = "%";
+        this.lastName = "%";
+        this.pagingType = "NONE";
+    }
+
 }
diff --git a/jpa/employee/employee.web/src/main/java/eclipselink/example/jpa/employee/web/EmployeeResults.java b/jpa/employee/employee.web/src/main/java/eclipselink/example/jpa/employee/web/EmployeeResults.java
index 60265a6..3734150 100644
--- a/jpa/employee/employee.web/src/main/java/eclipselink/example/jpa/employee/web/EmployeeResults.java
+++ b/jpa/employee/employee.web/src/main/java/eclipselink/example/jpa/employee/web/EmployeeResults.java
@@ -18,13 +18,12 @@
 import javax.ejb.EJB;
 import javax.faces.application.FacesMessage;
 import javax.faces.bean.ManagedBean;
+import javax.faces.bean.ManagedProperty;
 import javax.faces.bean.ViewScoped;
 import javax.faces.context.FacesContext;
 import javax.faces.context.Flash;
-import javax.inject.Inject;
 
 import eclipselink.example.jpa.employee.model.Employee;
-import eclipselink.example.jpa.employee.services.EmployeeCriteria;
 import eclipselink.example.jpa.employee.services.EmployeeRepository;
 import eclipselink.example.jpa.employee.services.paging.EntityPaging;
 
@@ -41,6 +40,9 @@
 
     protected static final String PAGE = "/employee/results?faces-redirect=true";
 
+    @ManagedProperty("#{searchEmployees}")
+    private SearchEmployees search;
+    
     private EmployeeRepository repository;
 
     /**
@@ -52,9 +54,6 @@
 
     private int currentPage = 1;
 
-    @Inject
-    private EmployeeCriteria criteria;
-
     public EmployeeRepository getRepository() {
         return repository;
     }
@@ -64,12 +63,12 @@
         this.repository = repository;
     }
 
-    public EmployeeCriteria getCriteria() {
-        return criteria;
+    public SearchEmployees getSearch() {
+        return search;
     }
 
-    public void setCriteria(EmployeeCriteria criteria) {
-        this.criteria = criteria;
+    public void setSearch(SearchEmployees search) {
+        this.search = search;
     }
 
     public EntityPaging<Employee> getPaging() {
@@ -78,18 +77,10 @@
 
     @PostConstruct
     public void initialize() {
-        if (getCriteria() == null) {
-            Flash flash = FacesContext.getCurrentInstance().getExternalContext().getFlash();
-            criteria = (EmployeeCriteria) flash.get(SearchEmployees.CRITERIA);
-        }
-        if (getCriteria() == null) {
-            System.err.println("No criteria found, using default in EmployeeResults");
-            this.criteria = new EmployeeCriteria(10);
-        }
         this.currentPage = 1;
         this.employees = null;
 
-        this.paging = getRepository().getPaging(criteria);
+        this.paging = getRepository().getPaging(getSearch().getCriteria());
     }
 
     public List<Employee> getEmployees() {
@@ -97,7 +88,7 @@
             if (getHasPaging()) {
                 this.employees = getPaging().get(this.currentPage);
             } else {
-                this.employees = getRepository().getEmployees(criteria);
+                this.employees = getRepository().getEmployees(getSearch().getCriteria());
             }
         }
 
diff --git a/jpa/employee/employee.web/src/main/java/eclipselink/example/jpa/employee/web/Navigation.java b/jpa/employee/employee.web/src/main/java/eclipselink/example/jpa/employee/web/Navigation.java
index fa27af0..11b161e 100644
--- a/jpa/employee/employee.web/src/main/java/eclipselink/example/jpa/employee/web/Navigation.java
+++ b/jpa/employee/employee.web/src/main/java/eclipselink/example/jpa/employee/web/Navigation.java
@@ -13,6 +13,7 @@
 package eclipselink.example.jpa.employee.web;
 
 import javax.faces.bean.ManagedBean;
+import javax.faces.bean.ManagedProperty;
 import javax.faces.bean.RequestScoped;
 
 import eclipselink.example.jpa.employee.model.Employee;
@@ -50,8 +51,20 @@
     public String edit() {
         return EDIT_REDIRECT;
     }
+    
+    @ManagedProperty("#{searchEmployees}")
+    private SearchEmployees search;
+
+    public SearchEmployees getSearch() {
+        return search;
+    }
+
+    public void setSearch(SearchEmployees search) {
+        this.search = search;
+    }
 
     public String search() {
+        getSearch().getCriteria().reset();
         return SEARCH_REDIRECT;
     }
 
diff --git a/jpa/employee/employee.web/src/main/java/eclipselink/example/jpa/employee/web/SearchEmployees.java b/jpa/employee/employee.web/src/main/java/eclipselink/example/jpa/employee/web/SearchEmployees.java
index 4a17867..144b918 100644
--- a/jpa/employee/employee.web/src/main/java/eclipselink/example/jpa/employee/web/SearchEmployees.java
+++ b/jpa/employee/employee.web/src/main/java/eclipselink/example/jpa/employee/web/SearchEmployees.java
@@ -12,11 +12,10 @@
  ******************************************************************************/
 package eclipselink.example.jpa.employee.web;
 
+import java.io.Serializable;
+
 import javax.faces.bean.ManagedBean;
-import javax.faces.bean.ViewScoped;
-import javax.faces.context.FacesContext;
-import javax.faces.context.Flash;
-import javax.inject.Inject;
+import javax.faces.bean.SessionScoped;
 
 import eclipselink.example.jpa.employee.services.EmployeeCriteria;
 
@@ -27,29 +26,17 @@
  * @since EclipseLink 2.4.2
  */
 @ManagedBean
-@ViewScoped
-public class SearchEmployees {
+@SessionScoped
+public class SearchEmployees implements Serializable {
+    private static final long serialVersionUID = 1L;
 
-    /**
-     * Flash property name used to pass the criteria through to the results
-     * rendering page.
-     */
-    protected final static String CRITERIA = "CRITERIA";
-
-    @Inject
     private EmployeeCriteria criteria = new EmployeeCriteria(10);
     
     public EmployeeCriteria getCriteria() {
         return criteria;
     }
 
-    public void setCriteria(EmployeeCriteria criteria) {
-        this.criteria = criteria;
-    }
-
-    public String search() {
-        Flash flash = FacesContext.getCurrentInstance().getExternalContext().getFlash();
-        flash.put(CRITERIA, getCriteria());
+     public String search() {
         return EmployeeResults.PAGE;
     }