On 1 Jul 2004, at 13:52, Bruno Dumon wrote:
On Thu, 2004-07-01 at 14:29, Jeremy Quinn wrote:On 1 Jul 2004, at 12:20, Bruno Dumon wrote:
On Thu, 2004-07-01 at 13:06, Jeremy Quinn wrote:On 1 Jul 2004, at 11:45, Bruno Dumon wrote:
On Thu, 2004-07-01 at 12:09, Jeremy Quinn wrote:On 30 Jun 2004, at 17:56, Bruno Dumon wrote:
Thanks for your response Bruno.
On Wed, 2004-06-30 at 13:01, Jeremy Quinn wrote:Hi All
I need to validate (within the CForms framework) that a set of checkboxes have all been checked.
I have tried adding <fd:validation/> but it does not appear to have an effect :
Checked the source: it's indeed not supported. Probably for no particular reason.
Possible options are:
* adding support for it.
sounds good
Should be no more then adding the following line to the class BooleanFieldDefinitionBuilder: setValidators(widgetElement, definition); I don't have time to test that, but since you already have an example worked out you could give it a try.
OK, I added setValidators(widgetElement, definition); at line 34, in
the buildWidgetDefinition method.
I then test with the following booleanfield:
<fd:booleanfield id="mod-copyright"> <fd:label> <i18n:text i18n:catalogue="local">moderate.mod-copyright.label</i18n:text>: </fd:label> <fd:hint> <i18n:text i18n:catalogue="local">moderate.mod-copyright.hint</i18n:text> </fd:hint> <fd:help> <i18n:text i18n:catalogue="local">moderate.mod-copyright.help</i18n:text> </fd:help> <fd:validation> <fd:assert test="mod-copyright = True()"> <fd:failmessage> <i18n:text i18n:catalogue="local">moderate.mod-copyright.fail</i18n:text> </fd:failmessage> </fd:assert> </fd:validation> </fd:booleanfield>
When I submit this form with the checkbox unchecked, I get no validation error displayed.
Comparing Field to BooleanField, it looks like BooleanField needs to
implement ValidationErrorAware, so I will try that next.
I also see that the class BooleanField defines the validate method to
do
nothing. Just throw that method out (the one from the parent class
will
take over).
Yes.
What I cannot work out now is how to do the actual validation.
Nothing special needs to be done, it is handled by the validate method
of the superclass.
Looking at Field.java, it uses the Datatype to do this: validationError = getDatatype().validate(value, new ExpressionContextImpl(this));
But BooleanField has no datatype .....
validators belonging to the datatype is old stuff (will be removed), so
you can ignore that.
OK, I added the following to BooleanField :
implements ValidationErrorAware
protected ValidationError validationError;
public boolean validate() { return super.validate(); }
public ValidationError getValidationError() { return validationError; }
public void setValidationError(ValidationError error) { this.validationError = error; }
I now get a ClassCastException when I submit. So I am stumped again.
Unfortunately, and I know how rude this sounds, but I have been asked to get on with "other work", so unfortunately I will have to get back to this later. My apologies, and thanks for the help so far.
Absolutely no problem. However, I think I fixed the source of the problem with a new xreporter-expression jar I just committed.
OK, the ClassCastException has gone.
However, the updated BooleanField still outputs no <fi:validation-message/> even when given (what I believe to be) an impossible to pass validation assert statement. <fd:assert test="False()"> . . . </fd:assert>
Can you think of anything else that may be missing?
Thanks
regards Jeremy
--------------------------------------------------------
If email from this address is not signed
IT IS NOT FROM MEAlways check the label, folks !!!!! --------------------------------------------------------
smime.p7s
Description: S/MIME cryptographic signature
