Package codetroopers.wicket.web.parsley.tagmodifier

Source Code of codetroopers.wicket.web.parsley.tagmodifier.ParsleyMinTagModifier

package codetroopers.wicket.web.parsley.tagmodifier;

import codetroopers.wicket.web.parsley.tagmodifier.bags.ValueBag;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.html.form.FormComponent;

import javax.validation.constraints.Min;

import static codetroopers.wicket.web.parsley.validator.ParsleyNumberValueValidationBehaviors.*;

/**
* @author cgatay
*/
public class ParsleyMinTagModifier extends AbstractTagModifier<Min> {
    /**
     * we're using the existing behaviors to keep a correct DRYness
     */
    @Override
    public void modify(final FormComponent<?> component, final ComponentTag tag, final Min annotation) {
        ValueBag bag = new ValueBag(getLabelString(component), annotation.value());
        final ParsleyMinValueValidationBehavior minValidator =
                new ParsleyMinValueValidationBehavior(annotation.value(),
                                                      getLocalizedMessage(component, annotation.message(), bag));
        minValidator.onComponentTag(component, tag);
    }
}
TOP

Related Classes of codetroopers.wicket.web.parsley.tagmodifier.ParsleyMinTagModifier

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.