0

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

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

谢谢

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;
}
4

1 回答 1

0

您对问题的描述不是很清楚。可以覆盖表单控件上的 valite 方法、表单数据源上的 validate 方法和表上的 validatefield 方法。这是我对3.0版的了解。你是什​​么意思“父字段”?我假设表格字段?

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

也许您可以更准确地了解您正在测试的验证方法?

于 2009-11-07T19:17:11.100 回答