Reputation: 116
I'm developing in Ax 2012. I have stringEdit controls on a form which holds the same type of information and share an EDT. I do validation on the EDT in a class. I call the class from a check method on the form. I use the same method on the form for all the stringEdit controls that needs this validation. I kick of the check method on the form from the validate method of each control.
My question: how do I pass the control that has been modified (and needs validation) to the check method? My check method on the form looks like this:
public void checkNumber(FormStringControl _cntrl)
{
MyValidationClass valClass = new MyValidationClass();
;
if(!valClass.validateNumber(_cntrl.text()))
{
_cntrl.text("");
}
}
***the problem I have is passing the current control to the above method
The validate method on the control looks like this:
public boolean validate()
{
boolean ret;
//ret = super();
ret = element.checkNumber(this);
return ret;
}
The problem I have is passing the current control I am modifying to the checkNumber method. If I cannot pass “this” to the check method, what then should I be passing?
Upvotes: 0
Views: 1667
Reputation: 18051
It is fine to pass this
, but you should call also super()
:
public boolean validate()
{
return super() && element.checkNumber(this);
}
Or:
public boolean validate()
{
return super() && new MyValidationClass.validateNumber(this.text());
}
Consider using a static method instead (on the controlling table): MyTable::validateNumber(this.text())
Consider using the validateField on the table instead:
public boolean validateField(fieldIdToCheck)
{
boolean ret = super(fieldIdToCheck);
switch (fieldIdToCheck)
{
case fieldNum(Table,Field):
ret = MyValidationClass::validateNumber(table.Field) && ret;
break;
}
return ret;
}
Then you do not have to make changes in the forms and you can use auto groups.
Upvotes: 1