2010-08-26 56 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]; 
     } 

應刪除重複錯誤信息,只留下一個...