You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by novotny <no...@gridsphere.org> on 2008/12/06 02:08:55 UTC

how to invoke javascript method after form validation?

Hi,

I have markup like <li class="noerror">Enter text<input type="text"
wicket:id="sometext"/>....

And I'm using FeedbackPanel currently, but instead of showing all the errors
at the top, we want to change class="noerror" to class="error" which seems
easier to do in javascript. But how can I indicate to wicket to invoke this
javascript function which changes class="noerror" to class="error" for those
fields that have errrors?
I'm open to other ideas, but I have lots of wicket panels and don't want to
have to add a lot more wicket code to every class e.g. doing <li
wicket:id=...> in markup and adding RepeatingView/Label solutions seems like
more work.

Thanks, Jason
-- 
View this message in context: http://www.nabble.com/how-to-invoke-javascript-method-after-form-validation--tp20865454p20865454.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: how to invoke javascript method after form validation?

Posted by Jeremy Thomerson <je...@wickettraining.com>.
Here's the easiest way that I can think of....

Create a behavior (extend AbstractBehavior) that assigns a class to the form
component of either "error" or "noerror" based on the component status.

Then, if you don't want to manually add it to every form component, I think
you could add a visitor to the form that adds the behavior to all form
components for you.

This is (IMHO) a better solution than JS - it works on the server side.

-- 
Jeremy Thomerson
http://www.wickettraining.com

On Fri, Dec 5, 2008 at 7:08 PM, novotny <no...@gridsphere.org> wrote:

>
> Hi,
>
> I have markup like <li class="noerror">Enter text<input type="text"
> wicket:id="sometext"/>....
>
> And I'm using FeedbackPanel currently, but instead of showing all the
> errors
> at the top, we want to change class="noerror" to class="error" which seems
> easier to do in javascript. But how can I indicate to wicket to invoke this
> javascript function which changes class="noerror" to class="error" for
> those
> fields that have errrors?
> I'm open to other ideas, but I have lots of wicket panels and don't want to
> have to add a lot more wicket code to every class e.g. doing <li
> wicket:id=...> in markup and adding RepeatingView/Label solutions seems
> like
> more work.
>
> Thanks, Jason
> --
> View this message in context:
> http://www.nabble.com/how-to-invoke-javascript-method-after-form-validation--tp20865454p20865454.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>