Skip to content

Instantly share code, notes, and snippets.

@kelunik
Last active Jan 17, 2020
Embed
What would you like to do?
<template>
<VueForm action="/api/test.json">
<FormLabel label="First name">
<FormInput name="firstName"/>
</FormLabel>
<FormLabel label="Last name">
<FormInput name="lastName">
</FormLabel>
<FormSubmit>Save</FormSubmit>
</VueForm>
</template>
{
"firstName": "...",
"lastName": "..."
}
pubic class TestAction extends ApiAction<TestAction.Request, TestAction.Response> {
public Resolution execute(Request request) {
User user = new User();
user.setFirstName(request.firstName);
user.setLastName(request.lastName);
// save user
return respond(new Response(user.getId()));
}
public static class Request {
@Validate(minlength = 3, required = true)
public String firstName;
@Validate(maxlength = 1024, required = true)
public String lastName;
}
public static class Response {
public long id;
public Response(long id) {
this.id = id;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment