public class ContactPage extends BasePage {
public static class ContactMessage implements Serializable {
public String name;
public String email;
public String message;
}
public ContactPage() {
// Show success()/error() messages as toasts
add(Oat.Behaviors.feedbackToasts());
Form<ContactMessage> form = new Form<>("contactForm",
new CompoundPropertyModel<>(new ContactMessage()));
form.setOutputMarkupId(true);
add(form);
// Models come from the CompoundPropertyModel, labels from ContactPage.properties - both by id
form.add(new OatTextField<String>("name").setRequired(true));
form.add(new OatEmailField("email").setRequired(true));
form.add(new OatTextArea<String>("message").setRequired(true));
form.add(Oat.Components.submitButton("submit", "Send Message",
target -> {
success("Thanks, " + form.getModelObject().name + "! We'll be in touch.");
target.add(form);
},
target -> {
error("Please fix the errors below.");
target.add(form); // show the inline errors
}));
}
}
# ContactPage.properties
name=Your Name
email=Email Address
message=Message
<!-- ContactPage.html -->
<wicket:extend>
<form wicket:id="contactForm" class="vstack gap-4">
<div wicket:id="name"></div>
<div wicket:id="email"></div>
<div wicket:id="message"></div>
<footer class="hstack justify-end mt-2">
<button wicket:id="submit"></button>
</footer>
</form>
</wicket:extend>
vstack, hstack, gap-4, justify-end and
mt-2 are Oat's own layout utilities, not Tailwind: Wicket Oat uses no CSS
library besides Oat. The README lists
all of them.