Stephane Decleire пишет:
Hi,
In my application, i have got several forms with the same bunch of
fields and other different fields.
What i would like is to create a component with the bunch of fields
and include it in the forms.
But the validateForm event is only managed by the page where my form
is declared and i can not catch it in the component itself so i can
not record crossfield errors.
And i can neither record crossfield errors in the page because the
fields are declared in the component and not in the page ...
Any idea ?
Stephane
Hi, Stephane
Here is short description of possible solution:
Inject environmental FormSupport object into you component
@Environmental()
private FormSupport formSupport;
In the end step of render add listener to formSupport. By adding
listener in later render phase you ensure that fields get their values
are validated before cross field validation occurs
@CleanupRender
void cleanupRender() {
formSupport.store(new ValidateAction(this));
}
Create listener class
static class ValidateAction implements
ComponentAction<YouComponentClassname>, Serializable {
public void execute(YouComponentClassname component) {
//TODO: add validate action here.
// you may get ValidationTracker from environment (the same way as you
get FormSupport)
}
}
Best Regards,
Dmitry Shyshkin
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]