skywalker (5) [Avatar] Offline
#1
On page 212, it says that before any validators are executed, convertInput is called first. [statement 1] It also says that the children of compound components are processed before the top component.

does that mean that it's done in this way?

convert input child 1
convert input child 2
convert input parent
validate converted input child 1
validate converted input child 2
validate converted input parent
continue form processing

or this way?

convert input child 1
validate converted input child 1
continue processing child 1
convert input child 2
validate converted input child 2
continue processing child 2
do the same for parent

it also says that convert input is only called when a form component is "valid" [statement 2], how's that? isn't the normal form processing cycle is to convert input first then validate the converted input? doesn't statement 2 contradict with statement 1?
Eelco12 (100) [Avatar] Offline
#2
Re: Section 8.3 - DateTimeField
The latter. Components have their input converted and then their validators fired one by one.

> it also says that convert input is only called when a form component is
> "valid" [statement 2], how's that? isn't the normal form processing cycle
> is to convert input first then validate the converted input? doesn't statement 2
> contradict with statement 1?

What I meant to explain there is that convertInput is only called *on the parent* when the nested components have their input converted and are validated. This is because nested components will be processed first, and the parent will check whether that went ok before calling convertInput. Look at this code of ValidationVisitor:

if (formComponent.isVisibleInHierarchy() && formComponent.isValid() &&
formComponent.isEnabled() && formComponent.isEnableAllowed())
{
validate(formComponent);
}

that calls isValid, which is defined as:

public final boolean isValid()
{
class IsValidVisitor implements IVisitor
{
boolean valid = true;

public Object formComponent(IFormVisitorParticipant formComponent)
{
final FormComponent fc = (FormComponent)formComponent;
if (fc.hasErrorMessage())
{
valid = false;
return Component.IVisitor.STOP_TRAVERSAL;
}
return Component.IVisitor.CONTINUE_TRAVERSAL;
}
}
IsValidVisitor tmp = new IsValidVisitor();
visitFormComponentsPostOrder(this, tmp);
return tmp.valid;
}

which is you can read checks child components for any errors it has registered. If any child component has an error, no further processing will be attempted on the parent component.

Hope that clears it up smilie

Eelco
skywalker (5) [Avatar] Offline
#3
Re: Section 8.3 - DateTimeField
yes, i get it now. thanks eelco! smilie