Formio

Form definition & binding library for Java platform

Get Started »

Download | Changelog | Issues | Doc

Features

  • Easy-to-use configurable handy tool.
  • Automatic bidirectional binding, even to immutable objects, primitives, collections and arrays, nested objects and lists of them.
  • Support for (non)default constructors, static factory methods.
  • Validation of form data (both bean validation API annotations and net.formio.validation.Validator can be used).
  • Seamless support for file uploads and configurable max. request/file size.
  • Form definitions are immutable, composable, self-contained, can be easily shared and cached.
  • Automatic generating of form markup (or its parts) can be optionally used.
  • One simple entry point to API: Forms class.
  • Non-invasive – easy integration with frameworks, minimum dependencies.
  • Usable with various template frameworks, with servlets, portlets or even in desktop applications.
  • Simply unit testable forms.
  • Good test coverage (about 70 % of lines).
  • Protection against CSRF attacks using authorization tokens in forms.
  • Inspired mainly by well-designed Play! framework.

License

Apache License 2.0 allows usage also in commercial projects.

Three steps to get started

  1. Prepare form definition (optional automatic mapping of properties):
    		private static final FormMapping<Person> personForm =
    	      Forms.automatic(Person.class, "person").build();
  2. Fill it with data:
    	    FormData<Person> formData = new FormData<>(
    	      person, ValidationResult.empty);
    	    FormMapping<Person> filledForm = 
    	      personForm.fill(formData);
    	    // Push the filled form into a template, 
    	    // use its properties to render it; or use 
    		// BasicFormRenderer to generate form markup
    		// automatically
  3. Bind data from request back into an object:
    		FormData<Person> formData = personForm.bind(
    		  new ServletRequestParams(request));
    	    if (formData.isValid()) {
    	      // save the person: formData.getData()
    	    } else {
    	      // show again the invalid form with validation 
    	      // messages: personForm.fill(formData) ...
    	    }