RE: jQuery form validation with wicket ajax

2012-02-15 Thread Paul Jackson

This works for us:

onclick=if (! $('#id45').validate().form()) {return false};if 
(function(){return Wicket.$$(this)Wicket.$$('id45')}.bind(this)()) { 
Wicket.showIncrementally('busyIndicator');}var 
wcall=wicketSubmitFormById('id45', 
'?x=cu02w6454cTq5HSn4Av8ZXGRwfcS*bDlrHDXn8GklQ6Sh3RC2Dgwz8XwqsEQE*Jo7KvmsA5Uh0NowPRWPoKW7z8clW5Md9oNtKs9d1v0BgjqKNKS-oluEmHYF0Tjrkqq8T76MXi*zlTAtfj5YLHG3gKsV2tb4R*z',
 'address:pafForm:pafSearch' ,function() { 
;Wicket.hideIncrementally('busyIndicator');}.bind(this),function() { 
;Wicket.hideIncrementally('busyIndicator');}.bind(this), function() {return 
Wicket.$$(this)Wicket.$$('id45')}.bind(this));;; return false;

It's basically the same, with some extras bits for busy indicators and such.

Paul

-Original Message-
From: Gerrit Scholz | QUERPLEX.de [mailto:gerrit.sch...@querplex.de] 
Sent: 15 February 2012 09:09
To: users@wicket.apache.org
Subject: AW: jQuery form validation with wicket ajax

I prepend if(!$('.register').valid()) { return false;}; to the onclick 
attribute.
This statement call the jQuery validator for the form.

The onclick attribute without my changes (AjaxRequestTarget not null): 

onclick=var wcall=wicketSubmitFormById('contactForm8', 
'../kemner/?wicket:interface=:4:contactForm:sendContact::IActivePageBehaviorListener:0:1wicket:ignoreIfNotActive=true',
 'sendContact' ,function() { }.bind(this),function() { }.bind(this), function() 
{return Wicket.$$(this)Wicket.$$('contactForm8')}.bind(this));;; return 
false;

onclick with my changes (AjaxRequestTarget null):

onclick= if(!$('.register').valid()) { return false;}; var 
wcall=wicketSubmitFormById('contactForm8', 
'../kemner/?wicket:interface=:4:contactForm:sendContact::IActivePageBehaviorListener:0:1wicket:ignoreIfNotActive=true',
 'sendContact' ,function() { }.bind(this),function() { }.bind(this), function() 
{return Wicket.$$(this)Wicket.$$('contactForm8')}.bind(this));;; return 
false;

Gerrit

-Ursprüngliche Nachricht-
Von: Alec Swan [mailto:alecs...@gmail.com]
Gesendet: Dienstag, 14. Februar 2012 18:50
An: users@wicket.apache.org
Betreff: Re: jQuery form validation with wicket ajax

Are you saying that AjaxRequestTarget is not null without your onclick 
attribute changes and is null with your changes? If so, please post the changes 
you made to onclick attribute.

