Click
Click Examples

Source Viewer : WEB-INF/classes/org/apache/click/examples/page/velocity/VelocityMacro.java

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

import org.apache.click.control.Form;
import org.apache.click.control.Reset;
import org.apache.click.control.Submit;
import org.apache.click.control.TextField;
import org.apache.click.examples.control.InvestmentSelect;
import org.apache.click.examples.page.BorderPage;
import org.apache.click.examples.page.HomePage;
import org.apache.click.extras.control.DoubleField;
import org.apache.click.extras.control.EmailField;
import org.apache.click.extras.control.IntegerField;
import org.apache.click.extras.control.PageSubmit;

/**
 * Provides a Velocity Macro example.
 */
public class VelocityMacro extends BorderPage {

    private static final long serialVersionUID = 1L;

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

    public VelocityMacro() {
        addControl(form);
        TextField nameField = new TextField("name", true);
        nameField.setMinLength(5);
        nameField.setTitle("Customer full name");
        nameField.setFocus(true);
        form.add(nameField);

        EmailField emailField = new EmailField("email", true);
        emailField.setTitle("Customers email address");
        form.add(emailField);

        IntegerField ageField = new IntegerField("age");
        ageField.setMinValue(1);
        ageField.setMaxValue(120);
        form.add(ageField);

        DoubleField holdingsField = new DoubleField("holdings", true);
        holdingsField.setTitle("Total investment holdings");
        form.add(holdingsField);

        form.add(new InvestmentSelect("investments"));

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

}