Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package net.sourceforge.jsdialect.validation;
Client-side validation using jQuery-Validation plugin for a JSR-303 annotated Java class. Could use th:object and th:field attribute values, like:
 <form th:object="${product" th:validate="${product}">
         <input type="text" th:field="*{description}" />
Also could use defined values, as in:
 <form th:validate="${product">
         <input type="text" name="description" />
A second parameter could be provided to prevent mandatory asterisks HTML generation:
 <form th:validate="${product, false">
         <input type="text" name="description" />
public class ValidateAttrProcessor extends AbstractAttrProcessor {

jQuery-validation-plugin 1.8.1 supported locales.
    private final static String[] jqueryValidationLanguages = {"ar""bg""ca""cn""cs""da""de""el",
    private JsDialect dialect;
    public ValidateAttrProcessor(JsDialect dialect) {
        this. = dialect;
    public int getPrecedence() {
        return 10000;
    public ProcessorResult processAttribute(Arguments argumentsElement elementString attributeName) {
        // Add jquery scripts
        new ValidateCommand(argumentselementattributeName).execute();
        return .;

Adds jQuery dependencies. If jQuery-validation-plugin support user language, adds localization script.
    private void addScripts(Arguments arguments) {
        String language = arguments.getContext().getLocale().getLanguage();
        if (ArrayUtils.contains(language)) {
            .addScriptAfter(arguments."messages_" + language + ".js");
New to GrepCode? Check out our FAQ X