Author: nbelaevski
Date: 2011-04-14 07:53:42 -0400 (Thu, 14 Apr 2011)
New Revision: 22419
Added:
trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/JPADataModel.java
trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/PersistenceLifecycle.java
trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/PersistenceLifecycleFactory.java
trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/PersistenceService.java
trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/Person.java
trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/PersonBean.java
trunk/examples/iteration-demo/src/main/resources/META-INF/
trunk/examples/iteration-demo/src/main/resources/META-INF/persistence.xml
trunk/examples/iteration-demo/src/main/resources/org/richfaces/demo/data.xml
trunk/examples/iteration-demo/src/main/webapp/jpaColumn.xhtml
trunk/examples/iteration-demo/src/main/webapp/jpaDataTable.xhtml
Modified:
trunk/examples/iteration-demo/pom.xml
trunk/examples/iteration-demo/src/main/webapp/WEB-INF/faces-config.xml
Log:
JPA 2 data table demo
Modified: trunk/examples/iteration-demo/pom.xml
===================================================================
--- trunk/examples/iteration-demo/pom.xml 2011-04-13 09:48:09 UTC (rev 22418)
+++ trunk/examples/iteration-demo/pom.xml 2011-04-14 11:53:42 UTC (rev 22419)
@@ -86,6 +86,22 @@
<artifactId>jstl</artifactId>
<scope>provided</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.hsqldb</groupId>
+ <artifactId>hsqldb-j5</artifactId>
+ <version>2.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa</artifactId>
+ <version>2.1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate.java-persistence</groupId>
+ <artifactId>jpa-api</artifactId>
+ <version>2.0-cr-1</version>
+ </dependency>
</dependencies>
<build>
Added: trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/JPADataModel.java
===================================================================
--- trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/JPADataModel.java
(rev 0)
+++
trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/JPADataModel.java 2011-04-14
11:53:42 UTC (rev 22419)
@@ -0,0 +1,251 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.demo;
+
+import java.util.List;
+
+import javax.faces.context.FacesContext;
+import javax.persistence.EntityManager;
+import javax.persistence.TypedQuery;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Expression;
+import javax.persistence.criteria.Order;
+import javax.persistence.criteria.Path;
+import javax.persistence.criteria.Root;
+
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.ExtendedDataModel;
+import org.ajax4jsf.model.Range;
+import org.ajax4jsf.model.SequenceRange;
+import org.richfaces.component.SortOrder;
+import org.richfaces.model.Arrangeable;
+import org.richfaces.model.ArrangeableState;
+import org.richfaces.model.FilterField;
+import org.richfaces.model.SortField;
+
+import com.google.common.base.Strings;
+import com.google.common.collect.Lists;
+
+public abstract class JPADataModel<T> extends ExtendedDataModel<T> implements
Arrangeable {
+
+ private EntityManager entityManager;
+
+ private Object rowKey;
+
+ private ArrangeableState arrangeableState;
+
+ private Class<T> entityClass;
+
+ public JPADataModel(EntityManager entityManager, Class<T> entityClass) {
+ super();
+
+ this.entityManager = entityManager;
+ this.entityClass = entityClass;
+ }
+
+ public void arrange(FacesContext context, ArrangeableState state) {
+ arrangeableState = state;
+ }
+
+ @Override
+ public void setRowKey(Object key) {
+ rowKey = key;
+ }
+
+ @Override
+ public Object getRowKey() {
+ return rowKey;
+ }
+
+ private CriteriaQuery<Long> createCountCriteriaQuery() {
+ CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
+ CriteriaQuery<Long> criteriaQuery =
criteriaBuilder.createQuery(Long.class);
+ Root<T> root = criteriaQuery.from(entityClass);
+
+ Expression<Boolean> filterCriteria = createFilterCriteria(criteriaBuilder,
root);
+ if (filterCriteria != null) {
+ criteriaQuery.where(filterCriteria);
+ }
+
+ Expression<Long> count = criteriaBuilder.count(root);
+ criteriaQuery.select(count);
+
+ return criteriaQuery;
+ }
+
+ private CriteriaQuery<T> createSelectCriteriaQuery() {
+ CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
+ CriteriaQuery<T> criteriaQuery = criteriaBuilder.createQuery(entityClass);
+ Root<T> root = criteriaQuery.from(entityClass);
+
+ if (arrangeableState != null) {
+
+ List<Order> orders = createOrders(criteriaBuilder, root);
+ if (!orders.isEmpty()) {
+ criteriaQuery.orderBy(orders);
+ }
+
+ Expression<Boolean> filterCriteria =
createFilterCriteria(criteriaBuilder, root);
+ if (filterCriteria != null) {
+ criteriaQuery.where(filterCriteria);
+ }
+ }
+
+ return criteriaQuery;
+ }
+
+ private List<Order> createOrders(CriteriaBuilder criteriaBuilder, Root<T>
root) {
+ List<Order> orders = Lists.newArrayList();
+ List<SortField> sortFields = arrangeableState.getSortFields();
+ if (sortFields != null && !sortFields.isEmpty()) {
+
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+
+ for (SortField sortField: sortFields) {
+ String propertyName = (String)
sortField.getSortBy().getValue(facesContext.getELContext());
+
+ Path<Object> expression = root.get(propertyName);
+
+ Order jpaOrder;
+ SortOrder sortOrder = sortField.getSortOrder();
+ if (sortOrder == SortOrder.ascending) {
+ jpaOrder = criteriaBuilder.asc(expression);
+ } else if (sortOrder == SortOrder.descending) {
+ jpaOrder = criteriaBuilder.desc(expression);
+ } else {
+ throw new IllegalArgumentException(sortOrder.toString());
+ }
+
+ orders.add(jpaOrder);
+ }
+ }
+
+ return orders;
+ }
+
+ protected ArrangeableState getArrangeableState() {
+ return arrangeableState;
+ }
+
+ protected Class<T> getEntityClass() {
+ return entityClass;
+ }
+
+ protected Expression<Boolean> createFilterCriteriaForField(String propertyName,
Object filterValue, Root<T> root, CriteriaBuilder criteriaBuilder) {
+ String stringFilterValue = (String) filterValue;
+ if (Strings.isNullOrEmpty(stringFilterValue)) {
+ return null;
+ }
+
+ stringFilterValue = stringFilterValue.toLowerCase(arrangeableState.getLocale());
+
+ Path<String> expression = root.get(propertyName);
+ Expression<Integer> locator =
criteriaBuilder.locate(criteriaBuilder.lower(expression), stringFilterValue);
+ return criteriaBuilder.gt(locator, 0);
+ }
+
+
+ private Expression<Boolean> createFilterCriteria(CriteriaBuilder
criteriaBuilder, Root<T> root) {
+ Expression<Boolean> filterCriteria = null;
+ List<FilterField> filterFields = arrangeableState.getFilterFields();
+ if (filterFields != null && !filterFields.isEmpty()) {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+
+ for (FilterField filterField : filterFields) {
+ String propertyName = (String)
filterField.getFilterExpression().getValue(facesContext.getELContext());
+ Object filterValue = filterField.getFilterValue();
+
+ Expression<Boolean> predicate =
createFilterCriteriaForField(propertyName, filterValue, root, criteriaBuilder);
+
+ if (predicate == null) {
+ continue;
+ }
+
+ if (filterCriteria == null) {
+ filterCriteria = predicate.as(Boolean.class);
+ } else {
+ filterCriteria = criteriaBuilder.and(filterCriteria,
predicate.as(Boolean.class));
+ }
+ }
+
+ }
+ return filterCriteria;
+ }
+
+ @Override
+ public void walk(FacesContext context, DataVisitor visitor, Range range, Object
argument) {
+ CriteriaQuery<T> criteriaQuery = createSelectCriteriaQuery();
+ TypedQuery<T> query = entityManager.createQuery(criteriaQuery);
+
+ SequenceRange sequenceRange = (SequenceRange) range;
+ if (sequenceRange.getFirstRow() >= 0 && sequenceRange.getRows() >
0) {
+ query.setFirstResult(sequenceRange.getFirstRow());
+ query.setMaxResults(sequenceRange.getRows());
+ }
+
+ List<T> data = query.getResultList();
+ for (T t : data) {
+ visitor.process(context, getId(t), argument);
+ }
+ }
+
+
+ @Override
+ public boolean isRowAvailable() {
+ return rowKey != null;
+ }
+
+ @Override
+ public int getRowCount() {
+ CriteriaQuery<Long> criteriaQuery = createCountCriteriaQuery();
+ return entityManager.createQuery(criteriaQuery).getSingleResult().intValue();
+ }
+
+ @Override
+ public T getRowData() {
+ return entityManager.find(entityClass, rowKey);
+ }
+
+ @Override
+ public int getRowIndex() {
+ return -1;
+ }
+
+ @Override
+ public void setRowIndex(int rowIndex) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Object getWrappedData() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void setWrappedData(Object data) {
+ throw new UnsupportedOperationException();
+ }
+
+ //TODO - implement using metadata
+ protected abstract Object getId(T t);
+}
\ No newline at end of file
Added:
trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/PersistenceLifecycle.java
===================================================================
---
trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/PersistenceLifecycle.java
(rev 0)
+++
trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/PersistenceLifecycle.java 2011-04-14
11:53:42 UTC (rev 22419)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.demo;
+
+import javax.faces.FacesException;
+import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseListener;
+import javax.faces.lifecycle.Lifecycle;
+
+class PersistenceLifecycle extends Lifecycle {
+
+ private static final class PersistenceServiceRef {
+
+ static final PersistenceService PERSISTENCE_SERVICE = (PersistenceService)
FacesContext.getCurrentInstance().
+
getExternalContext().getApplicationMap().get("persistenceService");
+
+ private PersistenceServiceRef() {
+ }
+
+ }
+
+ private Lifecycle lifecycle;
+
+ public PersistenceLifecycle(Lifecycle lifecycle) {
+ this.lifecycle = lifecycle;
+ }
+
+ public void addPhaseListener(PhaseListener listener) {
+ lifecycle.addPhaseListener(listener);
+ }
+
+ public PhaseListener[] getPhaseListeners() {
+ return lifecycle.getPhaseListeners();
+ }
+
+ public void removePhaseListener(PhaseListener listener) {
+ lifecycle.removePhaseListener(listener);
+ }
+
+ public void execute(FacesContext context) throws FacesException {
+ try {
+ lifecycle.execute(context);
+ } finally {
+ PersistenceServiceRef.PERSISTENCE_SERVICE.closeEntityManager();
+ }
+ }
+
+ public void render(FacesContext context) throws FacesException {
+ try {
+ lifecycle.render(context);
+ } finally {
+ PersistenceServiceRef.PERSISTENCE_SERVICE.closeEntityManager();
+ }
+ }
+
+
+}
\ No newline at end of file
Added:
trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/PersistenceLifecycleFactory.java
===================================================================
---
trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/PersistenceLifecycleFactory.java
(rev 0)
+++
trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/PersistenceLifecycleFactory.java 2011-04-14
11:53:42 UTC (rev 22419)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.demo;
+
+import java.util.Iterator;
+
+import javax.faces.FacesWrapper;
+import javax.faces.lifecycle.Lifecycle;
+import javax.faces.lifecycle.LifecycleFactory;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class PersistenceLifecycleFactory extends LifecycleFactory implements
FacesWrapper<LifecycleFactory> {
+
+ private LifecycleFactory lifecycleFactory;
+
+ private Lifecycle defaultLifecycle;
+
+ public PersistenceLifecycleFactory(LifecycleFactory lifecycleFactory) {
+ super();
+ this.lifecycleFactory = lifecycleFactory;
+ }
+
+ @Override
+ public void addLifecycle(String lifecycleId, Lifecycle lifecycle) {
+ getWrapped().addLifecycle(lifecycleId, lifecycle);
+ }
+
+ @Override
+ public Lifecycle getLifecycle(String lifecycleId) {
+ if (LifecycleFactory.DEFAULT_LIFECYCLE.equals(lifecycleId)) {
+ if (defaultLifecycle == null) {
+ createDefaultLifecycle();
+ }
+
+ return defaultLifecycle;
+ }
+
+ return lifecycleFactory.getLifecycle(lifecycleId);
+ }
+
+ private void createDefaultLifecycle() {
+ defaultLifecycle = new
PersistenceLifecycle(lifecycleFactory.getLifecycle(DEFAULT_LIFECYCLE));
+ }
+
+ @Override
+ public Iterator<String> getLifecycleIds() {
+ return lifecycleFactory.getLifecycleIds();
+ }
+
+}
Added:
trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/PersistenceService.java
===================================================================
---
trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/PersistenceService.java
(rev 0)
+++
trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/PersistenceService.java 2011-04-14
11:53:42 UTC (rev 22419)
@@ -0,0 +1,166 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.demo;
+
+import java.io.InputStream;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.faces.bean.ApplicationScoped;
+import javax.faces.bean.ManagedBean;
+import javax.faces.context.FacesContext;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.EntityTransaction;
+import javax.persistence.Persistence;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Node;
+
+import com.google.common.collect.Lists;
+import com.google.common.io.Closeables;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@ManagedBean(eager = true)
+@ApplicationScoped
+public class PersistenceService {
+
+ private static final Logger LOGGER =
Logger.getLogger(PersistenceService.class.getName());
+
+ private EntityManagerFactory entityManagerFactory;
+
+ public EntityManager getEntityManager() {
+ Map<Object, Object> attributes =
FacesContext.getCurrentInstance().getAttributes();
+
+ EntityManager manager = (EntityManager)
attributes.get(PersistenceService.class);
+
+ if (manager == null) {
+ manager = entityManagerFactory.createEntityManager();
+ attributes.put(PersistenceService.class, manager);
+ manager.getTransaction().begin();
+ }
+
+ return manager;
+ }
+
+ void closeEntityManager() {
+ Map<Object, Object> attributes =
FacesContext.getCurrentInstance().getAttributes();
+
+ EntityManager entityManager = (EntityManager)
attributes.remove(PersistenceService.class);
+
+ if (entityManager != null) {
+ try {
+ entityManager.getTransaction().commit();
+ } catch (Exception e) {
+ LOGGER.log(Level.SEVERE, e.getMessage(), e);
+ try {
+ entityManager.getTransaction().rollback();
+ } catch (Exception e1) {
+ LOGGER.log(Level.SEVERE, e1.getMessage(), e1);
+ }
+ } finally {
+ entityManager.close();
+ }
+ }
+ }
+
+ @PostConstruct
+ public void init() {
+ entityManagerFactory =
Persistence.createEntityManagerFactory("iterationDemo", new Properties());
+
+
+ EntityManager em = entityManagerFactory.createEntityManager();
+
+ EntityTransaction transaction = em.getTransaction();
+
+ try {
+ transaction.begin();
+
+ for (Person person: parseTestData()) {
+ em.persist(person);
+ }
+
+ transaction.commit();
+ } catch (Exception e) {
+ transaction.rollback();
+ e.printStackTrace();
+ } finally {
+ em.close();
+ }
+ }
+
+ private List<Person> parseTestData() throws Exception {
+ InputStream dataStream = null;
+ try {
+ dataStream =
PersistenceService.class.getResourceAsStream("data.xml");
+ DocumentBuilder documentBuilder =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ Node node = documentBuilder.parse(dataStream).getDocumentElement();
+
+ List<Person> persons = Lists.newArrayList();
+
+ for (Node personNode = node.getFirstChild(); personNode != null; personNode =
personNode.getNextSibling()) {
+ if (personNode.getNodeType() != Node.ELEMENT_NODE) {
+ continue;
+ }
+
+ Person person = new Person();
+ persons.add(person);
+
+ for (Node personDataNode = personNode.getFirstChild(); personDataNode !=
null; personDataNode = personDataNode.getNextSibling()) {
+ if (personDataNode.getNodeType() != Node.ELEMENT_NODE) {
+ continue;
+ }
+
+ String nodeName = personDataNode.getNodeName();
+ String text = personDataNode.getTextContent();
+ if ("name".equals(nodeName)) {
+ person.setName(text);
+ } else if ("surname".equals(nodeName)) {
+ person.setSurname(text);
+ } else if ("email".equals(nodeName)) {
+ person.setEmail(text);
+ }
+ }
+ }
+
+ return persons;
+ } finally {
+ Closeables.closeQuietly(dataStream);
+ }
+ }
+
+ @PreDestroy
+ public void destroy() {
+ entityManagerFactory.close();
+ entityManagerFactory = null;
+ }
+
+}
Added: trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/Person.java
===================================================================
--- trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/Person.java
(rev 0)
+++ trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/Person.java 2011-04-14
11:53:42 UTC (rev 22419)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.demo;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@Entity
+public class Person {
+
+ private String name;
+
+ private String surname;
+
+ private String email;
+
+ @Id
+ @GeneratedValue
+ private Long id;
+
+ public Person() {
+ }
+
+ public Person(String name) {
+ super();
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getSurname() {
+ return surname;
+ }
+
+ public void setSurname(String surname) {
+ this.surname = surname;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+}
Added: trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/PersonBean.java
===================================================================
--- trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/PersonBean.java
(rev 0)
+++
trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/PersonBean.java 2011-04-14
11:53:42 UTC (rev 22419)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.demo;
+
+
+import java.util.Map;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.ManagedProperty;
+import javax.faces.bean.SessionScoped;
+import javax.persistence.EntityManager;
+
+import org.richfaces.component.SortOrder;
+
+import com.google.common.collect.Maps;
+
+
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@ManagedBean
+@SessionScoped
+public class PersonBean {
+
+ private static final class PersonDataModel extends JPADataModel<Person> {
+
+ private PersonDataModel(EntityManager entityManager) {
+ super(entityManager, Person.class);
+ }
+
+ @Override
+ protected Object getId(Person t) {
+ return t.getId();
+ }
+ }
+
+ @ManagedProperty(value = "#{persistenceService}")
+ private PersistenceService persistenceService;
+
+ private Map<String, SortOrder> sortOrders =
Maps.newHashMapWithExpectedSize(1);
+
+ private Map<String, String> filterValues = Maps.newHashMap();
+
+ public void setPersistenceService(PersistenceService persistenceService) {
+ this.persistenceService = persistenceService;
+ }
+
+ public Map<String, SortOrder> getSortOrders() {
+ return sortOrders;
+ }
+
+ public Map<String, String> getFilterValues() {
+ return filterValues;
+ }
+
+ public SortOrder getSortOrder(String name) {
+ SortOrder sortOrder = getSortOrders().get(name);
+
+ if (sortOrder == null) {
+ sortOrder = SortOrder.unsorted;
+ }
+
+ return sortOrder;
+ }
+
+ public void switchSortOrder(String name) {
+ SortOrder newSortOrder = null;
+
+ switch (getSortOrder(name)) {
+ case unsorted:
+ newSortOrder = SortOrder.ascending;
+ break;
+ case ascending:
+ newSortOrder = SortOrder.descending;
+ break;
+ case descending:
+ newSortOrder = SortOrder.ascending;
+ break;
+ default:
+ throw new IllegalStateException();
+ }
+
+ sortOrders.clear();
+ sortOrders.put(name, newSortOrder);
+ }
+
+ public Object getDataModel() {
+ return new PersonDataModel(persistenceService.getEntityManager());
+ }
+}
\ No newline at end of file
Added: trunk/examples/iteration-demo/src/main/resources/META-INF/persistence.xml
===================================================================
--- trunk/examples/iteration-demo/src/main/resources/META-INF/persistence.xml
(rev 0)
+++ trunk/examples/iteration-demo/src/main/resources/META-INF/persistence.xml 2011-04-14
11:53:42 UTC (rev 22419)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence version="1.0"
+
xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
+ <persistence-unit name="iterationDemo"
+ transaction-type="RESOURCE_LOCAL">
+
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
+ <class>org.richfaces.demo.Person</class>
+ <properties>
+ <property name="javax.persistence.jdbc.driver"
value="org.hsqldb.jdbcDriver" />
+ <property name="javax.persistence.jdbc.url"
value="jdbc:hsqldb:mem:iteration_demo" />
+ <property name="javax.persistence.jdbc.user"
value="sa" />
+ <property name="javax.persistence.jdbc.password"
value=""/>
+ <property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema" />
+ <property name="openjpa.RuntimeUnenhancedClasses"
value="supported" />
+ </properties>
+ </persistence-unit>
+</persistence>
\ No newline at end of file
Added: trunk/examples/iteration-demo/src/main/resources/org/richfaces/demo/data.xml
===================================================================
--- trunk/examples/iteration-demo/src/main/resources/org/richfaces/demo/data.xml
(rev 0)
+++
trunk/examples/iteration-demo/src/main/resources/org/richfaces/demo/data.xml 2011-04-14
11:53:42 UTC (rev 22419)
@@ -0,0 +1,1003 @@
+<persons>
+ <person>
+ <name>Savannah</name>
+ <surname>Dickerson</surname>
+ <email>ac.sem(a)Phasellus.com</email>
+ </person>
+ <person>
+ <name>Melyssa</name>
+ <surname>Scott</surname>
+ <email>orci(a)at.com</email>
+ </person>
+ <person>
+ <name>Jemima</name>
+ <surname>Workman</surname>
+ <email>ac.mattis.semper(a)eget.org</email>
+ </person>
+ <person>
+ <name>Evelyn</name>
+ <surname>Santiago</surname>
+ <email>consectetuer.cursus(a)nonmagna.com</email>
+ </person>
+ <person>
+ <name>Blossom</name>
+ <surname>Diaz</surname>
+ <email>non.leo(a)mattisvelit.ca</email>
+ </person>
+ <person>
+ <name>Miriam</name>
+ <surname>Gonzales</surname>
+ <email>velit(a)urna.com</email>
+ </person>
+ <person>
+ <name>Jada</name>
+ <surname>Dennis</surname>
+ <email>lectus.ante(a)lectus.com</email>
+ </person>
+ <person>
+ <name>Jessica</name>
+ <surname>Cotton</surname>
+ <email>in(a)purus.com</email>
+ </person>
+ <person>
+ <name>Henry</name>
+ <surname>Blackburn</surname>
+ <email>amet.risus.Donec(a)semper.com</email>
+ </person>
+ <person>
+ <name>Raymond</name>
+ <surname>Estrada</surname>
+ <email>vitae(a)eutellus.ca</email>
+ </person>
+ <person>
+ <name>Rhiannon</name>
+ <surname>Dodson</surname>
+ <email>dictum(a)Nullamscelerisque.edu</email>
+ </person>
+ <person>
+ <name>Nigel</name>
+ <surname>Ferrell</surname>
+ <email>dictum.Phasellus(a)velitin.ca</email>
+ </person>
+ <person>
+ <name>Kane</name>
+ <surname>Cook</surname>
+ <email>massa.Vestibulum(a)eu.com</email>
+ </person>
+ <person>
+ <name>Leandra</name>
+ <surname>Macias</surname>
+ <email>erat.Vivamus.nisi(a)NullainterdumCurabitur.ca</email>
+ </person>
+ <person>
+ <name>Ivory</name>
+ <surname>Sanchez</surname>
+ <email>Cras.lorem(a)non.org</email>
+ </person>
+ <person>
+ <name>Kelly</name>
+ <surname>Palmer</surname>
+ <email>dolor.egestas.rhoncus(a)risusDonecegestas.com</email>
+ </person>
+ <person>
+ <name>Jenna</name>
+ <surname>Willis</surname>
+ <email>ipsum.dolor(a)luctus.ca</email>
+ </person>
+ <person>
+ <name>Ivana</name>
+ <surname>Wolf</surname>
+ <email>ac(a)infelis.com</email>
+ </person>
+ <person>
+ <name>Graiden</name>
+ <surname>Hall</surname>
+ <email>purus(a)Integer.edu</email>
+ </person>
+ <person>
+ <name>Daria</name>
+ <surname>Petty</surname>
+ <email>tortor.dictum(a)egestasrhoncus.edu</email>
+ </person>
+ <person>
+ <name>Holmes</name>
+ <surname>Lang</surname>
+ <email>adipiscing.enim(a)Nullamscelerisque.ca</email>
+ </person>
+ <person>
+ <name>Michelle</name>
+ <surname>Miranda</surname>
+ <email>Nam.consequat.dolor(a)Naminterdum.edu</email>
+ </person>
+ <person>
+ <name>Calista</name>
+ <surname>Everett</surname>
+ <email>Donec.nibh(a)laoreetlibero.com</email>
+ </person>
+ <person>
+ <name>September</name>
+ <surname>Nicholson</surname>
+ <email>iaculis.odio(a)sollicitudincommodo.ca</email>
+ </person>
+ <person>
+ <name>Rosalyn</name>
+ <surname>Cline</surname>
+ <email>Fusce.fermentum.fermentum(a)gravidanuncsed.edu</email>
+ </person>
+ <person>
+ <name>Christen</name>
+ <surname>Cleveland</surname>
+ <email>Duis.volutpat.nunc(a)metusvitaevelit.ca</email>
+ </person>
+ <person>
+ <name>Igor</name>
+ <surname>Sears</surname>
+ <email>non(a)eu.edu</email>
+ </person>
+ <person>
+ <name>Plato</name>
+ <surname>Johnston</surname>
+ <email>suscipit.est(a)Lorem.org</email>
+ </person>
+ <person>
+ <name>Kelsie</name>
+ <surname>Peterson</surname>
+ <email>lacus.Aliquam(a)dolorelitpellentesque.org</email>
+ </person>
+ <person>
+ <name>Lionel</name>
+ <surname>Puckett</surname>
+ <email>mi.lacinia.mattis(a)lacusEtiambibendum.org</email>
+ </person>
+ <person>
+ <name>Orlando</name>
+ <surname>Hayes</surname>
+ <email>Mauris.quis(a)fringilla.org</email>
+ </person>
+ <person>
+ <name>Fuller</name>
+ <surname>Keller</surname>
+ <email>In.nec.orci(a)utmolestiein.org</email>
+ </person>
+ <person>
+ <name>Brandon</name>
+ <surname>Woodward</surname>
+ <email>eget.magna(a)etnuncQuisque.edu</email>
+ </person>
+ <person>
+ <name>Lyle</name>
+ <surname>George</surname>
+ <email>lacus.Mauris(a)risus.edu</email>
+ </person>
+ <person>
+ <name>Abbot</name>
+ <surname>Valdez</surname>
+ <email>tincidunt.Donec.vitae(a)velit.ca</email>
+ </person>
+ <person>
+ <name>Kessie</name>
+ <surname>Carr</surname>
+ <email>Suspendisse.commodo(a)nonbibendum.ca</email>
+ </person>
+ <person>
+ <name>Louis</name>
+ <surname>Mitchell</surname>
+ <email>condimentum.Donec(a)convallisconvallis.com</email>
+ </person>
+ <person>
+ <name>Francesca</name>
+ <surname>Walters</surname>
+ <email>non.leo(a)eu.edu</email>
+ </person>
+ <person>
+ <name>Giacomo</name>
+ <surname>Cross</surname>
+ <email>Morbi(a)nunc.edu</email>
+ </person>
+ <person>
+ <name>Iris</name>
+ <surname>Curtis</surname>
+ <email>nec.euismod.in(a)Nullamsuscipit.ca</email>
+ </person>
+ <person>
+ <name>Abdul</name>
+ <surname>Atkins</surname>
+ <email>Donec.non.justo(a)lobortismauris.com</email>
+ </person>
+ <person>
+ <name>Dominique</name>
+ <surname>Knight</surname>
+ <email>suscipit.est.ac(a)odioNam.org</email>
+ </person>
+ <person>
+ <name>Odysseus</name>
+ <surname>Barnett</surname>
+ <email>nisi.a.odio(a)tempor.com</email>
+ </person>
+ <person>
+ <name>Hammett</name>
+ <surname>Ray</surname>
+ <email>eu.sem(a)purusactellus.ca</email>
+ </person>
+ <person>
+ <name>Gage</name>
+ <surname>Branch</surname>
+ <email>ac.libero(a)neque.ca</email>
+ </person>
+ <person>
+ <name>Quinn</name>
+ <surname>Wilcox</surname>
+ <email>Fusce(a)ipsumdolor.org</email>
+ </person>
+ <person>
+ <name>Ursa</name>
+ <surname>Bishop</surname>
+ <email>montes(a)tempor.org</email>
+ </person>
+ <person>
+ <name>Gray</name>
+ <surname>Riddle</surname>
+ <email>Suspendisse(a)magnanec.org</email>
+ </person>
+ <person>
+ <name>Jorden</name>
+ <surname>Christensen</surname>
+ <email>a.feugiat(a)id.edu</email>
+ </person>
+ <person>
+ <name>Hashim</name>
+ <surname>Knight</surname>
+ <email>Mauris(a)aliquetProin.edu</email>
+ </person>
+ <person>
+ <name>Whitney</name>
+ <surname>Hansen</surname>
+ <email>nibh.Phasellus.nulla(a)ullamcorperDuis.org</email>
+ </person>
+ <person>
+ <name>Lacy</name>
+ <surname>Thompson</surname>
+ <email>justo(a)egestasurnajusto.org</email>
+ </person>
+ <person>
+ <name>Chelsea</name>
+ <surname>Blanchard</surname>
+ <email>magna(a)dictum.org</email>
+ </person>
+ <person>
+ <name>Kaseem</name>
+ <surname>Melendez</surname>
+ <email>sem.semper.erat(a)mattis.edu</email>
+ </person>
+ <person>
+ <name>Lillian</name>
+ <surname>Conway</surname>
+ <email>mattis(a)egetmetus.com</email>
+ </person>
+ <person>
+ <name>Allistair</name>
+ <surname>Britt</surname>
+ <email>tellus.faucibus.leo(a)Aenean.org</email>
+ </person>
+ <person>
+ <name>Merritt</name>
+ <surname>Melton</surname>
+ <email>blandit(a)enimdiamvel.org</email>
+ </person>
+ <person>
+ <name>Vivien</name>
+ <surname>Baker</surname>
+ <email>accumsan(a)velitegestas.com</email>
+ </person>
+ <person>
+ <name>Quinn</name>
+ <surname>Lowery</surname>
+ <email>vitae.erat(a)ridiculusmusDonec.ca</email>
+ </person>
+ <person>
+ <name>Fleur</name>
+ <surname>Rios</surname>
+ <email>ullamcorper.viverra(a)egetvolutpatornare.ca</email>
+ </person>
+ <person>
+ <name>Suki</name>
+ <surname>Leach</surname>
+ <email>luctus.Curabitur(a)nibh.com</email>
+ </person>
+ <person>
+ <name>Scarlet</name>
+ <surname>Cannon</surname>
+ <email>dictum.eu.placerat(a)imperdiet.edu</email>
+ </person>
+ <person>
+ <name>Ross</name>
+ <surname>Reid</surname>
+ <email>in.hendrerit(a)tincidunt.ca</email>
+ </person>
+ <person>
+ <name>Amethyst</name>
+ <surname>Pennington</surname>
+ <email>Mauris.nulla.Integer(a)Fuscemollis.org</email>
+ </person>
+ <person>
+ <name>Gregory</name>
+ <surname>Lyons</surname>
+ <email>nisl.sem.consequat(a)Phasellus.ca</email>
+ </person>
+ <person>
+ <name>Constance</name>
+ <surname>Thomas</surname>
+ <email>accumsan(a)ipsum.ca</email>
+ </person>
+ <person>
+ <name>Cleo</name>
+ <surname>Chandler</surname>
+ <email>massa(a)penatibusetmagnis.org</email>
+ </person>
+ <person>
+ <name>Cruz</name>
+ <surname>Paul</surname>
+ <email>ornare.In(a)temporbibendum.org</email>
+ </person>
+ <person>
+ <name>Tyrone</name>
+ <surname>Nunez</surname>
+ <email>arcu.Nunc(a)nisi.org</email>
+ </person>
+ <person>
+ <name>Evan</name>
+ <surname>Erickson</surname>
+ <email>Etiam(a)nibh.org</email>
+ </person>
+ <person>
+ <name>Claudia</name>
+ <surname>Nash</surname>
+ <email>Cras.sed(a)estacmattis.com</email>
+ </person>
+ <person>
+ <name>Pascale</name>
+ <surname>Cherry</surname>
+ <email>mi(a)nonjustoProin.edu</email>
+ </person>
+ <person>
+ <name>Evelyn</name>
+ <surname>Baxter</surname>
+ <email>ante.ipsum.primis(a)adlitoratorquent.org</email>
+ </person>
+ <person>
+ <name>Wing</name>
+ <surname>Gill</surname>
+ <email>per(a)semperet.ca</email>
+ </person>
+ <person>
+ <name>Raja</name>
+ <surname>Smith</surname>
+ <email>euismod.in(a)Duisa.com</email>
+ </person>
+ <person>
+ <name>Gail</name>
+ <surname>Fisher</surname>
+ <email>Integer.mollis.Integer(a)nullaInteger.edu</email>
+ </person>
+ <person>
+ <name>Garth</name>
+ <surname>Kaufman</surname>
+ <email>Suspendisse(a)conguea.ca</email>
+ </person>
+ <person>
+ <name>Donna</name>
+ <surname>Holman</surname>
+ <email>orci.luctus(a)Integerinmagna.com</email>
+ </person>
+ <person>
+ <name>Harriet</name>
+ <surname>Rhodes</surname>
+ <email>eu(a)ametultricies.edu</email>
+ </person>
+ <person>
+ <name>Brody</name>
+ <surname>Jacobs</surname>
+ <email>magna.sed(a)Vivamusmolestiedapibus.org</email>
+ </person>
+ <person>
+ <name>Colton</name>
+ <surname>Duffy</surname>
+ <email>id.magna(a)nullaIntegervulputate.edu</email>
+ </person>
+ <person>
+ <name>Edan</name>
+ <surname>Baxter</surname>
+ <email>Cras(a)orciUt.ca</email>
+ </person>
+ <person>
+ <name>Desirae</name>
+ <surname>Thomas</surname>
+ <email>et(a)hendreritDonec.ca</email>
+ </person>
+ <person>
+ <name>Drew</name>
+ <surname>Dixon</surname>
+ <email>lectus.a.sollicitudin(a)rutrumurnanec.ca</email>
+ </person>
+ <person>
+ <name>Jasper</name>
+ <surname>Stein</surname>
+ <email>Nunc.commodo(a)Duis.edu</email>
+ </person>
+ <person>
+ <name>Stacy</name>
+ <surname>Taylor</surname>
+ <email>turpis.non(a)maurisblanditmattis.org</email>
+ </person>
+ <person>
+ <name>Indigo</name>
+ <surname>Ballard</surname>
+ <email>pellentesque.massa(a)odioEtiamligula.com</email>
+ </person>
+ <person>
+ <name>Leroy</name>
+ <surname>Golden</surname>
+ <email>ultrices(a)Aliquamnec.com</email>
+ </person>
+ <person>
+ <name>Erasmus</name>
+ <surname>Mcguire</surname>
+ <email>fermentum(a)Donecporttitor.com</email>
+ </person>
+ <person>
+ <name>Lev</name>
+ <surname>Mccray</surname>
+ <email>lectus.convallis.est(a)blanditenim.org</email>
+ </person>
+ <person>
+ <name>Ima</name>
+ <surname>Petersen</surname>
+ <email>egestas(a)acmieleifend.org</email>
+ </person>
+ <person>
+ <name>Murphy</name>
+ <surname>Mcintosh</surname>
+ <email>tempus.risus.Donec(a)dolorquamelementum.edu</email>
+ </person>
+ <person>
+ <name>Kelsie</name>
+ <surname>Cantrell</surname>
+ <email>ut.aliquam(a)commodohendreritDonec.org</email>
+ </person>
+ <person>
+ <name>Claudia</name>
+ <surname>Carlson</surname>
+ <email>fringilla(a)fermentumconvallisligula.com</email>
+ </person>
+ <person>
+ <name>Cole</name>
+ <surname>Walsh</surname>
+ <email>quis.pede.Praesent(a)intempus.org</email>
+ </person>
+ <person>
+ <name>Hu</name>
+ <surname>Baker</surname>
+ <email>Aliquam(a)Vivamusnibh.com</email>
+ </person>
+ <person>
+ <name>Lara</name>
+ <surname>Wong</surname>
+ <email>a.dui(a)leo.ca</email>
+ </person>
+ <person>
+ <name>Simone</name>
+ <surname>Lancaster</surname>
+ <email>netus.et(a)egettincidunt.ca</email>
+ </person>
+ <person>
+ <name>Heather</name>
+ <surname>Harrison</surname>
+ <email>tellus(a)lacus.edu</email>
+ </person>
+ <person>
+ <name>Zenia</name>
+ <surname>Curtis</surname>
+ <email>faucibus.lectus.a(a)fringilla.org</email>
+ </person>
+ <person>
+ <name>Stuart</name>
+ <surname>Pugh</surname>
+ <email>nulla.Cras.eu(a)asollicitudinorci.org</email>
+ </person>
+ <person>
+ <name>Shelley</name>
+ <surname>Goodman</surname>
+ <email>quam.dignissim(a)habitantmorbitristique.ca</email>
+ </person>
+ <person>
+ <name>Keegan</name>
+ <surname>Olson</surname>
+ <email>dolor.dapibus(a)tortor.org</email>
+ </person>
+ <person>
+ <name>Hop</name>
+ <surname>Rodriguez</surname>
+ <email>vitae.semper.egestas(a)natoque.ca</email>
+ </person>
+ <person>
+ <name>Deanna</name>
+ <surname>Frye</surname>
+ <email>Vivamus(a)risus.org</email>
+ </person>
+ <person>
+ <name>Rebecca</name>
+ <surname>Medina</surname>
+ <email>sociis(a)etmagnisdis.com</email>
+ </person>
+ <person>
+ <name>Sarah</name>
+ <surname>Patton</surname>
+ <email>ullamcorper(a)ettristique.com</email>
+ </person>
+ <person>
+ <name>Jenette</name>
+ <surname>Martin</surname>
+ <email>tempor.lorem.eget(a)etrutrum.com</email>
+ </person>
+ <person>
+ <name>Gil</name>
+ <surname>Brady</surname>
+ <email>tellus(a)inmagna.org</email>
+ </person>
+ <person>
+ <name>Jena</name>
+ <surname>Merritt</surname>
+ <email>litora(a)eu.ca</email>
+ </person>
+ <person>
+ <name>Christine</name>
+ <surname>Brennan</surname>
+ <email>ac(a)lectusasollicitudin.com</email>
+ </person>
+ <person>
+ <name>Clark</name>
+ <surname>Contreras</surname>
+ <email>natoque.penatibus.et(a)orciUtsagittis.org</email>
+ </person>
+ <person>
+ <name>Bo</name>
+ <surname>Becker</surname>
+ <email>est.vitae.sodales(a)Fusce.edu</email>
+ </person>
+ <person>
+ <name>Lacey</name>
+ <surname>Guerrero</surname>
+ <email>Fusce.dolor.quam(a)Aliquamvulputateullamcorper.com</email>
+ </person>
+ <person>
+ <name>Cullen</name>
+ <surname>Mason</surname>
+ <email>bibendum(a)purusin.com</email>
+ </person>
+ <person>
+ <name>Jenette</name>
+ <surname>Stuart</surname>
+ <email>sociis.natoque.penatibus(a)penatibus.com</email>
+ </person>
+ <person>
+ <name>Selma</name>
+ <surname>Zamora</surname>
+ <email>pede.Suspendisse.dui(a)fermentum.com</email>
+ </person>
+ <person>
+ <name>Clinton</name>
+ <surname>Peterson</surname>
+ <email>odio.Etiam(a)ornare.ca</email>
+ </person>
+ <person>
+ <name>Axel</name>
+ <surname>Henderson</surname>
+ <email>a(a)pedeCumsociis.org</email>
+ </person>
+ <person>
+ <name>Margaret</name>
+ <surname>Roy</surname>
+ <email>Sed(a)vehicularisusNulla.ca</email>
+ </person>
+ <person>
+ <name>Price</name>
+ <surname>Lyons</surname>
+ <email>magna(a)habitantmorbi.org</email>
+ </person>
+ <person>
+ <name>Logan</name>
+ <surname>Sharp</surname>
+ <email>In.at.pede(a)auctorodio.org</email>
+ </person>
+ <person>
+ <name>Marvin</name>
+ <surname>Ramirez</surname>
+ <email>Donec.tincidunt(a)et.edu</email>
+ </person>
+ <person>
+ <name>Briar</name>
+ <surname>Short</surname>
+ <email>nunc.interdum.feugiat(a)sedhendrerit.ca</email>
+ </person>
+ <person>
+ <name>Flynn</name>
+ <surname>York</surname>
+ <email>non.nisi(a)purusmauris.org</email>
+ </person>
+ <person>
+ <name>Benjamin</name>
+ <surname>Stevenson</surname>
+ <email>consectetuer(a)Aeneaneuismodmauris.org</email>
+ </person>
+ <person>
+ <name>Dieter</name>
+ <surname>Nicholson</surname>
+ <email>risus(a)enimgravida.org</email>
+ </person>
+ <person>
+ <name>Lacy</name>
+ <surname>Baker</surname>
+ <email>eu.neque.pellentesque(a)duiFuscealiquam.com</email>
+ </person>
+ <person>
+ <name>Kaseem</name>
+ <surname>Holder</surname>
+ <email>non.quam(a)Loremipsum.ca</email>
+ </person>
+ <person>
+ <name>Yeo</name>
+ <surname>Sanchez</surname>
+ <email>nisi.a(a)Namnullamagna.ca</email>
+ </person>
+ <person>
+ <name>Heidi</name>
+ <surname>Black</surname>
+ <email>tempus(a)faucibuslectusa.org</email>
+ </person>
+ <person>
+ <name>Cameron</name>
+ <surname>Vang</surname>
+ <email>turpis(a)tinciduntnuncac.com</email>
+ </person>
+ <person>
+ <name>Ryan</name>
+ <surname>Harris</surname>
+ <email>nec.ligula.consectetuer(a)risusInmi.edu</email>
+ </person>
+ <person>
+ <name>Debra</name>
+ <surname>Cortez</surname>
+ <email>luctus(a)pede.com</email>
+ </person>
+ <person>
+ <name>Neville</name>
+ <surname>Mcintyre</surname>
+ <email>egestas(a)placeratvelitQuisque.ca</email>
+ </person>
+ <person>
+ <name>Hope</name>
+ <surname>Romero</surname>
+ <email>dignissim.tempor(a)nonmagnaNam.com</email>
+ </person>
+ <person>
+ <name>Mechelle</name>
+ <surname>Kidd</surname>
+ <email>orci.Ut.sagittis(a)nonenimcommodo.ca</email>
+ </person>
+ <person>
+ <name>Nora</name>
+ <surname>Rivera</surname>
+ <email>gravida(a)consequatdolorvitae.edu</email>
+ </person>
+ <person>
+ <name>Zeph</name>
+ <surname>Snyder</surname>
+ <email>Donec.est(a)enimEtiam.ca</email>
+ </person>
+ <person>
+ <name>Britanni</name>
+ <surname>Williamson</surname>
+ <email>nulla.ante(a)sempereratin.edu</email>
+ </person>
+ <person>
+ <name>Jermaine</name>
+ <surname>Jones</surname>
+ <email>sapien.Aenean(a)Quisquenonummyipsum.org</email>
+ </person>
+ <person>
+ <name>Steel</name>
+ <surname>Newton</surname>
+ <email>cursus.et(a)Curabiturut.org</email>
+ </person>
+ <person>
+ <name>Hyatt</name>
+ <surname>Manning</surname>
+ <email>eget.massa.Suspendisse(a)aptenttaciti.edu</email>
+ </person>
+ <person>
+ <name>Stone</name>
+ <surname>Sloan</surname>
+ <email>adipiscing.elit.Curabitur(a)estvitaesodales.org</email>
+ </person>
+ <person>
+ <name>Lewis</name>
+ <surname>Guthrie</surname>
+ <email>neque.Nullam(a)Nuncpulvinararcu.edu</email>
+ </person>
+ <person>
+ <name>Sandra</name>
+ <surname>Cannon</surname>
+ <email>lobortis.nisi.nibh(a)luctuslobortisClass.com</email>
+ </person>
+ <person>
+ <name>Daria</name>
+ <surname>Page</surname>
+ <email>Aenean.sed.pede(a)facilisis.edu</email>
+ </person>
+ <person>
+ <name>Mohammad</name>
+ <surname>Soto</surname>
+ <email>blandit(a)aliquamarcuAliquam.org</email>
+ </person>
+ <person>
+ <name>Kerry</name>
+ <surname>Lowery</surname>
+ <email>vitae(a)mauriserateget.edu</email>
+ </person>
+ <person>
+ <name>Quinlan</name>
+ <surname>Roy</surname>
+ <email>est.ac(a)mollisvitaeposuere.com</email>
+ </person>
+ <person>
+ <name>Patricia</name>
+ <surname>Kirkland</surname>
+ <email>ipsum.dolor(a)orci.org</email>
+ </person>
+ <person>
+ <name>Janna</name>
+ <surname>Banks</surname>
+ <email>id.mollis.nec(a)eteuismodet.org</email>
+ </person>
+ <person>
+ <name>Lucius</name>
+ <surname>William</surname>
+ <email>sem(a)Nullamlobortis.com</email>
+ </person>
+ <person>
+ <name>Ira</name>
+ <surname>Buck</surname>
+ <email>pede.nonummy(a)dapibusgravidaAliquam.ca</email>
+ </person>
+ <person>
+ <name>Shellie</name>
+ <surname>Charles</surname>
+ <email>est(a)lobortisultricesVivamus.org</email>
+ </person>
+ <person>
+ <name>Stewart</name>
+ <surname>Cabrera</surname>
+ <email>libero(a)feugiat.com</email>
+ </person>
+ <person>
+ <name>April</name>
+ <surname>Sheppard</surname>
+ <email>sit(a)seddictumeleifend.ca</email>
+ </person>
+ <person>
+ <name>Gail</name>
+ <surname>Rollins</surname>
+ <email>odio(a)Proinnonmassa.ca</email>
+ </person>
+ <person>
+ <name>Ross</name>
+ <surname>Levy</surname>
+ <email>sit.amet.ultricies(a)Quisqueliberolacus.com</email>
+ </person>
+ <person>
+ <name>Hadley</name>
+ <surname>Mccormick</surname>
+ <email>vitae.posuere.at(a)enimnonnisi.org</email>
+ </person>
+ <person>
+ <name>Susan</name>
+ <surname>Banks</surname>
+ <email>interdum(a)nislsemconsequat.org</email>
+ </person>
+ <person>
+ <name>Nash</name>
+ <surname>Nolan</surname>
+ <email>convallis.dolor(a)enimSed.ca</email>
+ </person>
+ <person>
+ <name>Gretchen</name>
+ <surname>Carson</surname>
+ <email>elit.dictum.eu(a)temporarcuVestibulum.ca</email>
+ </person>
+ <person>
+ <name>Harper</name>
+ <surname>Hull</surname>
+ <email>eget(a)imperdiet.edu</email>
+ </person>
+ <person>
+ <name>Porter</name>
+ <surname>Benson</surname>
+ <email>tempus.non(a)Aenean.org</email>
+ </person>
+ <person>
+ <name>Xenos</name>
+ <surname>Tate</surname>
+ <email>blandit(a)antebibendum.org</email>
+ </person>
+ <person>
+ <name>Ali</name>
+ <surname>Carver</surname>
+ <email>Nulla.aliquet(a)ornare.org</email>
+ </person>
+ <person>
+ <name>Zachery</name>
+ <surname>Shepherd</surname>
+ <email>vitae.erat(a)sed.edu</email>
+ </person>
+ <person>
+ <name>Garrett</name>
+ <surname>Leach</surname>
+ <email>risus(a)quisurna.org</email>
+ </person>
+ <person>
+ <name>Mufutau</name>
+ <surname>Greer</surname>
+ <email>bibendum(a)luctus.com</email>
+ </person>
+ <person>
+ <name>Ryan</name>
+ <surname>Bryant</surname>
+ <email>turpis(a)purus.edu</email>
+ </person>
+ <person>
+ <name>Lacey</name>
+ <surname>Riley</surname>
+ <email>sed.turpis.nec(a)molestieSed.ca</email>
+ </person>
+ <person>
+ <name>Tiger</name>
+ <surname>Ryan</surname>
+ <email>lorem(a)vel.com</email>
+ </person>
+ <person>
+ <name>Upton</name>
+ <surname>Sullivan</surname>
+ <email>amet(a)Proin.com</email>
+ </person>
+ <person>
+ <name>Juliet</name>
+ <surname>Tate</surname>
+ <email>pede.Cum(a)eu.edu</email>
+ </person>
+ <person>
+ <name>Dieter</name>
+ <surname>Bowman</surname>
+ <email>lorem.eu(a)pellentesqueegetdictum.com</email>
+ </person>
+ <person>
+ <name>Jelani</name>
+ <surname>Knapp</surname>
+ <email>Nulla(a)Morbi.org</email>
+ </person>
+ <person>
+ <name>Martena</name>
+ <surname>Leblanc</surname>
+ <email>arcu.Vestibulum.ut(a)quamquis.edu</email>
+ </person>
+ <person>
+ <name>Megan</name>
+ <surname>Hull</surname>
+ <email>eu.nulla(a)amalesuada.com</email>
+ </person>
+ <person>
+ <name>Ginger</name>
+ <surname>Mcpherson</surname>
+ <email>dui.augue(a)Innecorci.com</email>
+ </person>
+ <person>
+ <name>Kylan</name>
+ <surname>Gilmore</surname>
+ <email>urna.Ut.tincidunt(a)aliquetsemut.com</email>
+ </person>
+ <person>
+ <name>Carlos</name>
+ <surname>King</surname>
+ <email>fermentum(a)lacus.com</email>
+ </person>
+ <person>
+ <name>Irma</name>
+ <surname>Blake</surname>
+ <email>Aliquam.nec(a)adipiscingelit.com</email>
+ </person>
+ <person>
+ <name>Tad</name>
+ <surname>Allen</surname>
+ <email>rhoncus.Proin.nisl(a)vehiculaaliquet.ca</email>
+ </person>
+ <person>
+ <name>Fiona</name>
+ <surname>Kline</surname>
+ <email>risus(a)gravidasagittisDuis.ca</email>
+ </person>
+ <person>
+ <name>Nell</name>
+ <surname>Franco</surname>
+ <email>blandit(a)viverraMaecenasiaculis.org</email>
+ </person>
+ <person>
+ <name>Scarlet</name>
+ <surname>Hall</surname>
+ <email>tincidunt(a)Nullamsuscipit.com</email>
+ </person>
+ <person>
+ <name>Zane</name>
+ <surname>Mccray</surname>
+ <email>volutpat.Nulla(a)malesuadafringilla.edu</email>
+ </person>
+ <person>
+ <name>Connor</name>
+ <surname>Salas</surname>
+ <email>Sed.nulla.ante(a)eu.com</email>
+ </person>
+ <person>
+ <name>Carlos</name>
+ <surname>Hunt</surname>
+ <email>Nam(a)nequevenenatislacus.org</email>
+ </person>
+ <person>
+ <name>Lane</name>
+ <surname>Andrews</surname>
+ <email>a.sollicitudin(a)inconsequat.org</email>
+ </person>
+ <person>
+ <name>Shana</name>
+ <surname>Ballard</surname>
+ <email>elementum(a)nibhlacinia.org</email>
+ </person>
+ <person>
+ <name>Conan</name>
+ <surname>Bradshaw</surname>
+ <email>vel.arcu.Curabitur(a)eratnonummyultricies.ca</email>
+ </person>
+ <person>
+ <name>Colleen</name>
+ <surname>Brooks</surname>
+ <email>erat.volutpat(a)cubiliaCurae;.edu</email>
+ </person>
+ <person>
+ <name>Francis</name>
+ <surname>Hardy</surname>
+ <email>sit.amet.luctus(a)dignissimlacus.com</email>
+ </person>
+ <person>
+ <name>Reuben</name>
+ <surname>Rodriguez</surname>
+ <email>natoque.penatibus.et(a)euaccumsansed.com</email>
+ </person>
+ <person>
+ <name>Iris</name>
+ <surname>Reid</surname>
+ <email>sed(a)Quisquepurussapien.edu</email>
+ </person>
+ <person>
+ <name>Phillip</name>
+ <surname>Schmidt</surname>
+ <email>ut(a)tortornibhsit.com</email>
+ </person>
+ <person>
+ <name>Jonas</name>
+ <surname>Crane</surname>
+ <email>ac.mi(a)luctusCurabitur.org</email>
+ </person>
+ <person>
+ <name>Abbot</name>
+ <surname>Terry</surname>
+ <email>fringilla(a)Crasconvallisconvallis.com</email>
+ </person>
+</persons>
+
\ No newline at end of file
Modified: trunk/examples/iteration-demo/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- trunk/examples/iteration-demo/src/main/webapp/WEB-INF/faces-config.xml 2011-04-13
09:48:09 UTC (rev 22418)
+++ trunk/examples/iteration-demo/src/main/webapp/WEB-INF/faces-config.xml 2011-04-14
11:53:42 UTC (rev 22419)
@@ -10,4 +10,8 @@
<converter-id>org.richfaces.demo.PackageKeyConverter</converter-id>
<converter-class>org.richfaces.demo.model.tree.adaptors.PackageKeyConverter</converter-class>
</converter>
+
+ <factory>
+
<lifecycle-factory>org.richfaces.demo.PersistenceLifecycleFactory</lifecycle-factory>
+ </factory>
</faces-config>
Added: trunk/examples/iteration-demo/src/main/webapp/jpaColumn.xhtml
===================================================================
--- trunk/examples/iteration-demo/src/main/webapp/jpaColumn.xhtml
(rev 0)
+++ trunk/examples/iteration-demo/src/main/webapp/jpaColumn.xhtml 2011-04-14 11:53:42 UTC
(rev 22419)
@@ -0,0 +1,29 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:it="http://richfaces.org/iteration"
+
xmlns:a4j="http://richfaces.org/a4j">
+<ui:composition>
+ <it:column sortBy="#{property}"
+ sortOrder="#{bean.sortOrders[property]}"
+ filterValue="#{bean.filterValues[property]}"
+ filterExpression="#{property}">
+ <f:facet name="header">
+ <h:commandLink style="color: white;"
+ action="#{bean.switchSortOrder(property)}">
+ #{bean.getSortOrder(property)}
+ <a4j:ajax render="richTable" />
+ </h:commandLink>
+ <br />
+ <h:inputText value="#{bean.filterValues[property]}">
+ <a4j:ajax render="richTable@body scroller" event="keyup"
/>
+ </h:inputText>
+ </f:facet>
+
+ <h:outputText value="#{record[property]}" />
+ </it:column>
+</ui:composition>
+</html>
Added: trunk/examples/iteration-demo/src/main/webapp/jpaDataTable.xhtml
===================================================================
--- trunk/examples/iteration-demo/src/main/webapp/jpaDataTable.xhtml
(rev 0)
+++ trunk/examples/iteration-demo/src/main/webapp/jpaDataTable.xhtml 2011-04-14 11:53:42
UTC (rev 22419)
@@ -0,0 +1,38 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:it="http://richfaces.org/iteration"
+
xmlns:misc="http://richfaces.org/misc"
+
xmlns:a4j="http://richfaces.org/a4j">
+<f:view contentType="text/html"/>
+
+<h:head>
+ <title>Richfaces JPA Demo</title>
+</h:head>
+
+<h:body>
+ <h:form id="form">
+ <it:dataTable keepSaved="true" id="richTable"
var="record" value="#{personBean.dataModel}" rows="20">
+ <ui:include src="jpaColumn.xhtml">
+ <ui:param name="bean" value="#{personBean}" />
+ <ui:param name="property" value="name" />
+ </ui:include>
+ <ui:include src="jpaColumn.xhtml">
+ <ui:param name="bean" value="#{personBean}" />
+ <ui:param name="property" value="surname" />
+ </ui:include>
+ <ui:include src="jpaColumn.xhtml">
+ <ui:param name="bean" value="#{personBean}" />
+ <ui:param name="property" value="email" />
+ </ui:include>
+
+ <f:facet name="footer">
+ <it:dataScroller id="scroller" />
+ </f:facet>
+ </it:dataTable>
+ </h:form>
+</h:body>
+</html>