Skip to content

Instantly share code, notes, and snippets.

@kelunik
Last active January 17, 2020 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kelunik/5c5124b9e4fec684665366a17fc2882d to your computer and use it in GitHub Desktop.
Save kelunik/5c5124b9e4fec684665366a17fc2882d to your computer and use it in GitHub Desktop.
<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