Example usage for org.apache.wicket.validation.validator RangeValidator range

List of usage examples for org.apache.wicket.validation.validator RangeValidator range

Introduction

In this page you can find the example usage for org.apache.wicket.validation.validator RangeValidator range.

Prototype

public static <T extends Comparable<? super T> & Serializable> RangeValidator<T> range(T minimum, T maximum) 

Source Link

Usage

From source file:org.devgateway.eudevfin.ui.common.components.NumberInputField.java

License:Open Source License

public NumberInputField<T> range(T min, T max) {
    field.add(RangeValidator.range(min, max));
    return this;
}

From source file:org.devgateway.eudevfin.ui.common.components.NumberTextInputField.java

License:Open Source License

public NumberTextInputField<T> range(T min, T max) {
    field.add(RangeValidator.range(min, max));
    return this;
}

From source file:org.devgateway.eudevfin.ui.common.components.TextInputField.java

License:Open Source License

public TextInputField<T> range(Integer min, Integer max) {
    if (!field.getType().isAssignableFrom(Integer.class))
        throw new RuntimeException(
                "Please use the typeInteger() method to set the type, or range validator won't work!");
    field.add(RangeValidator.range(min, max));
    return this;
}

From source file:org.wicketstuff.datetime.extensions.yui.calendar.DateTimeField.java

License:Apache License

/**
 * create a new {@link TextField} instance for hours to be added to this panel.
 * //  w  ww .  ja  va2 s . c om
 * @param id
 *            the component id
 * @param model
 *            model that should be used by the {@link TextField}
 * @param type
 *            the type of the text field
 * @return a new text field instance
 */
protected TextField<Integer> newHoursTextField(final String id, IModel<Integer> model, Class<Integer> type) {
    TextField<Integer> hoursTextField = new TextField<>(id, model, type);
    hoursTextField.add(getMaximumHours() == 24 ? RangeValidator.range(0, 23) : RangeValidator.range(1, 12));
    hoursTextField.setLabel(new Model<>(HOURS));
    return hoursTextField;
}

From source file:org.wicket_sapporo.workshop01.page.form.validation.ValidationFormPage.java

License:Apache License

/**
 * Construct./*  w ww . j  a v  a2s. c  o  m*/
 */
public ValidationFormPage() {

    Form<FormPageBean> form = new Form<FormPageBean>("form", new CompoundPropertyModel<>(new FormPageBean())) {
        private static final long serialVersionUID = 6843470916943201357L;

        @Override
        protected void onSubmit() {
            super.onSubmit();
            // getModelObject???????Model???????
            System.out.println(getModelObject().toString());
            setResponsePage(new FormConfirmationPage(getModel()));
        }
    };

    add(form);

    // FeedbackPanel??????????????
    form.add(new FeedbackPanel("feedback"));

    form.add(new TextField<String>("name") {
        private static final long serialVersionUID = 5903648176922990518L;

        @Override
        protected void onInitialize() {
            // ???onInitialize??????????
            super.onInitialize();
            // ??
            setRequired(true);
            // 30????????
            add(StringValidator.maximumLength(10));
            // ?????????????
            setLabel(Model.of("???"));
        }
    });

    form.add(new TextField<Integer>("age") {
        private static final long serialVersionUID = 8030102985942074330L;

        @Override
        protected void onInitialize() {
            super.onInitialize();
            // ?0150??
            add(RangeValidator.range(0, 150));
            // ?????????????
            setLabel(Model.of(""));
        }
    });

    form.add(new TextArea<>("introduction"));

}