On Tue, Feb 14, 2012 at 7:06 AM, Gerrit Scholz | QUERPLEX.de 
gerrit.sch...@querplex.de wrote:
 If I intercept the onclick event my function is called but the processing not 
 stop. Mean that the wicket (onclick) javascript is running parallel.
 So I write a AttributeModifier that prepends my function to the onclick 
 attribute. Now the validation works fine, but on the onSubmit method of the 
 wicket ajax button the AjaxRequestTarget is null so the component to refresh 
 cannot be added.

 Gerrit

 -Ursprüngliche Nachricht-
 Von: Paul Jackson [mailto:paul.jack...@cdl.co.uk]
 Gesendet: Dienstag, 14. Februar 2012 10:38
 An: users@wicket.apache.org
 Betreff: RE: jQuery form validation with wicket ajax

 Thanks for that link! I never managed to work out how to get jquery events to 
 override the buttons onClick attribute. This should simplify our validation 
 code a lot.

 Paul

 -Original Message-
 From: Alec Swan [mailto:alecs...@gmail.com]
 Sent: 13 February 2012 16:38
 To: users@wicket.apache.org
 Subject: Re: jQuery form validation with wicket ajax

 This thread describes a purely client-side solution to your problem:
 http://stackoverflow.com/questions/1506729/how-to-intercept-the-onclick-event.
 You can solve this problem for all you AJAX links by assigning them a special 
 class, e.g. class=ajaxLink, and then apply the technique to $(form 
 .ajaxLink).

 On Mon, Feb 13, 2012 at 3:55 AM, Paul Jackson paul.jack...@cdl.co.uk wrote:
 We use an OnBeforeRenderListener to add onClick events to the buttons and 
 ajax buttons on a form that we want to be validated. We have to handle the 
 normal buttons and ajax buttons slightly differently.

 Ajax button:

            button.add(new AttributeModifier(onclick, new 
 ModelString(if (! $('# + formMarkupId
                    + ').validate().form()) {return false};)) {

 Normal Button:

            button.add(new WiQueryEventBehavior(new
 Event(MouseEvent.CLICK) {
                @Override
                public JsScope callback() {
                    return JsScope.quickScope(return $('# + 
 formMarkupId + ').validate().form(););
                }
            }));

 Hope that helps.

 Paul

 -Original Message-
 From: Gerrit Scholz | QUERPLEX.de [mailto:gerrit.sch...@querplex.de]
 Sent: 13 February 2012 10:18
 To: users@wicket.apache.org
 Subject: jQuery form validation with wicket ajax

 Hello there,
 I try to use jQuery validaton (http://docs.jquery.com/Plugins/Validation) 
 with a wicket AJAX button. I register the jQuery validator on the form. If I 
 use a normal wicket submit button or link, the jQuery form validation works. 
 But if I use

RE: Wicket jQuery Validator integration

2012-02-15 Thread Paul Jackson
We do something very similar to this, and agree that it works really
well. We also use JSR303 annotations on our domain models and use them
to drive adding both wicket and jquery validators. 

We have a bunch of ValdiationConfiguration classes that know what to add
to the markup and javascript to get the client side validation to work,
so we don't need an extension to IValidator.

Cheers,
Paul

-Original Message-
From: Zachary Bedell [mailto:zacl...@thebedells.org] 
Sent: 15 February 2012 15:52
To: users@wicket.apache.org
Subject: Wicket jQuery Validator integration

Good morning,

Reading a recent thread about accessing jQuery Validation from Wicket
reminded me that I've developed some code that might be of use.  I'm not
sure if this is something anyone else would be interested in or if it's
something that might eventually be integrated into Wicket core or if it
would be more appropriate for one of the existing jQuery/Wicket
integration libraries.  I wanted to describe what I've cooked up so far.
If this is anything that would be useful, I'd be willing to clean the
code up a bit to extract a few bits that are specific to our environment
and post the code somewhere.

My intent was to get client-side validation using Wicket's existing
validation classes without requiring AJAX calls to make them work and
preferably without requiring Page's to include lots of unsightly
JavaScript.  Also, not duplicating validation logic on the client 
server tiers was desirable.  The code was originally developed for a
site that was expected to receive a high amount of traffic in a short
period of time, and avoiding unnecessary server calls was a priority.  

I created a subclass of Form (ClientSideValidatingForm) which examines
each FormComponent (and sub-Form) added to it and extracts information
about the standard Wicket validations.  It generates JavaScript which
uses jQuery's Validator library to apply client-side checks equivalent
to the Wicket server side checks.  The nice thing about this is that you
get client-side validation for free just by adding the normal Wicket
validations plus you still get all your validations backed up in the
server side in case JavaScript is unavailable or disabled.

The implementation of the class does lack a bit in terms of elegance
unfortunately.  As the Wicket validation interface doesn't currently
know anything about JavaScript, it was necessary to run a chain of
instanceof checks against all the known Wicket validations and emit
JavaScript to mirror their logic.  I also created an extension of the
Wicket IValidator interface which can provide JavaScript functions to
perform validation equivalent to the server-side Java code.  The
extraction code in ClientSideValidatingForm preferentially checks for
this interface and uses provided JavaScript if available.  Otherwise,
it's a bunch of instanceof's to check for known validations or log an
error if an unknown instance of IValidator is found.

Long term, it would be helpful if the stock Wicket IValidator interface
could include a method to get JavaScript validations for all of the
stock validations.

The code is pretty tightly bound to jQuery Validator at this point, but
it's likely the methodology could be abstracted to other validation
frameworks.  It's also built using WiQuery, though that's mostly as a
convenience to get the same version of jQuery that we use elsewhere.
The same could easily be implemented without WiQuery provided a version
of jQuery was contributed to the response via some other mechanism.

Is this something anyone would be interested in?  

Best regards,
Zac Bedell

(Apologies if this is a dupe. I had some email client config issues this
morning...)


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

**
Please consider the environment - do you really need to print this email?

This email is intended only for the person(s) named above and may contain 
private and confidential information. If it has come to you in error, please 
destroy and permanently delete any copy in your possession and contact us on 
+44 (0) 161 480 4420. The information in this email is copyright © CDL Group 
Holdings Limited. We cannot accept any liability for any loss or damage 
sustained as a result of software viruses. It is your responsibility to carry 
out such virus checking as is necessary before opening any attachment.

Cheshire Datasystems Limited uses software which automatically screens incoming 
emails for inappropriate content and attachments. If the software identifies 
such content or attachment, the email will be forwarded to our Technology 
Department for checking. You should be aware that any email which you send to 
Cheshire Datasystems Limited is subject to this procedure.

Cheshire Datasystems Limited, Strata 

RE: jQuery form validation with wicket ajax

2012-02-14 Thread Paul Jackson
Thanks for that link! I never managed to work out how to get jquery events to 
override the buttons onClick attribute. This should simplify our validation 
code a lot.

Paul

-Original Message-
From: Alec Swan [mailto:alecs...@gmail.com] 
Sent: 13 February 2012 16:38
To: users@wicket.apache.org
Subject: Re: jQuery form validation with wicket ajax

This thread describes a purely client-side solution to your problem:
http://stackoverflow.com/questions/1506729/how-to-intercept-the-onclick-event.
You can solve this problem for all you AJAX links by assigning them a special 
class, e.g. class=ajaxLink, and then apply the technique to $(form 
.ajaxLink).

On Mon, Feb 13, 2012 at 3:55 AM, Paul Jackson paul.jack...@cdl.co.uk wrote:
 We use an OnBeforeRenderListener to add onClick events to the buttons and 
 ajax buttons on a form that we want to be validated. We have to handle the 
 normal buttons and ajax buttons slightly differently.

 Ajax button:

            button.add(new AttributeModifier(onclick, new 
 ModelString(if (! $('# + formMarkupId
                    + ').validate().form()) {return false};)) {

 Normal Button:

            button.add(new WiQueryEventBehavior(new 
 Event(MouseEvent.CLICK) {
                @Override
                public JsScope callback() {
                    return JsScope.quickScope(return $('# + 
 formMarkupId + ').validate().form(););
                }
            }));

 Hope that helps.

 Paul

 -Original Message-
 From: Gerrit Scholz | QUERPLEX.de [mailto:gerrit.sch...@querplex.de]
 Sent: 13 February 2012 10:18
 To: users@wicket.apache.org
 Subject: jQuery form validation with wicket ajax

 Hello there,
 I try to use jQuery validaton (http://docs.jquery.com/Plugins/Validation) 
 with a wicket AJAX button. I register the jQuery validator on the form. If I 
 use a normal wicket submit button or link, the jQuery form validation works. 
 But if I use an AJAX button or link, the jQuery form validation is not 
 called. How can I call the jQuery validation before AJAX update.
 Thanks,
 Gerrit



 --
 - QUERPLEX GmbH Nürnberg | www.querplex.de Kornmarkt 2
 D-90402 Nürnberg
 --
 -
 Tel +49 (0)911 94 11 98 - 0
 Fax +49 (0)911 94 11 98 - 59
 --
 -
 Registergericht Nürnberg HRB 20 123
 Geschäftsführerin: Angelika Benkert
 --
 -
 **
 Please consider the environment - do you really need to print this email?

 This email is intended only for the person(s) named above and may contain 
 private and confidential information. If it has come to you in error, please 
 destroy and permanently delete any copy in your possession and contact us on 
 +44 (0) 161 480 4420. The information in this email is copyright © CDL Group 
 Holdings Limited. We cannot accept any liability for any loss or damage 
 sustained as a result of software viruses. It is your responsibility to carry 
 out such virus checking as is necessary before opening any attachment.

 Cheshire Datasystems Limited uses software which automatically screens 
 incoming emails for inappropriate content and attachments. If the software 
 identifies such content or attachment, the email will be forwarded to our 
 Technology Department for checking. You should be aware that any email which 
 you send to Cheshire Datasystems Limited is subject to this procedure.

 Cheshire Datasystems Limited, Strata House, Kings Reach Road, 
 Stockport SK4 2HD Registered in England and Wales with Company Number 
 3991057 VAT registration: 727 1188 33

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


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



RE: jQuery form validation with wicket ajax

2012-02-13 Thread Paul Jackson
We use an OnBeforeRenderListener to add onClick events to the buttons and ajax 
buttons on a form that we want to be validated. We have to handle the normal 
buttons and ajax buttons slightly differently.

Ajax button:

button.add(new AttributeModifier(onclick, new ModelString(if 
(! $('# + formMarkupId
+ ').validate().form()) {return false};)) {

Normal Button:

button.add(new WiQueryEventBehavior(new Event(MouseEvent.CLICK) {
@Override
public JsScope callback() {
return JsScope.quickScope(return $('# + formMarkupId + 
').validate().form(););
}
}));

Hope that helps.

Paul

-Original Message-
From: Gerrit Scholz | QUERPLEX.de [mailto:gerrit.sch...@querplex.de] 
Sent: 13 February 2012 10:18
To: users@wicket.apache.org
Subject: jQuery form validation with wicket ajax

Hello there,
I try to use jQuery validaton (http://docs.jquery.com/Plugins/Validation) with 
a wicket AJAX button. I register the jQuery validator on the form. If I use a 
normal wicket submit button or link, the jQuery form validation works. But if I 
use an AJAX button or link, the jQuery form validation is not called. How can I 
call the jQuery validation before AJAX update.
Thanks,
Gerrit
 


---
QUERPLEX GmbH Nürnberg | www.querplex.de Kornmarkt 2
D-90402 Nürnberg
---
Tel +49 (0)911 94 11 98 - 0
Fax +49 (0)911 94 11 98 - 59
---
Registergericht Nürnberg HRB 20 123
Geschäftsführerin: Angelika Benkert
---
**
Please consider the environment - do you really need to print this email?

This email is intended only for the person(s) named above and may contain 
private and confidential information. If it has come to you in error, please 
destroy and permanently delete any copy in your possession and contact us on 
+44 (0) 161 480 4420. The information in this email is copyright © CDL Group 
Holdings Limited. We cannot accept any liability for any loss or damage 
sustained as a result of software viruses. It is your responsibility to carry 
out such virus checking as is necessary before opening any attachment.

Cheshire Datasystems Limited uses software which automatically screens incoming 
emails for inappropriate content and attachments. If the software identifies 
such content or attachment, the email will be forwarded to our Technology 
Department for checking. You should be aware that any email which you send to 
Cheshire Datasystems Limited is subject to this procedure.

Cheshire Datasystems Limited, Strata House, Kings Reach Road, Stockport SK4 2HD
Registered in England and Wales with Company Number 3991057
VAT registration: 727 1188 33


Interaction betwen IAjaxRegionMarkupIdProvider, renderPlaceholderTag and visibility

2011-03-25 Thread Paul Jackson
Hi,

 

I've just discovered what I think is a bug with
IAjaxRegionMarkupIdProvider. We are using it on a Behavior that provides
a border to form components (label, mandatory marker, etc), which for
the most part works great.

 

We have encountered a problem when toggling the visibility of a form
component with this behavior via ajax. 

 

The component is first sent out visible and the markup is all correct.

 

A change elsewhere on the page causes the component to be set to not
visible and redrawn via ajax. The ajax response contains a tag with a
markupid generated via renderPlaceholderTag. This does not take into
account the  IAjaxRegionMarkupIdProvider behaviour.

 

Another change happens on the page causing the component to become
visible, and the ajax replace can't happen because the component with
the correct markupId is not present.

 

I think the problem is that renderPlaceholderTag should be aware of
IAjaxRegionMarkupIdProvider behaviours on the component when creating
the markupid. Should I raise a issue for this?

 

Cheers,

Paul

/PRE
p style=font-family:'Arial';font-size:8pt
**br
Please consider the environment - do you really need to print this email?br
br
This email is intended only for the person(s) named above and may contain 
private and confidential information. If it has come to you in error, please 
destroy and permanently delete any copy in your possession and contact us on 
+44 (0) 161 480 4420. The information in this email is copyright copy; CDL 
Group Holdings Limited. We cannot accept any liability for any loss or damage 
sustained as a result of software viruses. It is your responsibility to carry 
out such virus checking as is necessary before opening any attachment.br
Cheshire Datasystems Limited uses software which automatically screens incoming 
emails for inappropriate content and attachments. If the software identifies 
such content or attachment, the email will be forwarded to our Technology 
Department for checking. You should be aware that any email which you send to 
Cheshire Datasystems Limited is subject to this procedure. br
Cheshire Datasystems Limited, Strata House, Kings Reach Road, Stockport SK4 
2HDbr
Registered in England and Wales with Company Number 3991057br
VAT registration: 727 1188 33/p
PRE