Click
Click Examples

Source Viewer : WEB-INF/classes/org/apache/click/examples/page/control/RegexDemo.java

package org.apache.click.examples.page.control;

import org.apache.click.control.Form;
import org.apache.click.control.Submit;
import org.apache.click.examples.page.BorderPage;
import org.apache.click.examples.page.HomePage;
import org.apache.click.extras.control.PageSubmit;
import org.apache.click.extras.control.RegexField;

/**
 * Provides a form RegexField example.
 */
public class RegexDemo extends BorderPage {

    private static final long serialVersionUID = 1L;

    private Form form = new Form("form");

    public RegexDemo() {
        addControl(form);

        RegexField versionField = new RegexField("version", "Version", 10);
        versionField.setPattern("[0-9]+\\.[0-9]+\\.[0-9]+");
        versionField.setRequired(true);
        versionField.setTitle("Version number, e.g. '1.2.0'");
        form.add(versionField);

        RegexField urlField = new RegexField("url", "URL", 30);
        urlField.setPattern("(http|https)://.+");
        urlField.setRequired(true);
        urlField.setTitle("URL address, e.g. 'http://www.google.com'");
        form.add(urlField);

        form.add(new Submit("ok", "  OK  "));
        form.add(new PageSubmit("cancel", HomePage.class));
    }

}