2009-11-06 65 views
0

在大多数情况下,每次更改父字段时,我重写的验证方法都会执行两次。一切仍然有效,但InfoLog每次显示双重信息。Axapta验证覆盖始终执行两次

有什么办法可以防止这种情况发生?

感谢

public boolean validate() 
{ 
    boolean ret; 
    int exlowValue; 
    int lowValue; 
    int highValue; 
    int exhighValue; 
    str errorMessage; 
    ; 

    ret = super(); 

    //Make sure a numeric value was entered 
    if (ABC_RegExValidator::validateMe("integer", int2str (ABC_Checks_checkExtremeLow.value()))) 
    { 
     //get the form values 
     exlowValue = ABC_Checks_checkExtremeLow.value(); 
     lowValue = str2int(ABC_Checks_checkLow.valueStr()); 
     highValue = str2int(ABC_Checks_checkHigh.valueStr()); 
     exhighValue = str2int(ABC_Checks_checkExtremeHigh.valueStr()); 

     //Extreme Low must be 0 or less than all others 
     if (exlowValue != 0) 
     { 
      //A non-zero value was entered; it must be less than all other fields 
      if ((exlowValue >= lowValue && lowValue > 0) || (exlowValue >= highValue && highValue > 0) || (exlowValue >= exhighValue && exhighValue > 0)) 
      { 
       //Return an error 
       ret = checkfailed(strFmt("@ABC197", int2str(exlowValue))); 
      } 
      else 
      { 
       //Not greater than any other value 
       //Success! 
       ret = true; 
      } //Greater than all others? 
     } 
     else 
     { 
      //No errors 
      ret = true; 
     } // 0? 
    } 
    else 
    { 
     //Regular expression failed 
     //Return an error 
     ret = checkfailed("@ABC192"); 
    } //Regular expression 


    return ret; 
} 

回答

0

你的问题的描述是不是真的清楚。可以重写表单控件上的valite方法,表单数据源上的validate方法和表上的validatefield方法。这是我对3.0版的了解。 而你是如何指“父领域”?我认为表格字段?

如果我把信息消息在每一种方法,他们只当我修改的值执行一次。 3.0就是这种情况。我不知道你使用的是哪个版本。

也许你可以更精确地了解你正在测试其验证方法?

+0

使用Dynamics AX 2009中,我重写的表单字段(stringedit,intedit,组合框等)本身,而不是数据源或表验证事件。我在验证例程的开头放置了一个info()语句,如果该字段通过验证,它将显示一次,但如果验证失败,则总是显示两次。该代码是相当简单: 公共布尔验证() { 布尔RET; ; ret = super(); 如果(..statement ..) { RET = checkfailed(strFmt( “@ SPC197”);} 其他 { RET =真; } 返回RET;} 在 – Brad 2009-11-09 15:39:29

+0

您的评论你提到在方法开始时你有一个info()语句,但是,info()语句不是你的代码示例的一部分,这会让我困惑,如果你将info()语句和checkFailed那么这就是问题出在哪里,checkFailed()语句也使用Infolog系统来显示警告消除检查失败并简单地使用ret = false如果这仍然不是答案,那么你可以发布完整的代码示例吗? – pointer 2009-11-09 21:28:37

+0

该info()仅用于测试,因此未包含在我发布的代码中。在验证期间不使用info(),只检查失败。代码现在可用。往上看。 – Brad 2009-11-10 13:55:37