dabo Commit
Revision 4708
Date: 2008-11-23 10:29:51 -0800 (Sun, 23 Nov 2008)
Author: Ed
Trac: http://svn.dabodev.com/trac/dabo/changeset/4708

Changed:
U   trunk/dabo/ui/dDataControlMixinBase.py
U   trunk/dabo/ui/uiwx/dForm.py
U   trunk/dabo/ui/uiwx/dFormMixin.py
U   trunk/dabo/ui/uiwx/dTextBoxMixin.py

Log:
Added code that handles the edge case where a textbox that is the very first 
control on a form will have its _oldVal attribute set to an empty string, even 
though the original value may be something else. If the user then blanks that 
value, the framework thought that it hadn't changed, and didn't validate it.

Fixed the navigation methods so that if field validation fails, the navigation 
does not happen.



Diff:
Modified: trunk/dabo/ui/dDataControlMixinBase.py
===================================================================
--- trunk/dabo/ui/dDataControlMixinBase.py      2008-11-23 18:23:50 UTC (rev 
4707)
+++ trunk/dabo/ui/dDataControlMixinBase.py      2008-11-23 18:29:51 UTC (rev 
4708)
@@ -165,10 +165,16 @@
                """ Save any changes to the underlying source field. First 
check to make sure
                that any changes are validated.
                """
-               if (self._oldVal != self.Value) and hasattr(self.Form, 
"validateField"):
-                       if not self.Form.validateField(self):
-                               # Validation failed; the form will handle 
notifying the user
-                               return False
+               # We need to test empty oldvals because of the way that 
textboxes work; they
+               # can set _oldVal to "" before the actual Value is set.
+               if (not self._oldVal) or (self._oldVal != self.Value):
+                       try:
+                               if not self.Form.validateField(self):
+                                       # Validation failed; the form will 
handle notifying the user
+                                       return False
+                       except AttributeError:
+                               # Form doesn't have a validateField() method
+                               pass
                curVal = self.Value
                ret = None
                isChanged = False

Modified: trunk/dabo/ui/uiwx/dForm.py
===================================================================
--- trunk/dabo/ui/uiwx/dForm.py 2008-11-23 18:23:50 UTC (rev 4707)
+++ trunk/dabo/ui/uiwx/dForm.py 2008-11-23 18:29:51 UTC (rev 4708)
@@ -254,7 +254,9 @@
                        biz = self.getBizobj(dataSource)
                oldRowNum = biz.RowNumber
 
-               self.activeControlValid()
+               if not self.activeControlValid():
+                       # Field validation failed
+                       return False
                err = self.beforePointerMove()
                if err:
                        self.notifyUser(err)

Modified: trunk/dabo/ui/uiwx/dFormMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dFormMixin.py    2008-11-23 18:23:50 UTC (rev 4707)
+++ trunk/dabo/ui/uiwx/dFormMixin.py    2008-11-23 18:29:51 UTC (rev 4708)
@@ -269,8 +269,9 @@
                """
                ac = self.ActiveControl
                if ac is not None and isinstance(ac, 
dabo.ui.dDataControlMixinBase.dDataControlMixinBase):
-                       if not hasattr(ac, "_oldVal") or ac._oldVal != ac.Value:
-                               ac.flushValue()
+                       if not hasattr(ac, "_oldVal") or (not ac._oldVal) or 
(ac._oldVal != ac.Value):
+                               return ac.flushValue()
+               return True
                                
        
        def createBizobjs(self):

Modified: trunk/dabo/ui/uiwx/dTextBoxMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dTextBoxMixin.py 2008-11-23 18:23:50 UTC (rev 4707)
+++ trunk/dabo/ui/uiwx/dTextBoxMixin.py 2008-11-23 18:29:51 UTC (rev 4708)
@@ -50,8 +50,9 @@
                        return
                self._inFlush = True
                self._updateStringDisplay()
-               super(dTextBoxMixinBase, self).flushValue()
+               ret = super(dTextBoxMixinBase, self).flushValue()
                self._inFlush = False
+               return ret
        
 
        def _updateStringDisplay(self):




_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/[EMAIL PROTECTED]

Reply via email to