Author: konstantin.mishin
Date: 2010-02-25 13:58:25 -0500 (Thu, 25 Feb 2010)
New Revision: 16498
Added:
root/framework/trunk/api/src/main/java/org/richfaces/model/Field.java
root/framework/trunk/api/src/main/java/org/richfaces/model/Filter.java
root/framework/trunk/api/src/main/java/org/richfaces/model/FilterField.java
root/framework/trunk/api/src/main/java/org/richfaces/model/LocaleAware.java
root/framework/trunk/api/src/main/java/org/richfaces/model/Modifiable.java
root/framework/trunk/api/src/main/java/org/richfaces/model/ModifiableState.java
root/framework/trunk/api/src/main/java/org/richfaces/model/SortField.java
root/framework/trunk/impl/src/test/java/org/richfaces/model/ModifiableModel.java
root/framework/trunk/impl/src/test/java/org/richfaces/model/ModifiableStateDefaultImpl.java
Log:
RF-8118 RF-8119
Added: root/framework/trunk/api/src/main/java/org/richfaces/model/Field.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/Field.java
(rev 0)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/Field.java 2010-02-25
18:58:25 UTC (rev 16498)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.model;
+
+import javax.el.ValueExpression;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public abstract class Field {
+
+ private ValueExpression expression;
+
+ public Field(ValueExpression expression) {
+ this.expression = expression;
+ }
+
+ protected ValueExpression getExpression() {
+ return expression;
+ }
+}
Added: root/framework/trunk/api/src/main/java/org/richfaces/model/Filter.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/Filter.java
(rev 0)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/Filter.java 2010-02-25
18:58:25 UTC (rev 16498)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.model;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public interface Filter<T> {
+
+ boolean accept(T t);
+}
Added: root/framework/trunk/api/src/main/java/org/richfaces/model/FilterField.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/FilterField.java
(rev 0)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/FilterField.java 2010-02-25
18:58:25 UTC (rev 16498)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.model;
+
+import javax.el.ValueExpression;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class FilterField extends Field{
+
+ private Filter<?> filter;
+
+ private String filterValue;
+
+ public FilterField(ValueExpression filterExpression, Filter<?> filter, String
filterValue) {
+ super(filterExpression);
+ this.filter = filter;
+ this.filterValue = filterValue;
+ }
+
+ public ValueExpression getFilterExpression() {
+ return getExpression();
+ }
+
+ public Filter<?> getFilter() {
+ return filter;
+ }
+
+ public String getFilterValue() {
+ return filterValue;
+ }
+}
Added: root/framework/trunk/api/src/main/java/org/richfaces/model/LocaleAware.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/LocaleAware.java
(rev 0)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/LocaleAware.java 2010-02-25
18:58:25 UTC (rev 16498)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.model;
+
+import java.util.Locale;
+
+/**
+ * Models that are based on locale-dependent operations should implement this interface
+ *
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+
+public interface LocaleAware {
+
+ Locale getLocale();
+
+ void setLocale(Locale locale);
+}
Added: root/framework/trunk/api/src/main/java/org/richfaces/model/Modifiable.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/Modifiable.java
(rev 0)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/Modifiable.java 2010-02-25
18:58:25 UTC (rev 16498)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.model;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public interface Modifiable {
+
+ void modify(ModifiableState state);
+}
Added: root/framework/trunk/api/src/main/java/org/richfaces/model/ModifiableState.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/ModifiableState.java
(rev 0)
+++
root/framework/trunk/api/src/main/java/org/richfaces/model/ModifiableState.java 2010-02-25
18:58:25 UTC (rev 16498)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.model;
+
+import java.util.List;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public interface ModifiableState {
+
+ List<FilterField> getFilterFields();
+
+ List<SortField> getSortFields();
+}
Added: root/framework/trunk/api/src/main/java/org/richfaces/model/SortField.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/SortField.java
(rev 0)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/SortField.java 2010-02-25
18:58:25 UTC (rev 16498)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.model;
+
+import java.util.Comparator;
+
+import javax.el.ValueExpression;
+import javax.swing.SortOrder;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class SortField extends Field {
+
+ private Comparator<?> comparator;
+
+ private SortOrder order;
+
+ public SortField(ValueExpression sortBy, Comparator<?> comparator, SortOrder
order) {
+ super(sortBy);
+ this.comparator = comparator;
+ this.order = order;
+ }
+
+ public ValueExpression getSortBy() {
+ return getExpression();
+ }
+
+ public Comparator<?> getComparator() {
+ return comparator;
+ }
+
+ public SortOrder getSortOrder() {
+ return order;
+ }
+}
Added: root/framework/trunk/impl/src/test/java/org/richfaces/model/ModifiableModel.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/model/ModifiableModel.java
(rev 0)
+++
root/framework/trunk/impl/src/test/java/org/richfaces/model/ModifiableModel.java 2010-02-25
18:58:25 UTC (rev 16498)
@@ -0,0 +1,381 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.model;
+
+import java.text.Collator;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.el.ELContext;
+import javax.el.ValueExpression;
+import javax.faces.context.FacesContext;
+import javax.faces.model.DataModelListener;
+import javax.swing.SortOrder;
+
+import org.ajax4jsf.model.DataVisitResult;
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.ExtendedDataModel;
+import org.ajax4jsf.model.Range;
+import org.ajax4jsf.model.SequenceRange;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class ModifiableModel extends ExtendedDataModel<Object> implements
Modifiable, LocaleAware {
+
+ protected FacesContext context;
+
+ protected ELContext elContext;
+
+ protected Map<String, Object> requestMap;
+
+ protected ModifiableState state;
+
+ protected List<Object> rowKeys;
+
+ protected ExtendedDataModel<?> originalModel;
+
+ protected String var;
+
+ protected String filterVar;
+
+ protected Locale locale;
+
+ private Comparator<? super String> stringComparator;
+
+ public ModifiableModel(ExtendedDataModel<?> originalModel, String var, String
filterVar) {
+ this(FacesContext.getCurrentInstance(), originalModel, var, filterVar);
+ }
+
+ public ModifiableModel(FacesContext context, ExtendedDataModel<?>
originalModel, String var, String filterVar) {
+ this.context = context;
+ elContext = context.getELContext();
+ requestMap = context.getExternalContext().getRequestMap();
+ this.originalModel = originalModel;
+ this.var = var;
+ this.filterVar = filterVar;
+ }
+
+ @Override
+ public void addDataModelListener(DataModelListener listener) {
+ originalModel.addDataModelListener(listener);
+ }
+
+ @Override
+ public DataModelListener[] getDataModelListeners() {
+ return originalModel.getDataModelListeners();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.model.ExtendedDataModel#getRowKey()
+ */
+ @Override
+ public Object getRowKey() {
+ return originalModel.getRowKey();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.model.ExtendedDataModel#setRowKey(java.lang.Object)
+ */
+ @Override
+ public void setRowKey(Object key) {
+ originalModel.setRowKey(key);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.model.ExtendedDataModel#walk(javax.faces.context.FacesContext,
org.ajax4jsf.model.DataVisitor,
+ * org.ajax4jsf.model.Range, java.lang.Object)
+ */
+ @Override
+ public void walk(FacesContext context, DataVisitor visitor, Range range, Object
argument) {
+ final SequenceRange seqRange = (SequenceRange) range;
+ int rows = seqRange.getRows();
+ int rowCount = getRowCount();
+ int currentRow = seqRange.getFirstRow();
+ if (rows > 0) {
+ rows += currentRow;
+ rows = Math.min(rows, rowCount);
+ } else {
+ rows = rowCount;
+ }
+ for (; currentRow < rows; currentRow++) {
+ visitor.process(context, rowKeys.get(currentRow), argument);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.model.DataModel#getRowCount()
+ */
+ @Override
+ public int getRowCount() {
+ if (rowKeys == null) {
+ return -1;
+ } else {
+ return rowKeys.size();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.model.DataModel#getRowData()
+ */
+ @Override
+ public Object getRowData() {
+ return originalModel.getRowData();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.model.DataModel#getRowIndex()
+ */
+ @Override
+ public int getRowIndex() {
+ return rowKeys.indexOf(originalModel.getRowKey());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.model.DataModel#getWrappedData()
+ */
+ @Override
+ public Object getWrappedData() {
+ return originalModel.getWrappedData();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.model.DataModel#isRowAvailable()
+ */
+ @Override
+ public boolean isRowAvailable() {
+ return originalModel.isRowAvailable();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.model.DataModel#setRowIndex(int)
+ */
+ @Override
+ public void setRowIndex(int rowIndex) {
+ Object originalKey = null;
+ if (rowIndex >= 0 && rowIndex < rowKeys.size()) {
+ originalKey = rowKeys.get(rowIndex);
+ }
+ originalModel.setRowKey(originalKey);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.model.DataModel#setWrappedData(java.lang.Object)
+ */
+ @Override
+ public void setWrappedData(Object data) {
+ originalModel.setWrappedData(data);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.model.Modifiable#modify(org.richfaces.model.ModifiableState)
+ */
+ public void modify(ModifiableState state) {
+ this.state = state;
+ int rowCount = originalModel.getRowCount();
+
+ if (rowCount > 0) {
+ rowKeys = new ArrayList<Object>(rowCount);
+ } else {
+ rowKeys = new ArrayList<Object>();
+ }
+ Object rowKey = originalModel.getRowKey();
+ originalModel.walk(context, new DataVisitor() {
+ public DataVisitResult process(FacesContext context, Object rowKey, Object
argument) {
+ originalModel.setRowKey(rowKey);
+ if (originalModel.isRowAvailable()) {
+ rowKeys.add(rowKey);
+ }
+ return DataVisitResult.CONTINUE;
+ }
+ }, new SequenceRange(0, -1), null);
+ if (this.state != null) {
+ filter();
+ sort();
+ }
+ originalModel.setRowKey(rowKey);
+ }
+
+ protected void filter() {
+ List<FilterField> filterFields = state.getFilterFields();
+ if (filterFields != null && !filterFields.isEmpty()) {
+ List<Object> filteredCollection = new ArrayList<Object>();
+ for (Object rowKey : rowKeys) {
+ if (accept(rowKey)) {
+ filteredCollection.add(rowKey);
+ }
+ }
+ rowKeys = filteredCollection;
+ }
+ }
+
+ protected void sort() {
+ List<SortField> sortFields = state.getSortFields();
+ if (sortFields != null && !sortFields.isEmpty()) {
+ Collections.sort(rowKeys, new Comparator<Object>() {
+ public int compare(Object rowKey1, Object rowKey2) {
+ return ModifiableModel.this.compare(rowKey1, rowKey2);
+ }
+ });
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ protected boolean accept(Object rowKey) {
+ originalModel.setRowKey(rowKey);
+ Object object = originalModel.getRowData();
+ updateVar(var, object);
+ for (FilterField filterField : state.getFilterFields()) {
+ Filter filter = filterField.getFilter();
+ if (filter != null) {
+ return filter.accept(object);
+ } else {
+ ValueExpression filterExpression = filterField.getFilterExpression();
+ if (filterExpression != null) {
+ updateVar(filterVar, filterField.getFilterValue());
+ if (Boolean.FALSE.equals(filterExpression.getValue(elContext))) {
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected int compare(Object rowKey1, Object rowKey2) {
+ originalModel.setRowKey(rowKey1);
+ Object object1 = originalModel.getRowData();
+ originalModel.setRowKey(rowKey2);
+ Object object2 = originalModel.getRowData();
+ int result = 0;
+ for (Iterator<SortField> iterator = state.getSortFields().iterator();
iterator.hasNext() && result == 0;) {
+ SortField sortField = iterator.next();
+ SortOrder sortOrder = sortField.getSortOrder();
+ if (sortOrder != null && !SortOrder.UNSORTED.equals(sortOrder)) {
+ Comparator comparator = sortField.getComparator();
+ if (comparator != null) {
+ result = comparator.compare(object1, object2);
+ } else {
+ ValueExpression sortBy = sortField.getSortBy();
+ if (sortBy != null) {
+ updateVar(var, object1);
+ Object value1 = sortBy.getValue(elContext);
+ updateVar(var, object2);
+ Object value2 = sortBy.getValue(elContext);
+ result = compareSortByValues(value1, value2);
+ }
+ }
+ if (SortOrder.DESCENDING.equals(sortOrder)) {
+ result = -result;
+ }
+ }
+ }
+ return 0;
+ }
+
+ @SuppressWarnings("unchecked")
+ private int compareSortByValues(Object value1, Object value2) {
+ int result = 0;
+ if (value1 instanceof String && value2 instanceof String) {
+ if (stringComparator == null) {
+ stringComparator = createStringComparator();
+ }
+ result = stringComparator.compare(((String) value1).trim(), ((String)
value2).trim());
+ } else if (value1 instanceof Comparable<?>) {
+ result = ((Comparable) value1).compareTo(value2);
+ } else if (value1 == null && value2 != null) {
+ result = -1;
+ } else if (value2 == null && value1 != null) {
+ result = 1;
+ }
+ return result;
+ }
+
+ private Comparator<? super String> createStringComparator() {
+ Comparator<? super String> comparator = null;
+ if (locale != null) {
+ comparator = Collator.getInstance(locale);
+ } else {
+ comparator = new Comparator<String>() {
+ public int compare(String o1, String o2) {
+ return o1.compareToIgnoreCase(o2);
+ }
+ };
+ }
+ return comparator;
+ }
+
+ private void updateVar(String var, Object value) {
+ if (var != null && var.length() > 0) {
+ requestMap.put(var, value);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.model.LocaleAware#getLocale()
+ */
+ public Locale getLocale() {
+ return locale;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.model.LocaleAware#setLocale(java.util.Locale)
+ */
+ public void setLocale(Locale locale) {
+ this.locale = locale;
+ }
+
+}
Added:
root/framework/trunk/impl/src/test/java/org/richfaces/model/ModifiableStateDefaultImpl.java
===================================================================
---
root/framework/trunk/impl/src/test/java/org/richfaces/model/ModifiableStateDefaultImpl.java
(rev 0)
+++
root/framework/trunk/impl/src/test/java/org/richfaces/model/ModifiableStateDefaultImpl.java 2010-02-25
18:58:25 UTC (rev 16498)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.model;
+
+import java.util.List;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class ModifiableStateDefaultImpl implements ModifiableState {
+
+ private List<FilterField> filterFields;
+
+ private List<SortField> sortFields;
+
+ public ModifiableStateDefaultImpl(List<FilterField> filterFields,
List<SortField> sortFields) {
+ this.filterFields = filterFields;
+ this.sortFields = sortFields;
+ }
+
+ public List<FilterField> getFilterFields() {
+ return filterFields;
+ }
+
+ public List<SortField> getSortFields() {
+ return sortFields;
+ }
+}