GithubHelp home page GithubHelp logo

limcheekin / jquery-validation-ui Goto Github PK

View Code? Open in Web Editor NEW
20.0 7.0 18.0 1.16 MB

JQuery Validation UI Plugin - Client Side Validation without writing JavaScript

Home Page: http://limcheekin.github.io/jquery-validation-ui/

License: Apache License 2.0

Groovy 37.69% Gosu 5.30% CSS 24.55% JavaScript 32.46%

jquery-validation-ui's Introduction

See the latest documetation here.

jquery-validation-ui's People

Contributors

bluesliverx avatar jonroler avatar limcheekin avatar mgkimsal avatar mootinator avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

jquery-validation-ui's Issues

ValidationService.getConstrainedProperties method has concurrent issue

When two thread run into this method at a same time, they all get closure

def validationClosure = validatableClass.constraints

The problem is two thread get same instance of closure. So when

validationClosure.setDelegate(constrainedPropertyBuilder)

is executed one by one, it may cause previous constrainedPropertyBuilder overwrited by later constrainedPropertyBuilder.

The worst result of this issue is application go into a loop and never break. Will take some times to explain why go int a loop, in short, it was some HashMap code.

change to below code should fix the issue:
def validationClosure = validatableClass.constraints.clone()

i18n Messages that have single quotes in them are not escaped properly

Any message that is resolved in the javascript by renderValidationScript is not escaped if a single quote is present in the message, resulting in an "unknown identifier" javascript message.

This needs to be escaped in the service in getMessage and getTypeMismatchMessage. I'm working on a pull request for it.

jquery-validation-ui doesn't work with hibernate4

Because of the hardcoded dependency on the hibernate plugin, it is not possible to use the hibernate4 plugin, which now is the default for Grails 2.4.

Error messages include:

Caused by NotWritablePropertyException: Invalid property 'lobHandler' of bean class [org.codehaus.groovy.grails.orm.hibernate.ConfigurableLocalSessionFactoryBean]: Bean property 'lobHandler' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
->>  262 | run       in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    745 | run       in java.lang.Thread

Display content from errors.rejectValue in the client

In a remote validation, is there a way to display the error code sent in errors.rejectedValue in the client?
If I have a custom constraint, and I don't return a boolean value but return errors.rejectValue('field','errorCode'), the plugin won't validate that field.

Error after installing plugin version 1.4.9 org/grails/plugins/tomcat/fork/ForkedTomcatServer$_findSystemClasspathJars_closure3

Hi,

I added console log. When I tried to install the plugin I got this error:

|Loading Grails 2.3.5
|Configuring classpath
.
|Environment set to development
.................................
|Packaging Grails application
|Installing zip jquery-validation-ui-1.4.9.zip...
...
|Installed plugin jquery-validation-ui-1.4.9


  • Your grails-app/conf/Config.groovy has been updated with *
  • default configurations of JQuery Validation UI; *
  • please verify that the values are correct. *

.............
|Installing zip jquery-validation-1.9.zip...
...
|Installed plugin jquery-validation-1.9
.............
|Installing zip constraints-0.6.0.zip...
...
|Installed plugin constraints-0.6.0
....................
|Compiling 241 source files
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
.......
|Compiling 40 source files
.......................................................Error
|
Error executing script RunApp: org/grails/plugins/tomcat/fork/ForkedTomcatServer$_findSystemClasspathJars_closure3 (Use --stacktrace to see the full trace)

//////////////////////////////////////////////////////

BuildConfig.groovy (plugins):

plugins {
// plugins for the build system only
build ":tomcat:7.0.50"

    // plugins for the compile step
    compile ":scaffolding:2.0.1"
    compile ':cache:1.1.1'
    compile ":spring-security-core:2.0-RC2" //s2-quickstart
    compile ":spring-security-ui:1.0-RC1"

    // plugins needed at runtime but not for compilation
    runtime ":hibernate:3.6.10.7"// or ":hibernate4:4.1.11.6"
    runtime ":database-migration:1.3.8"
    runtime ":jquery:1.10.2.2"
    runtime ":resources:1.2.1"

}

Matches does not work with \s, \d, etc

The problem is that the code new RegExp("\d{3}") would fail for "010". What actually needs to happen is new RegExp("\d{3}") (notice the double backslash). This should occur in the taglib. I have a fix ready to go for this and will submit the pull request.

