You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ma...@apache.org on 2007/12/16 16:26:51 UTC
svn commit: r604638 -
/myfaces/trinidad/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/SortableModel.java
Author: matzew
Date: Sun Dec 16 07:26:50 2007
New Revision: 604638
URL: http://svn.apache.org/viewvc?rev=604638&view=rev
Log:
TRINIDAD-768 (applied to 12x trunk)
thx to Gerhard Petracek
Modified:
myfaces/trinidad/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/SortableModel.java
Modified: myfaces/trinidad/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/SortableModel.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/SortableModel.java?rev=604638&r1=604637&r2=604638&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/SortableModel.java (original)
+++ myfaces/trinidad/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/SortableModel.java Sun Dec 16 07:26:50 2007
@@ -151,7 +151,7 @@
try
{
PropertyResolver resolver = __getPropertyResolver();
- Object propertyValue = resolver.getValue(data, property);
+ Object propertyValue = evaluateProperty(resolver, data, property);
// when the value is null, we don't know if we can sort it.
// by default let's support sorting of null values, and let the user
@@ -173,6 +173,18 @@
}
}
+ private Object evaluateProperty(PropertyResolver resolver, Object base, String property)
+ {
+ //simple property -> resolve value directly
+ if (!property.contains( "." ))
+ return resolver.getValue( base, property );
+
+ int index = property.indexOf( '.' );
+ Object newBase = resolver.getValue( base, property.substring( 0, index ) );
+
+ return evaluateProperty( resolver, newBase, property.substring( index + 1 ) );
+ }
+
@Override
public List<SortCriterion> getSortCriteria()
{
@@ -348,11 +360,11 @@
_model.setRowIndex(index1);
Object instance1 = _model.getRowData();
- Object value1 = _resolver.getValue(instance1, _prop);
+ Object value1 = evaluateProperty( _resolver, instance1, _prop );
_model.setRowIndex(index2);
Object instance2 = _model.getRowData();
- Object value2 = _resolver.getValue(instance2, _prop);
+ Object value2 = evaluateProperty( _resolver, instance2, _prop );
if (value1 == null)
return (value2 == null) ? 0 : -1;