2010-08-26 26 views
0

任何人都有任何想法为什么错误消息在Flex SDK 3.5中重复(但不是在3.4),并有一个很好的方法,使其停止重复?查看截图:Flex 3.5验证器错误消息重复

alt text

alt text

你也可以看到不同的应用程序在这里:

http://www.flexdevelopers.com/examples/validator/3.4/Tester.html

http://www.flexdevelopers.com/examples/validator/3.5/Tester.html

[查看源在两个应用程序启用]

为了做到这一点,请将textInput字段留空并保存多次。然后将鼠标悬停在textInput上。

我可以想到几个解决方案,但他们似乎很hacky。

感谢,

Jeremy Mitchell

+0

好吧,看起来,一个unresol此问题存在ved错误:https://bugs.adobe.com/jira/browse/SDK-22911 – 2010-08-26 15:10:54

+0

查看我的应用程序的源代码后,您可能想知道为什么我每次点击时创建一个新的验证器保存按钮。那么,我这样做是因为这个错误:( - https://bugs.adobe.com/jira/browse/SDK-25731 – 2010-08-26 15:13:45

+0

你应该看看尽快迁移到Flex 4,Jeremy。 – Francisc 2010-08-26 21:15:55

回答

2

这里是一个黑客在3.5解决此问题。

查看这个文件的来源:http://www.flexdevelopers.com/examples/validator/3.5/Tester.html

更改saveMessage()方法来读取这样的:

public function saveMessage(event:Event):void 
     { 
      setupValidators(); 

      var failedValidations:Array = new Array(); 
      failedValidations = Validator.validateAll(_formValidators); 

      if (failedValidations.length == 0) 
      { 
       Alert.show("save it"); 
      } 
      else 
      { 
       for each (var validationResultEvent:ValidationResultEvent in failedValidations) 
       { 
        hackForSDK35Bug22911ToRemoveRepeatingErrorMessages(validationResultEvent); 
       } 
      } 
     } 

再加入此方法:

private function hackForSDK35Bug22911ToRemoveRepeatingErrorMessages(failedValidation:ValidationResultEvent):void 
     { 
      var uiComponent:UIComponent = failedValidation.target.source as UIComponent; 
      var errorString:String = uiComponent.errorString as String; 
      uiComponent.errorString = errorString.split("\n")[0]; 
     } 

应删除重复错误信息,只留下一个...