[Duplicate of #14] Custom validator failure in JqueryValidationService: No such property: request

[ Sorry. This is a duplicate of #14. I don't think I can withdraw the issue however ]

Following up on your request to have an issue opened from this thread:

https://groups.google.com/forum/?fromgroups=#!topic/jquery-validation-ui-plugin/rh8nxzvAu_o

Including a validator like this:

static constraints = {

    phoneList (validator: { phones, obj, errors ->
        phones.each { p ->
            if (! (p ==~ phoneMask)) {
                errors.rejectValue("phoneList", "personalPhone.phoneNo.matches")
            } 
        }
    })
}

Causes this Exception:

Caused by MissingPropertyException: No such property: request for class: org.grails.jquery.validation.ui.JqueryValidationService
->> 348 | doCall in org.grails.jquery.validation.ui.JqueryValidationService$_createJavaScriptConstraints_closure8


| 271 | createJavaScriptConstraints in org.grails.jquery.validation.ui.JqueryValidationService

Encoding must be set to 'none'

It appears that the only way the messages properly render from the renderValidationScript is by setting the default codec to 'none'. Otherwise the quotes around the messages are escaped.

This leaves the application vulnerable. Should be able to encode your page as html, but have the output from the tag not be encoded.

phone and email validators don't always work

I have applied phone and email validation on two text fields. To test, I tried generating all validation errors multiple times. Most of the validators work fine i.e. the page does not submit and the error messages are displayed. But phone and email validators (out of those that I've tested, there could be more) do not always work this way. In some cases, the page is submitted and I only get server side errors. After getting server side errors, when I try to submit the page again, it again gives me client side error displaying two sets of errors for both fields, both client side and server-side.

[ Duplicate of #14] Custom validator failure: No such property: request

[ Sorry. This is a duplicate of #14. I don't think I can withdraw the issue however ]

Domain classes with a custom validation block trigger this exception:

Caused by MissingPropertyException: No such property: request for class: org.grails.jquery.validation.ui.JqueryValidationService
->> 348 | doCall in org.grails.jquery.validation.ui.JqueryValidationService$_createJavaScriptConstraints_closure8


| 271 | createJavaScriptConstraints in org.grails.jquery.validation.ui.JqueryValidationService

static constraints = {
...

    phoneList (validator: { phones, obj, errors ->
        phones.each { p ->
            if (! (p ==~ phoneMask)) {
                errors.rejectValue("phoneList", "personalPhone.phoneNo.matches")
            } 
        }
    })

}

Can I change the qTip version?

I am using qTip 2.2.0 elsewhere in my project. I would like to try using it with this plugin, however the plugin is using qTip 2.0.0, which is incompatible with jQuery 1.9. I get JavaScript errors when I try to use it.

What is the best way to use the newer version of qTip with jquery-validation-ui?

Links in jquery.qtip.css are not correct

While processing /plugins/jquery-validation-ui-1.2.2/css/qTip/jquery.qtip.css, a resource was required but not found: /plugins/jquery-validation-ui-1.2.2/css/qTip/images/close.png

validate looking for a String or Long value for id

JQueryRemoteValidatorController seems to be expecting a String or Long for the id parameter type. When using MongoDB as the domain object's persistence store it creates an issue as the object type is an org.bson.types.ObjectId. The check in the controller for a String fails and it then tries to convert the id value to a Long, throwing an exception.

Please find the exception below:
2013-08-27 09:50:10,926 [http-bio-8080-exec-9] ERROR StackTrace - Full Stack Trace:
java.lang.NumberFormatException: For input string: "520a5902e4b0ee2a6f3dc4f8"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Long.parseLong(Long.java:441)
at java.lang.Long.valueOf(Long.java:540)
at org.grails.jquery.validation.ui.JQueryRemoteValidatorController$_closure1.doCall(JQueryRemoteValidatorController.groovy:39)
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)

Release 1.4.9 validation messages not html escaped in page source

I installed plugin version 1.4.9.The validation was not working for me as the message section has unescaped html:Any ideas?Using it with grails 2.3.7.

messages: {
custName: { maxlength: function() { return 'Property \u005bcustName\u005d of class \u005bclass Cust\u005d with value \u005b' + $('#custName').val() + '\u005d exceeds the maximum size of \u005b100\u005d'; }, required: 'Customer Name cannot be blank.' },
custDesc: { maxlength: function() { return 'Property \u005bcustDesc\u005d of class \u005bclass Cust\u005d with value \u005b' + $('#custDesc').val() + '\u005d exceeds the maximum size of \u005b200\u005d'; } },

No such property: request for class: org.grails.jquery.validation.ui.JqueryValidationService

Grails 2.1.1
jquery-validation-1.4
Line 348 of ValidationService.groovy

It seems that request is not available in services, you need first to :

import org.codehaus.groovy.grails.web.util.WebUtils

def webUtils = WebUtils.retrieveGrailsWebRequest()
//Getting the Request object
def request = webUtils.getCurrentRequest()

//Getting the Response object
def response = webUtils.getCurrentResponse()

//Getting the ServletContext object
def context = webUtils.getServletContext()

remote validation not working with command objects

When using command objects a few things don't work correctly.

  1. auto wiring.

when a custom validator needs to access a service defined in the command object (same might be for domain object), the service instance variable has not been injected before calling the custom validator.

in JQueryRemoteValidatorController.groovy

                        import org.springframework.beans.factory.config.AutowireCapableBeanFactory

and add this after initiating validatableInstance in the method validate() around line 41
applicationContext.autowireCapableBeanFactory.autowireBeanProperties(validatableInstance,AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, false)

  1. command objects don't respond to isAttached

in same method validate() around line 57 replace

          if(validatableInstance.isAttached()) validatableInstance.discard()

by
if(validatableInstance.metaClass.respondsTo(validatableInstance, "isAttached") && validatableInstance.isAttached())
validatableInstance.discard()

Hope that helps

Regards

Pascal

MissingMethodException: No signature of method: org.grails.jquery.validation.ui.JqueryValidationService.getMessage() is applicable for argument types

When I use this plugin, I get this error:

Caused by MissingMethodException: No signature of method: org.grails.jquery.validation.ui.JqueryValidationService.getMessage() is applicable for argument types: (java.lang.Class, java.lang.String, java.util.ArrayList, java.lang.String, java.util.Locale) values: [class com.x.y.z.command.LoginCommand, ...]

I'm using Grails 2.2.1, and version 1.4.4 of this plugin.

NEW and FIX for Not all fields from the form are binding

I wanted to create a separate issue for a comment Pascal made in issue #17. Not all fields from the form are getting passed back to the controller so we can't do custom validation that requires more than one parameter.

I used Christopher's suggestion to serialize the form and send it back to the controller.

Pushing the fix now.

Custom validator appears in rules instead of $.validator.addMethod

I created a custom validator by adding a Javascript function to CustomConstraintsMap in Config.groovy. The result is that renderValidationScript writes the function directly where the method name should go in the rules map. This produces a JavaScript error: "t.validator.methods[a] is undefined."

According to the jQuery Validation Plugin docs, the custom code should go in $.validator.addMethod.

I'm not sure if I'm doing something wrong or perhaps the approach has changed.

Fix for issue #15 broke the display of field values in validation error messages.

The fix for issue #15 added the encodeAsJavaScript() call at the end of JqueryValidationService.getMessage() in order to allow single quotes inside of message strings. This method escapes single quotes in the message which is exactly what is needed to allow arbitrary strings to be placed inside of a javascript string. However, this type of escaping can't be performed on actual javascript code, which is what is happening as a result of issue #15:

validation-javascript

We are passing actual javascript (' + $('#name').val() + ') to get the value of the field included in the message string. However, when the single quotes are escaped, they just appear inline in the code.

The best fix I can think for this is:

  1. First pass a placeholder string (like "JAVASCRIPT_TO_RETRIEVE_VALUE_GOES_HERE") as an argument to messageSource.getMessage()
  2. Call encodeAsJavascript() on the result (the placeholder will still be present here).
  3. Finally, replace the placeholder with the actual javascript.

This solution allows the message to be escaped for quotes as needed, and the javascript can then be added in the correct place without the escaping. The main downside to this approach is some arbitrary placeholder text has to be chosen that hopefully won't appear elsewhere in the message. I don't see any way around this, however, so we'll just have to pick something very likely to not appear in any actual message.

Maven POM file has jquery 1.7.2 hard dependency in it

This is causing conflict with jquery 1.8.3 installed. I've no idea where/how the POM would have that hard dependency in it - I don't see anything in the plugin code that specifies a jquery dependency.

org.grails.plugins jquery 1.7.2 zip runtime xml-apis xml-apis

Plugin using latest version of hibernate plugin - incompatible with older versions of grails

The latest version of the plugin is using version 3.6.10.2 of the hibernate plugin. This is not compatible with older versions of grails (specifically anything <2.3) this causes a problem when building older apps.

We were using latest.release of jquery-validation-ui plugin but have since switched to specify version number 1.4.5.

This is less of a bug and more of a suggestion to elevate this dependency into the plugin descriptor or to downgrade the dependency to an older version of hibernate plugin.

Thanks

Sintax error in v1.4.8

Hi, I've tried to update this plugin to the latest version (1.4.8) but I'm having a sintax error in FireBug.

SyntaxError: syntax error
url: '/testJQ/JQueryRemoteValidator/validate',

Where the sintax error is with these characters: "&#39"
This is not happening with the previous version.

Regards

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.