Forms - miguelperezcolom/mateu GitHub Wiki

Declaring a form in Mateu is so easy as creating a class. Mateu will use java reflection to infer all of the form fields and form actions, and you can use annotations to change the default behavior of Mateu.

So, a form to send an email could be something like this:

package com.example.demo;

import io.mateu.core.domain.uidefinition.shared.annotations.MainAction;
import io.mateu.core.domain.uidefinition.shared.annotations.MateuUI;
import io.mateu.core.domain.uidefinition.shared.annotations.TextArea;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

@MateuUI("/form")             // this sets the url
@Service@Scope("prototype")   // use prototype scope if you do not want every user to share the same form
public class SimpleForm {

    String email;

    String subject;

    @TextArea
    String body;

    @MainAction
    public void send() {
        // send the email
    }
    
}

Annotating the class as a @Service is optional, but it will allow you to inject any bean if you need to. The form above would become something like this:

If you want to include the form as a menu option in a bigger application, you only need to put it as a @MenuOption annotated field like this:

@MateuUI(path = "")
public class SimpleUI {

    @MenuOption
    SimpleForm sendEmail;

}

Please visit https://github.com/miguelperezcolom/mateu/tree/master/demo for a complete reference.

⚠️ **GitHub.com Fallback** ⚠️