You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2008/04/10 16:18:08 UTC
svn commit: r646813 - in /myfaces/tobago/trunk: core/
core/src/main/java/org/apache/myfaces/tobago/component/
core/src/main/java/org/apache/myfaces/tobago/util/ tobago-jsf-compat/
tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/compat/ tobago...
Author: bommel
Date: Thu Apr 10 07:17:54 2008
New Revision: 646813
URL: http://svn.apache.org/viewvc?rev=646813&view=rev
Log:
(TOBAGO-637) Generate Components, JSP Tags
moving some sheet sorter stuff to jsf-compat
Added:
myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/util/
myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/util/BeanComparator.java (contents, props changed)
- copied, changed from r645312, myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/BeanComparator.java
myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/util/ComparatorBase.java (contents, props changed)
- copied, changed from r645312, myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/ComparatorBase.java
myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/util/ValueBindingComparator.java (contents, props changed)
- copied, changed from r645312, myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/ValueBindingComparator.java
myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/util/ValueExpressionComparator.java (with props)
Removed:
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/BeanComparator.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/ComparatorBase.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/ValueBindingComparator.java
Modified:
myfaces/tobago/trunk/core/pom.xml
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Sorter.java
myfaces/tobago/trunk/tobago-jsf-compat/pom.xml
myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/compat/FacesUtils.java
myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/compat/FacesUtils12.java
Modified: myfaces/tobago/trunk/core/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/pom.xml?rev=646813&r1=646812&r2=646813&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/pom.xml (original)
+++ myfaces/tobago/trunk/core/pom.xml Thu Apr 10 07:17:54 2008
@@ -55,6 +55,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.0</version>
<executions>
<execution>
<id>add-source</id>
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Sorter.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Sorter.java?rev=646813&r1=646812&r2=646813&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Sorter.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Sorter.java Thu Apr 10 07:17:54 2008
@@ -24,7 +24,6 @@
import org.apache.myfaces.tobago.event.SortActionEvent;
import org.apache.myfaces.tobago.model.SheetState;
import org.apache.myfaces.tobago.util.BeanComparator;
-import org.apache.myfaces.tobago.util.ValueBindingComparator;
import org.apache.myfaces.tobago.compat.FacesUtils;
import javax.faces.component.UIColumn;
@@ -36,7 +35,6 @@
import javax.faces.component.UISelectOne;
import javax.faces.component.UISelectMany;
import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
import javax.faces.model.DataModel;
import java.util.ArrayList;
@@ -80,7 +78,6 @@
UIComponent child = getFirstSortableChild(column.getChildren());
if (child != null) {
- ValueBinding valueBinding = child.getValueBinding("value");
String var = data.getVar();
if (FacesUtils.hasValueBindingOrValueExpression(child, "value")) {
@@ -101,8 +98,9 @@
LOG.debug("Sort property is " + sortProperty);
}
} else {
- actualComparator = new ValueBindingComparator(facesContext, var,
- valueBinding, !sheetState.isAscending(), comparator);
+
+ boolean descending = !sheetState.isAscending();
+ actualComparator = FacesUtils.getBindingOrExpressionComparator(facesContext, child, var, descending, comparator);
}
}
Modified: myfaces/tobago/trunk/tobago-jsf-compat/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-jsf-compat/pom.xml?rev=646813&r1=646812&r2=646813&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-jsf-compat/pom.xml (original)
+++ myfaces/tobago/trunk/tobago-jsf-compat/pom.xml Thu Apr 10 07:17:54 2008
@@ -77,7 +77,6 @@
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
Modified: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/compat/FacesUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/compat/FacesUtils.java?rev=646813&r1=646812&r2=646813&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/compat/FacesUtils.java (original)
+++ myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/compat/FacesUtils.java Thu Apr 10 07:17:54 2008
@@ -21,6 +21,7 @@
import org.apache.commons.logging.LogFactory;
import org.apache.myfaces.tobago.event.ValueBindingTabChangeListener;
import org.apache.myfaces.tobago.event.TabChangeSource;
+import org.apache.myfaces.tobago.util.ValueBindingComparator;
import javax.faces.application.Application;
import javax.faces.component.ContextCallback;
@@ -33,6 +34,7 @@
import javax.faces.el.MethodBinding;
import javax.faces.webapp.UIComponentTag;
import javax.faces.convert.Converter;
+import java.util.Comparator;
@SuppressWarnings("deprecation")
public class FacesUtils {
@@ -237,6 +239,16 @@
source.addTabChangeListener(new ValueBindingTabChangeListener(type, (ValueBinding) bindingOrExpression));
} else {
FacesUtils12.addBindingOrExpressionTabChangeListener(source, type, bindingOrExpression);
+ }
+ }
+
+ public static Comparator getBindingOrExpressionComparator(FacesContext facesContext, UIComponent child, String var,
+ boolean descending, Comparator comparator) {
+ if (facesVersion == 11) {
+ ValueBinding valueBinding = child.getValueBinding("value");
+ return new ValueBindingComparator(facesContext, var, valueBinding, descending , comparator);
+ } else {
+ return FacesUtils12.getBindingOrExpressionComparator(facesContext, child, var, descending,comparator);
}
}
}
Modified: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/compat/FacesUtils12.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/compat/FacesUtils12.java?rev=646813&r1=646812&r2=646813&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/compat/FacesUtils12.java (original)
+++ myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/compat/FacesUtils12.java Thu Apr 10 07:17:54 2008
@@ -21,6 +21,7 @@
import org.apache.commons.logging.LogFactory;
import org.apache.myfaces.tobago.event.TabChangeSource;
import org.apache.myfaces.tobago.event.ValueExpressionTabChangeListener;
+import org.apache.myfaces.tobago.util.ValueExpressionComparator;
import javax.faces.context.FacesContext;
import javax.faces.component.UIComponent;
@@ -29,6 +30,7 @@
import javax.faces.validator.MethodExpressionValidator;
import javax.el.ValueExpression;
import javax.el.MethodExpression;
+import java.util.Comparator;
public class FacesUtils12 {
@@ -113,5 +115,11 @@
if (bindingOrExpression instanceof ValueExpression) {
source.addTabChangeListener(new ValueExpressionTabChangeListener(type, (ValueExpression) bindingOrExpression));
}
+ }
+
+ public static Comparator getBindingOrExpressionComparator(FacesContext facesContext, UIComponent child, String var,
+ boolean descending, Comparator comparator) {
+ ValueExpression valueBinding = child.getValueExpression("value");
+ return new ValueExpressionComparator(facesContext, var, valueBinding, descending , comparator);
}
}
Copied: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/util/BeanComparator.java (from r645312, myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/BeanComparator.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/util/BeanComparator.java?p2=myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/util/BeanComparator.java&p1=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/BeanComparator.java&r1=645312&r2=646813&rev=646813&view=diff
==============================================================================
(empty)
Propchange: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/util/BeanComparator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/util/BeanComparator.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Copied: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/util/ComparatorBase.java (from r645312, myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/ComparatorBase.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/util/ComparatorBase.java?p2=myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/util/ComparatorBase.java&p1=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/ComparatorBase.java&r1=645312&r2=646813&rev=646813&view=diff
==============================================================================
(empty)
Propchange: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/util/ComparatorBase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/util/ComparatorBase.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Copied: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/util/ValueBindingComparator.java (from r645312, myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/ValueBindingComparator.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/util/ValueBindingComparator.java?p2=myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/util/ValueBindingComparator.java&p1=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/ValueBindingComparator.java&r1=645312&r2=646813&rev=646813&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/ValueBindingComparator.java (original)
+++ myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/util/ValueBindingComparator.java Thu Apr 10 07:17:54 2008
@@ -28,7 +28,7 @@
/*
* Created: Mon Apr 15 15:56:44 2002
*/
-
+@SuppressWarnings("deprecation")
public class ValueBindingComparator extends ComparatorBase {
private static final Log LOG = LogFactory.getLog(ValueBindingComparator.class);
@@ -121,7 +121,7 @@
obj2 = valueBinding.getValue(facesContext);
} catch (Exception e) {
- ValueBindingComparator.LOG.error(e.getMessage(), e);
+ LOG.error(e.getMessage(), e);
return 0;
}
return super.internalCompare(obj1, obj2);
Propchange: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/util/ValueBindingComparator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/util/ValueBindingComparator.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/util/ValueExpressionComparator.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/util/ValueExpressionComparator.java?rev=646813&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/util/ValueExpressionComparator.java (added)
+++ myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/util/ValueExpressionComparator.java Thu Apr 10 07:17:54 2008
@@ -0,0 +1,125 @@
+package org.apache.myfaces.tobago.util;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.faces.context.FacesContext;
+import javax.el.ValueExpression;
+import java.util.Comparator;
+import java.util.Map;
+
+public class ValueExpressionComparator extends ComparatorBase {
+
+ private static final Log LOG = LogFactory.getLog(ValueExpressionComparator.class);
+
+ private FacesContext facesContext;
+
+ private String var;
+
+ private ValueExpression valueExpression;
+
+ public ValueExpressionComparator(FacesContext facesContext, String var, ValueExpression valueExpression) {
+ this.facesContext = facesContext;
+ this.var = var;
+ this.valueExpression = valueExpression;
+ }
+
+ public ValueExpressionComparator(FacesContext facesContext, String var, ValueExpression valueExpression, boolean reverse) {
+ super(reverse);
+ this.facesContext = facesContext;
+ this.var = var;
+ this.valueExpression = valueExpression;
+ }
+
+ public ValueExpressionComparator(FacesContext facesContext, String var,
+ ValueExpression valueExpression, Comparator comparator) {
+ super(comparator);
+ this.facesContext = facesContext;
+ this.var = var;
+ this.valueExpression = valueExpression;
+ }
+
+ public ValueExpressionComparator(FacesContext facesContext, String var,
+ ValueExpression valueExpression, boolean reverse, Comparator comparator) {
+ super(reverse, comparator);
+ this.facesContext = facesContext;
+ this.var = var;
+ this.valueExpression = valueExpression;
+ }
+
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ final ValueExpressionComparator that = (ValueExpressionComparator) o;
+
+ if (!super.equals(o)) {
+ return false;
+ }
+ if (facesContext != null ? !facesContext.equals(that.facesContext) : that.facesContext != null) {
+ return false;
+ }
+ if (valueExpression != null ? !valueExpression.equals(that.valueExpression) : that.valueExpression != null) {
+ return false;
+ }
+ if (var != null ? !var.equals(that.var) : that.var != null) {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode() {
+ int result;
+ result = (facesContext != null ? facesContext.hashCode() : 0);
+ result = 29 * result + (var != null ? var.hashCode() : 0);
+ result = 29 * result + (valueExpression != null ? valueExpression.hashCode() : 0);
+ result = 29 * result + super.hashCode();
+ return result;
+ }
+
+ // implementation of java.util.Comparator interface
+
+ /**
+ * @param param1 <description>
+ * @param param2 <description>
+ * @return <description>
+ */
+ public int compare(Object param1, Object param2) {
+ Object obj1;
+ Object obj2;
+ try {
+ final Map requestMap = facesContext.getExternalContext().getRequestMap();
+ requestMap.put(var, param1);
+ obj1 = valueExpression.getValue(facesContext.getELContext());
+ requestMap.put(var, param2);
+ obj2 = valueExpression.getValue(facesContext.getELContext());
+
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ return 0;
+ }
+ return super.internalCompare(obj1, obj2);
+ }
+}
Propchange: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/util/ValueExpressionComparator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/util/ValueExpressionComparator.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL