Also, I think it should be easier to find out what errors were
registered by/ for what components. This would make it easier than it is
now to do things like adding a tag attribute modifier that changes the
class of a textfield when an error is recorded for that field.
Regards,
Eelco
Eelco Hillenius wrote:
All,
Currently, the form validation algoritm is (as described in the
Javadoc of Form.validate()):
/**
* Validates all children of this form, returning the first error
that occurs return
* Validation error or IValidator.NO_ERROR if every
HtmlFormComponent in this
* container validates
* @return Validation error or IValidator.NO_ERROR if no error
occurred
*/
I think this is not a good idea, as the common case (at least in *all*
the projects I have seen so far) is to check all fields on errors
instead of stopping validation on the first error. Take the CD app as
an example... the following validation does apply:
title: required and < 50 chars
performers: required and < 50 chars
label: < 50 chars
year: must a valid integer
If the user submits an empty form, I want errors displayed for both
title and performers (required)
And, for example, if the user fills in title with a string of over 50
chars, leaves performers empty, and enters a non-numeric value for
year, I want to display those three errors (probably together with an
indicator for each field, e.g. changing the class of the field in
order render it's background red).
So, I think the algoritm should be like:
for all fields:
- execute validations until either:
- all registered validations for that field are done without
errors, or
- a validation fails, in which case the error should be recorded
(somewhere), and no further validations should be executed for that
field.
- after all fields are processed, check if any errors were recorded,
and - if so - do something usefull with it (like calling
IValidationErrorHandler.validationError, though I also do not agree
with the current behaviour of allways calling this method; I think it
should be called on errors only).
To implement this, we'll probably need to introduce a field (like a
List or a Map) in Form to record the errors.
Do you agree with my comments? And if so, what do you think would be
the best way to implement this?
Regards,
Eelco
-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE
FREE OODBMS DOWNLOAD - A multidimensional database that combines
robust object and relational technologies, making it a perfect match
for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8
_______________________________________________
Wicket-develop mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/wicket-develop
-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE
FREE OODBMS DOWNLOAD - A multidimensional database that combines
robust object and relational technologies, making it a perfect match
for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8
_______________________________________________
Wicket-develop mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/wicket-develop