You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2010/02/25 19:30:46 UTC
svn commit: r916387 -
/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInput.java
Author: gbrown
Date: Thu Feb 25 18:30:46 2010
New Revision: 916387
URL: http://svn.apache.org/viewvc?rev=916387&view=rev
Log:
Support two-way bind mapping in TextInput.BindMapping.
Modified:
pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInput.java
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInput.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInput.java?rev=916387&r1=916386&r2=916387&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInput.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInput.java Thu Feb 25 18:30:46 2010
@@ -64,7 +64,14 @@
*/
public interface BindMapping {
/**
- * Returns the value that will stored in the bind context.
+ * Converts a value from the bind context to a text representation.
+ *
+ * @param value
+ */
+ public String toString(Object value);
+
+ /**
+ * Converts a text string to a value to be stored in the bind context.
*
* @param text
*/
@@ -733,8 +740,12 @@
if (textKey != null
&& JSONSerializer.containsKey(context, textKey)) {
Object value = JSONSerializer.get(context, textKey);
- if (value != null) {
- value = value.toString();
+
+ if (bindMapping == null
+ && value != null) {
+ value = value.toString();
+ } else {
+ value = bindMapping.toString(value);
}
setText((String)value);