You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by gc...@apache.org on 2009/06/25 01:49:24 UTC
svn commit: r788213 - in
/myfaces/trinidad/branches/1.2.11.4-branch/trinidad-api/src/main:
java-templates/org/apache/myfaces/trinidad/component/UIXEditableValueTemplate.java
xrts/org/apache/myfaces/trinidad/resource/LoggerBundle.xrts
Author: gcrawford
Date: Wed Jun 24 23:49:24 2009
New Revision: 788213
URL: http://svn.apache.org/viewvc?rev=788213&view=rev
Log:
TRINIDAD-1489 get a valueChangeEvent for bigDecimal even though user didn't make a change
Modified:
myfaces/trinidad/branches/1.2.11.4-branch/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXEditableValueTemplate.java
myfaces/trinidad/branches/1.2.11.4-branch/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/LoggerBundle.xrts
Modified: myfaces/trinidad/branches/1.2.11.4-branch/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXEditableValueTemplate.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.11.4-branch/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXEditableValueTemplate.java?rev=788213&r1=788212&r2=788213&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.11.4-branch/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXEditableValueTemplate.java (original)
+++ myfaces/trinidad/branches/1.2.11.4-branch/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXEditableValueTemplate.java Wed Jun 24 23:49:24 2009
@@ -6,9 +6,9 @@
* 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
@@ -411,7 +411,7 @@
return newValue;
}
- /**
+ /**
* <p>Return <code>true</code> if the new value is different from the
* previous value.</p>
*
@@ -420,10 +420,37 @@
*/
protected boolean compareValues(Object previous, Object value)
{
+ // handle cases where previous value was empty
if (isEmpty(previous)) // bug 4268807
return !isEmpty(value);
- return !previous.equals(value);
+ boolean isNotEqual = !previous.equals(value);
+
+ // Handle objects whose comparable() implementation is inconsistent with equals().
+ // if not equal we will also check compareTo if the data implements Comparable.
+ // An example of why we need this is for a case where the data is bigdecimal,
+ // because bigdecimal remembers formatting information like scale. So 2.0 is not equal to 2.00
+ // in bigdecimal, but when you use compareTo 2.0 and 2.00 are equal.
+ // See Issue TRINIDAD-1489 for test case
+ if (isNotEqual && previous instanceof Comparable && value instanceof Comparable)
+ {
+ try
+ {
+ int compareTo = ((Comparable)previous).compareTo(value);
+ isNotEqual = (compareTo != 0);
+ }
+ catch (ClassCastException cce)
+ {
+ if (_LOG.isWarning())
+ {
+ // There's a type mismatch between previous and value, in theory this shouldn't happen
+ _LOG.warning("COMPARETO_TYPE_MISMATCH", new Object[]{previous, value});
+ _LOG.warning(cce);
+ }
+ }
+ }
+
+ return isNotEqual;
}
/**
Modified: myfaces/trinidad/branches/1.2.11.4-branch/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/LoggerBundle.xrts
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.11.4-branch/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/LoggerBundle.xrts?rev=788213&r1=788212&r2=788213&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.11.4-branch/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/LoggerBundle.xrts (original)
+++ myfaces/trinidad/branches/1.2.11.4-branch/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/LoggerBundle.xrts Wed Jun 24 23:49:24 2009
@@ -449,4 +449,8 @@
<!-- UNABLE_TO_SET_RENDER_PARAMETERS -->
<resource key="UNABLE_TO_SET_RENDER_PARAMETERS">Unable ro set portlet render parameters due to failed reflection</resource>
+
+<!-- COMPARETO_TYPE_MISMATCH -->
+<resource key="COMPARETO_TYPE_MISMATCH">The type for "{0}" prevents it from being compared to "{1}".</resource>
+
</resources>