Re: Client side validation behaviors - already started?
First thing that I have to notice: ClientAndServerExactLengthValidatingBehavior is an awful class name. LengthValidation would be enough. The other thing: I wouldn't use clientside validation when it validates on submit only. It should validate non-empty fields on blur, and fields already marked as invalid on keyup. Without that there really isn't much of a point in using clientside validation at all. I'll try to look at your actual code, though some examples would help a lot! Jörn On Sun, Oct 5, 2008 at 7:33 AM, Jeremy Thomerson [EMAIL PROTECTED] wrote: Okay, I was able to commit what I had already started on. This is only a few hours work, so it is nowhere near complete. However, I have the basis for the framework, and a replica of all the StringValidator validation done. https://wicket-stuff.svn.sourceforge.net/svnroot/wicket-stuff/trunk/wicketstuff-client-and-server-validation/ Here are the basic features: - By simply replacing formcomponent.add(StringValidator.exactLength(4)) with add(new ClientAndServerExactLengthValidatingBehavior(form, 4)), it will do the client side validation and add the server side IValidator for you. - It is internationalized because it uses all of the same resource keys / messages that the standard Wicket validators use. - It can insert feedback messages onto the page in a feedback panel or other WebMarkupContainer by calling feedbackpanel.add(new ClientAndServerValidatingFeedbackBehavior(form)) - this will make it use the same appearance that the normal feedback panel would generate. I'm sure there is quite a bit of stuff that can be cleaned up, especially in the JS code. For instance, I'm using document.getElementById quite a bit, but I'm not sure if there are some browsers that may not support that. I need to look because I can't remember. Anyway, feedback is welcome! NOTE: I had started it within another project and was testing it there. I have not had time to test it again after I moved it to its own project. Since all I did was move it, add the license info and rename the packages, it should still work, but you know how that goes. -- Jeremy Thomerson http://www.wickettraining.com On Sat, Oct 4, 2008 at 9:39 AM, Jeremy Thomerson [EMAIL PROTECTED]wrote: Basically, where you would normally call: Formcomponent.add(IValidator), You could now add a behavior. In my behavior, on bind I add the server-side equivalent validator. Then in renderHead, I add some onLoad JS that adds the component to a JS array of components to be validated on form submit. Let me get a little more of the basic started, and then I would REALLY welcome the help! Maybe tomorrow night or Monday I can get a wicketstuff project started for it... The help will be great - my JS fu is rusty! Jeremy Thomerson http://www.wickettraining.com -- sent from a wireless device -Original Message- From: Jörn Zaefferer =F6rn_Zaefferer _ [EMAIL PROTECTED] Sent: Saturday, October 04, 2008 5:50 AM To: users@wicket.apache.org Subject: Re: Client side validation behaviors - already started? What approach for client-side validation are you looking for? I may be able to help with that. Jörn On Fri, Oct 3, 2008 at 5:50 AM, Jeremy Thomerson [EMAIL PROTECTED] wrote: I've been thinking of trying to create some behaviors that combine the standard server-side validation with client-side validation. I just wanted to check to see if anyone knew of something like this already started. I don't want to duplicate work already done. Thanks, -- Jeremy Thomerson http://www.wickettraining.com
Re: Client side validation behaviors - already started?
What approach for client-side validation are you looking for? I may be able to help with that. Jörn On Fri, Oct 3, 2008 at 5:50 AM, Jeremy Thomerson [EMAIL PROTECTED] wrote: I've been thinking of trying to create some behaviors that combine the standard server-side validation with client-side validation. I just wanted to check to see if anyone knew of something like this already started. I don't want to duplicate work already done. Thanks, -- Jeremy Thomerson http://www.wickettraining.com
RE: Client side validation behaviors - already started?
Basically, where you would normally call: Formcomponent.add(IValidator), You could now add a behavior. In my behavior, on bind I add the server-side equivalent validator. Then in renderHead, I add some onLoad JS that adds the component to a JS array of components to be validated on form submit. Let me get a little more of the basic started, and then I would REALLY welcome the help! Maybe tomorrow night or Monday I can get a wicketstuff project started for it... The help will be great - my JS fu is rusty! Jeremy Thomerson http://www.wickettraining.com -- sent from a wireless device -Original Message- From: Jörn Zaefferer =F6rn_Zaefferer _ [EMAIL PROTECTED] Sent: Saturday, October 04, 2008 5:50 AM To: users@wicket.apache.org Subject: Re: Client side validation behaviors - already started? What approach for client-side validation are you looking for? I may be able to help with that. Jörn On Fri, Oct 3, 2008 at 5:50 AM, Jeremy Thomerson [EMAIL PROTECTED] wrote: I've been thinking of trying to create some behaviors that combine the standard server-side validation with client-side validation. I just wanted to check to see if anyone knew of something like this already started. I don't want to duplicate work already done. Thanks, -- Jeremy Thomerson http://www.wickettraining.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Client side validation behaviors - already started?
Okay, this sounds like the validation plugin (I've written) could be useful: http://bassistance.de/jquery-plugins/jquery-plugin-validation/ You'd add a very small script to the head: $(function() { $(#formid).validate() }); And then create inline rules based on the validation behaviour. There are two options for those: Either classes and (custom attributes) or metadata (which requires an additional plugin). I think classes/attributes work really well and result in readable HTML, though depending on the rules in use, it won't validate. For example, to make an input required and an email address: input class=required email name=... / For an optional input with min and max length: input minlength=5 maxlength=15 / For an input with min/max value: input min=5 max=10 / Those are actually attributes defined by HTLM5 (http://www.whatwg.org/specs/web-apps/current-work/#the-min-and-max-attributes). I've tried to keep it close to specs where possible and already existing. The thing is: generating those classes/attributes with Wicket is really easy and already works fine in a lot of projects. Let me know if invalid HTLM isn't acceptable, and I'll detail the alternatives. Jörn On Sat, Oct 4, 2008 at 4:39 PM, Jeremy Thomerson [EMAIL PROTECTED] wrote: Basically, where you would normally call: Formcomponent.add(IValidator), You could now add a behavior. In my behavior, on bind I add the server-side equivalent validator. Then in renderHead, I add some onLoad JS that adds the component to a JS array of components to be validated on form submit. Let me get a little more of the basic started, and then I would REALLY welcome the help! Maybe tomorrow night or Monday I can get a wicketstuff project started for it... The help will be great - my JS fu is rusty! Jeremy Thomerson http://www.wickettraining.com -- sent from a wireless device -Original Message- From: Jörn Zaefferer =F6rn_Zaefferer _ [EMAIL PROTECTED] Sent: Saturday, October 04, 2008 5:50 AM To: users@wicket.apache.org Subject: Re: Client side validation behaviors - already started? What approach for client-side validation are you looking for? I may be able to help with that. Jörn On Fri, Oct 3, 2008 at 5:50 AM, Jeremy Thomerson [EMAIL PROTECTED] wrote: I've been thinking of trying to create some behaviors that combine the standard server-side validation with client-side validation. I just wanted to check to see if anyone knew of something like this already started. I don't want to duplicate work already done. Thanks, -- Jeremy Thomerson http://www.wickettraining.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Client side validation behaviors - already started?
Okay, I was able to commit what I had already started on. This is only a few hours work, so it is nowhere near complete. However, I have the basis for the framework, and a replica of all the StringValidator validation done. https://wicket-stuff.svn.sourceforge.net/svnroot/wicket-stuff/trunk/wicketstuff-client-and-server-validation/ Here are the basic features: - By simply replacing formcomponent.add(StringValidator.exactLength(4)) with add(new ClientAndServerExactLengthValidatingBehavior(form, 4)), it will do the client side validation and add the server side IValidator for you. - It is internationalized because it uses all of the same resource keys / messages that the standard Wicket validators use. - It can insert feedback messages onto the page in a feedback panel or other WebMarkupContainer by calling feedbackpanel.add(new ClientAndServerValidatingFeedbackBehavior(form)) - this will make it use the same appearance that the normal feedback panel would generate. I'm sure there is quite a bit of stuff that can be cleaned up, especially in the JS code. For instance, I'm using document.getElementById quite a bit, but I'm not sure if there are some browsers that may not support that. I need to look because I can't remember. Anyway, feedback is welcome! NOTE: I had started it within another project and was testing it there. I have not had time to test it again after I moved it to its own project. Since all I did was move it, add the license info and rename the packages, it should still work, but you know how that goes. -- Jeremy Thomerson http://www.wickettraining.com On Sat, Oct 4, 2008 at 9:39 AM, Jeremy Thomerson [EMAIL PROTECTED]wrote: Basically, where you would normally call: Formcomponent.add(IValidator), You could now add a behavior. In my behavior, on bind I add the server-side equivalent validator. Then in renderHead, I add some onLoad JS that adds the component to a JS array of components to be validated on form submit. Let me get a little more of the basic started, and then I would REALLY welcome the help! Maybe tomorrow night or Monday I can get a wicketstuff project started for it... The help will be great - my JS fu is rusty! Jeremy Thomerson http://www.wickettraining.com -- sent from a wireless device -Original Message- From: Jörn Zaefferer =F6rn_Zaefferer _ [EMAIL PROTECTED] Sent: Saturday, October 04, 2008 5:50 AM To: users@wicket.apache.org Subject: Re: Client side validation behaviors - already started? What approach for client-side validation are you looking for? I may be able to help with that. Jörn On Fri, Oct 3, 2008 at 5:50 AM, Jeremy Thomerson [EMAIL PROTECTED] wrote: I've been thinking of trying to create some behaviors that combine the standard server-side validation with client-side validation. I just wanted to check to see if anyone knew of something like this already started. I don't want to duplicate work already done. Thanks, -- Jeremy Thomerson http://www.wickettraining.com
Client side validation behaviors - already started?
I've been thinking of trying to create some behaviors that combine the standard server-side validation with client-side validation. I just wanted to check to see if anyone knew of something like this already started. I don't want to duplicate work already done. Thanks, -- Jeremy Thomerson http://www.wickettraining.com