Form Handling & Validation

Type-safe form processing with OorianForm and FormListener—no manual parsing required.

Async Form Submission

OorianForm submits asynchronously without a page reload. The form is processed on the server and the page updates in place—no redirects, no refresh.

FormListener

Implement the FormListener interface to receive typed FormEvent objects with all submitted data.

Parameters API

Access submitted values through a rich Parameters API with typed getters for strings, ints, doubles, and booleans.

Input Types

Built-in support for TextInput, PasswordInput, Checkbox, RadioButton, Select, FileInput, and more.

Validation

Validate form data on the server with full access to your domain logic, database, and business rules.

Error Reporting

Report validation errors back to the client with clear, targeted messages for each field.

OorianForm & FormListener

OorianForm submits asynchronously within the same page—no redirect, no reload. Add input elements, register a FormListener, and handle the submission in your onEvent method. After processing, update any element on the page to show results, errors, or confirmation messages.

Java
@Page("/contact")
public class ContactPage extends HtmlPage implements FormListener
{
    private Div messageArea;

    @Override
    protected void createBody(Body body)
    {
        OorianForm form = new OorianForm();

        TextInput name = new TextInput();
        name.setName("name");
        name.setPlaceholder("Your name");
        form.addElement(name);

        TextInput email = new TextInput();
        email.setName("email");
        email.setPlaceholder("Email address");
        form.addElement(email);

        Button submit = new Button("Send");
        submit.setType("submit");
        form.addElement(submit);

        form.registerListener(this, FormEvent.class);
        body.addElement(form);

        // Area for showing results without leaving the page
        messageArea = new Div();
        body.addElement(messageArea);
    }

    @Override
    public void onEvent(FormEvent event)
    {
        Parameters params = event.getParameters();
        String name = params.getParameterValue("name");
        String email = params.getParameterValue("email");

        // Process and update the page in place
        saveContact(name, email);
        messageArea.setText("Thanks, " + name + "! We'll be in touch.");
    }
}

Benefits

Asynchronous, Same-Page Processing

Forms submit asynchronously without a page reload. Process the data on the server and update any element on the page to show results, errors, or confirmation—all within the same page.

Type-Safe Parameters

The Parameters API provides typed accessors like getParameterValueAsInt() and getParameterValueAsBoolean(), eliminating manual parsing.

Built-in Validation

Validate submissions with Java code on the server. No need to duplicate validation logic in JavaScript.

Multiple Input Types

Built-in support for text, password, checkbox, radio, select, file upload, and hidden inputs with consistent handling.

Clean Separation

The FormListener pattern cleanly separates form construction from submission handling, keeping your code organized.