Package org.springmodules.validation.bean.annotation.javascript.taglib

Source Code of org.springmodules.validation.bean.annotation.javascript.taglib.MaxHandler

package org.springmodules.validation.bean.annotation.javascript.taglib;

import java.lang.annotation.Annotation;

import org.springframework.context.support.MessageSourceAccessor;
import org.springmodules.validation.bean.conf.loader.annotation.handler.Max;

public class MaxHandler extends Handler {

    public MaxHandler() {
        super(Max.class);
    }

    @Override
    public String convertToValang(String fieldName, Annotation a, MessageSourceAccessor messages) {
        Max annotation = (Max) a;

        String errMsg = messages.getMessage(annotation.errorCode(), annotation.message());
        String applyIfValang = valangToJS(annotation.applyIf());

        StringBuffer sb = new StringBuffer();
        sb.append(" function() {return this.lessThanOrEquals((this.getPropertyValue(");
        sb.append(wrapAndEscapeJsString(fieldName));// field
        sb.append(")), (");
        sb.append(annotation.value());
        sb.append("))}");

        return buildBasicRule(fieldName, errMsg, sb.toString(), applyIfValang, annotation);
    }

}
TOP

Related Classes of org.springmodules.validation.bean.annotation.javascript.taglib.MaxHandler

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.