it gets a +1 for me. Fail early and fast.
johan
On 4/6/06, Igor Vaynberg <
[EMAIL PROTECTED]> wrote:
spring has boolean supports(Class class) in its validator interface
-IgorOn 4/6/06, Johan Compagner < [EMAIL PROTECTED]> wrote:I find ITypeValidator a wrong name. That looks much the same with (the impl then) TypeValidators
And we don't have TypeValidators anymore (just like we don't have requiredvalidators anymore)
I am not sure but as far as i know all validatiors should work on a type..
What else should they do with it?
johanOn 4/6/06, Martijn Dashorst <[EMAIL PROTECTED] > wrote:Though in this case this might seem like a good fix, but I don't recommend it.
Validators are not specifically tied to one type. A required validator doesn't even check the type of a field. Therefore the getType() method doesn't belong in IValidator.
We could introduce another interface: ITypeValidator, introduce in it the getType() method, and get the check from there.
MartijnOn 4/6/06, Johan Compagner <[EMAIL PROTECTED]> wrote:Somehow a StringValidator was added to a Date typed FormComponent (TextField)
This was maybe valid in the pre beta2? or futher release. But now Validators are build for types
the conversion is done before the validators are running. So validators expect the right type.
If that is not the case yes we got a ClassCastException.
I do think that we throw this to late. We already know it much much earlier.
What we could do is this:
public interface IValidator extends Serializable
{
void validate(final FormComponent component);
Class getType(); <<< ADDDED
}
then in FormComponent:
public final FormComponent add(final IValidator validator)
{
if (type != null && validator.getType() != null && type.isAssignableFrom(validator.getType()) ) <<<< ADDED
throw new WicketRuntimeException("Validatior not build on the right type"); <<< ADDED
// keep this in until we remove TypeValidator
if (validator instanceof TypeValidator)
{
setType(((TypeValidator)validator).getType());
}
else
{
validators_add(validator);
}
return this;
}
Then we catch it much earlier with a normal error.
johanOn 4/6/06, SourceForge.net <[EMAIL PROTECTED]> wrote:Bugs item #1465702, was opened at 2006-04-06 14:58
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=684975&aid=1465702&group_id=119783
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: core
Group: 1.2
Status: Open
Resolution: None
Priority: 7
Submitted By: Martijn Dashorst (dashorst)
Assigned to: Nobody/Anonymous (nobody)
Summary: Regression: typed validator throws ClassCastException
Initial Comment:
A field created using new TextField("foo", Date.class)
throws a ClassCastException when submitted. I committed
a testcase for this issue in the unittests:
Caused by: wicket.WicketRuntimeException: Exception
java.lang.ClassCastException: java.util.Date occurred
during validation
nl.topicus.iridium.web.gui.leerling.EditLeerlingPersonaliaPage$5
on component 7:personaliaForm:geboortedatum
at
wicket.markup.html.form.FormComponent.checkValidators(FormComponent.java:640)
at wicket.markup.html.form.Form$15.validate(Form.java:885)
at
wicket.markup.html.form.Form$ValidationVisitor.formComponent (Form.java:143)
at wicket.markup.html.form.Form$4.component(Form.java:409)
at
wicket.MarkupContainer.visitChildren(MarkupContainer.java:692)
at
wicket.markup.html.form.Form.visitFormComponents (Form.java:405)
at
wicket.markup.html.form.Form.validateValidators(Form.java:881)
at wicket.markup.html.form.Form.validate(Form.java:843)
at
nl.topicus.iridium.web.components.form.VersionedForm.validate (VersionedForm.java:88)
at wicket.markup.html.form.Form.process(Form.java:755)
at
wicket.markup.html.form.Form.onFormSubmitted(Form.java:281)
... 30 more
Caused by: java.lang.ClassCastException : java.util.Date
at
wicket.markup.html.form.validation.StringValidator.validate(StringValidator.java:107)
at
wicket.markup.html.form.FormComponent.checkValidators(FormComponent.java:631)
... 40 more
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=684975&aid=1465702&group_id=119783
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop
--
Wicket 1.2 is coming! Write Ajax applications without touching _javascript_!
-- http://wicketframework.org
