23 Replies Latest reply on Apr 3, 2008 2:39 PM by Ansury

    Another Flex 2.0.1 bug

    dimival Level 1
      I honestly don't understand what's going on, since i updated to Flex 2.0.1 i found bug after bug.

      This time to my surprise i found that the errorString property is causing a buggy behavior, if i set an empty String to this property in order to clean a validation error for a TextInput control then its layout changes, it gets a weird black color on its border.

      Try this one out

      <mx:TextInput id="buggy"/>
      <mx:Button click = "buggy.errorString = ''"/>

      So tell me, why if this WORKED in FLEX 2.0, why did Adobe had to change it ? How is it supposed to work now?

        • 1. Another Flex 2.0.1 BUG
          dimival Level 1
          Ok more on this one, i think i found a workaround, before setting an empty string to the errorString property validate if it is already empty, like this:

          if (textInput.errorString != '"") {
          textInput.errorString = "";
          }

          When doing this then the previous bug doesn't happen, so the BUG ONLY HAPPENS when you try to set an empty string to the errorString property when it is already empty.

          Any idea why this happens? it shouldn't matter if i set to empty if it already empty, at least it didn't matter in Flex 2.0
          • 2. Re: Another Flex 2.0.1 BUG
            peterent Level 2
            It probably ought not to go black, but set the errorString = null; and it should be OK.
            • 3. Re: Another Flex 2.0.1 BUG
              peterent Level 2
              It probably ought not to go black, but set the errorString = null; and it should be OK.
              • 4. Re: Another Flex 2.0.1 BUG
                dimival Level 1
                Umm nope, i tried setting it to null and still fails, it changes the TextInput layout.

                So far, the work around i found is to check if errorString is already an empty string like this:

                if (textInput.errorString != '"") {
                textInput.errorString = "";
                }

                When doing this validation then i works fine but, like i said previously, if you set an empty string to the errorString property and it was already empty, then it changes the textInput's layout.
                • 5. Re: Another Flex 2.0.1 BUG
                  peterent Level 2
                  Do you have Flex 2.0.1? It should be fixed in that version.
                  • 6. Re: Another Flex 2.0.1 BUG
                    dimival Level 1
                    quote:

                    Originally posted by: peterent
                    Do you have Flex 2.0.1? It should be fixed in that version.


                    Guess you didn't read the post, in FLEX 2.0 IT WORKED, when i updated to 2.0.1 it FAILED.

                    This is a Flex 2.0.1 BUG, would you be so kind as to try the example on the first post of this topic?

                    • 7. Re: Another Flex 2.0.1 BUG
                      peterent Level 2
                      Sorry, I was in a hurry. I tried this in Flex 2.0.1 and works for me.
                      • 8. Re: Another Flex 2.0.1 BUG
                        chris.huston.t10 Level 3
                        I'm using Flex 2.0.155577 and I get the same black border around TextInput boxes as Dimival reported if the errorString is assigned to null or '' and the errorString was not previously set to some value. Dimival's workaround works, but it seems like a bug.

                        Vygo
                        • 9. Re: Another Flex 2.0.1 BUG
                          dimival Level 1
                          quote:

                          Originally posted by: peterent
                          Sorry, I was in a hurry. I tried this in Flex 2.0.1 and works for me.


                          What are you trying to do? set it to empty when it is already empty? Try the snippet i put in my first post and as soon as the application load press the button and watch the TextInput's layout, it changes, it gets a black border on it.

                          I do have Flex 2.0.1, and it causes this bug, on Flex 2.0 it didn't. If you want i can send you my sample code for you to test it.
                          • 10. Re: Another Flex 2.0.1 BUG
                            vrubba Level 1
                            Umm, I tried this as well, and i get the same resulting behaviour:

                            <?xml version="1.0" encoding="utf-8"?>
                            <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
                            <mx:TextInput id="bug" x="304" y="162"/>
                            <mx:TextInput id="bu1" x="303" y="195"/>
                            <mx:Button click="bug.errorString=''" x="255" y="161"/>
                            </mx:Application>
                            • 11. Re: Another Flex 2.0.1 bug
                              michael_ramirez44 Level 1
                              The problem is in the UIComponent.as file in mx.core. In Flex 2.01 they factored out the border color for error string logic into a separate method setBorderColorForErrorString():void. Here is the method in Flex 2.01

                              private function setBorderColorForErrorString():void
                              {
                              if (!_errorString || _errorString.length == 0)
                              {
                              setStyle("borderColor", origBorderColor);
                              saveBorderColor = true;
                              }
                              else
                              {
                              // Remember the original border color
                              if (saveBorderColor)
                              {
                              saveBorderColor = false;
                              origBorderColor = getStyle("borderColor");
                              }

                              setStyle("borderColor", getStyle("errorColor"));
                              }

                              styleChanged("themeColor");

                              var focusManager:IFocusManager = focusManager;
                              var focusObj:DisplayObject = focusManager ?
                              DisplayObject(focusManager.getFocus()) :
                              null;
                              if (focusManager && focusManager.showFocusIndicator &&
                              focusObj == this)
                              {
                              drawFocus(true);
                              }

                              }

                              Here is the orignal code from Flex 2.0

                              public function set errorString(value:String):void
                              {
                              ToolTipManager.registerErrorString(this, value);

                              _errorString = value;

                              var p:String;

                              if (!value || value.length == 0)
                              {
                              saveBorderValues = true;
                              for (p in origBorderValues)
                              {
                              setStyle(p, origBorderValues[p]);
                              }
                              }
                              else
                              {
                              // Remember the original colors, so we can restore them later.
                              if (!origBorderValues)
                              origBorderValues = {};

                              if (saveBorderValues)
                              {
                              saveBorderValues = false;
                              for (p in origBorderStyles)
                              {
                              origBorderValues[p] = getStyle(p);
                              }
                              }

                              for (p in origBorderStyles)
                              {
                              setStyle(p, origBorderStyles[p]);
                              }
                              }

                              styleChanged("themeColor");

                              var focusManager:IFocusManager = focusManager;
                              var focusObj:DisplayObject = focusManager ?
                              DisplayObject(focusManager.getFocus()) :
                              null;
                              if (focusManager && focusManager.showFocusIndicator &&
                              focusObj == this)
                              {
                              drawFocus(true);
                              }

                              dispatchEvent(new Event("errorStringChanged"));
                              }
                              • 12. Another Flex 2.0.1 bug
                                michael_ramirez44 Level 1
                                Workaround:

                                Set the errorString to some none blank value first. This will cause the Framework to actually save the original border color. The bug is in the logic of the setBorderColorForErrorString method. If you set the errorString value to blank then the orginal border color of black is saved and no matter what you do after that you will keep on getting a black border.
                                • 13. Another Flex 2.0.1 bug
                                  michael_ramirez44 Level 1
                                  Possible Fix:

                                  Line 4475: should be

                                  setStyle("borderColor", getStyle("borderColor"));

                                  instead of

                                  setStyle("borderColor", origBorderColor);

                                  and remove all the saveBorderColor logic from the method.
                                  • 14. Re: Another Flex 2.0.1 bug
                                    dimival Level 1
                                    Thanks for the explanation, so they did messed it up in Flex 2.0.1.

                                    I posted some posts ago a workaround for this too, to validate if it is empty before setting empty. Works pretty good, any idea where to report this bug?
                                    • 15. Re: Another Flex 2.0.1 bug
                                      michael_ramirez44 Level 1
                                      Here is a better fix :) My last one would not working because it would cause the background color to stay "red" after the first error.

                                      private function setBorderColorForErrorString():void
                                      {

                                      // Remember the original border color
                                      if (saveBorderColor)
                                      {
                                      saveBorderColor = false;
                                      origBorderColor = getStyle("borderColor");
                                      }

                                      if (!_errorString || _errorString.length == 0)
                                      {
                                      setStyle("borderColor", origBorderColor);
                                      saveBorderColor = true;
                                      }
                                      else
                                      {
                                      setStyle("borderColor", getStyle("errorColor"));
                                      }

                                      styleChanged("themeColor");

                                      var focusManager:IFocusManager = focusManager;
                                      var focusObj:DisplayObject = focusManager ?
                                      DisplayObject(focusManager.getFocus()) :
                                      null;
                                      if (focusManager && focusManager.showFocusIndicator &&
                                      focusObj == this)
                                      {
                                      drawFocus(true);
                                      }

                                      }
                                      • 16. Re: Another Flex 2.0.1 bug
                                        dimival Level 1
                                        Ok, there are like 2 workarounds to this bug, one posted by me and the one posted by michael. They are both posted in this topic so please anyone who has the same problem, check this topic for the workarounds.

                                        Really really hope Adobe corrects this one someday
                                        • 17. Re: Another Flex 2.0.1 bug
                                          Dr Khaled
                                          hi,

                                          dimival, your work around would not work if an error message occurs and you want to remove that error message after the user correct the input..
                                          • 18. Another Flex 2.0.1 bug
                                            BillHeit2
                                            I ran into the same bug and also found an additional issue.

                                            When I set the error string on a TextInput control used as a itemEditor, it screws up the current focus. Focus is removed from the DataGrid entirely.

                                            Ok, I decide to fix this bug today.

                                            First, copy the UIComponent from the Flex SDK source files to your project (must be in the same mx directory structure)

                                            Second, change the setBorderColorForErrorString method as follows:

                                            private function setBorderColorForErrorString():void
                                            {
                                            if (!_errorString || _errorString.length == 0)
                                            {
                                            // Begin Change - Fix black boarder issue
                                            //setStyle("borderColor", origBorderColor);
                                            if(!saveBorderColor){
                                            setStyle("borderColor", origBorderColor);
                                            }
                                            // End Change

                                            saveBorderColor = true;
                                            }

                                            ...
                                            • 19. Re: Another Flex 2.0.1 bug
                                              joan_lafferty Adobe Employee
                                              Yes, the black border issue with errorString as well as the problem that Bill reported regarding using errorString in an itemEditor will be fixed in our next release of Flex. They have already been fixed in our internal builds.

                                              Thanks for reporting these issues.
                                              Joan Lafferty
                                              Flex Framework QE
                                              • 20. Re: Another Flex 2.0.1 bug
                                                BillHeit2 Level 1
                                                Ok, I decided to fix this bug before the next release:

                                                First add the UIComponent class to your project:
                                                - Copy the UIComponent.as file from the SDK source files to a matching directory structure in your project (starting with "mx")
                                                Seond modify the setBorderColorForErrorString as follows:

                                                private function setBorderColorForErrorString():void
                                                {
                                                if (!_errorString || _errorString.length == 0)
                                                {
                                                // Pacific Bean: Begin Change - Fix black boarder issue
                                                //setStyle("borderColor", origBorderColor);
                                                if(!saveBorderColor){
                                                setStyle("borderColor", origBorderColor);
                                                }
                                                // Pacific Bean: End Change

                                                saveBorderColor = true;
                                                }
                                                ...
                                                • 21. Re: Another Flex 2.0.1 bug
                                                  BillHeit2 Level 1
                                                  Ok, I decided to fix this bug before the next release:

                                                  First add the UIComponent class to your project:
                                                  - Copy the UIComponent.as file from the SDK source files to a matching directory structure in your project (starting with "mx")
                                                  Seond modify the setBorderColorForErrorString as follows:

                                                  private function setBorderColorForErrorString():void
                                                  {
                                                  if (!_errorString || _errorString.length == 0)
                                                  {
                                                  // Pacific Bean: Begin Change - Fix black boarder issue
                                                  //setStyle("borderColor", origBorderColor);
                                                  if(!saveBorderColor){
                                                  setStyle("borderColor", origBorderColor);
                                                  }
                                                  // Pacific Bean: End Change

                                                  saveBorderColor = true;
                                                  }
                                                  ...
                                                  • 22. Re: Another Flex 2.0.1 bug
                                                    Ansury Level 3
                                                    Sorry to resurrect a dead post but this bug is killing me, and these fixes aren't working for some reason - does anyone know if this is this fixed in Flex 3?
                                                    • 23. Re: Another Flex 2.0.1 bug
                                                      Ansury Level 3
                                                      *crickets*

                                                      ?

                                                      Guess not.