代码之家  ›  专栏  ›  技术社区  ›  Brad

Axapta验证覆盖始终执行两次

  •  0
  • Brad  · 技术社区  · 16 年前

    在大多数情况下,每次父字段更改时,我重写的验证方法都会执行两次。一切都正常,但信息日志每次显示两条消息。

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

    谢谢

    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;
    }
    
    1 回复  |  直到 16 年前
        1
  •  0
  •   pointer    16 年前

    你对这个问题的描述不是很清楚。可以重写窗体控件上的valite方法、窗体数据源上的validate方法和表上的validateField方法。这是我对3.0版的了解。 “父字段”是什么意思?我想是桌子区吧?

    如果我将信息消息放在这些方法中的每一个中,当我修改一个值时它们只执行一次。这就是3.0中的情况。我不知道你用的是哪个版本。

    也许您可以更精确地测试哪个验证方法?