Firas A. a écrit :
Hello,
I'm using a custom validator (implements Validator) and the
ValidationDelegate.
I've verified that the custom validator I'm using is working correctly - the
getHasErrors() of the delegate returns true. But ValidationDelegate doesn't
decorate anything (no asterics, no red labels).
I then used my own extended ValidationDelegate class and overriden the
writeSuffix method:
public void writeSuffix(IMarkupWriter writer, IRequestCycle arg1,
IFormComponent formComponent,
IValidator validator) {
if (isInError(formComponent)) {
// more code here
}
and noticed that the isInError() test allways returns false despite the fact
that my validator is throwing ValidatorException on validation error.
Page template:
<label jwcid="@FieldLabel" field="component:QuantityField"></label>
<input jwcid="QuantityField" type="text" size="2" maxlength="2" />
Page spec:
<component id="QuantityField" type="TextField">
<binding name="displayName" value="message:Quantity" />
...
</component>
Thanks for your time!
</Firas>
I had the same symptoms a while ago, I don't know if it's the same
problem you're facing, but this might be helpful:
When you instantiate your delegate and pass it to the form component,
you have to make sure it is the same instance during the whole cycle. If
you create a new instance of the delegate each time you render the page,
then it won't keep track of the errors discovered during the previous
rewind: your page won't validate, but decorations are not rendered
(isInError() returns false)
What I do is create a new instance of the delegate only if there isn't
one yet, and make it available to the form component through a page
property.
HTH
Ch.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]