contact.jsp
<form action="ContactAction.mtw" method="post"> Name: <input type="text" name="name" /> <br /> Birthdate: <input type="text" name="birthdate" /> <br /> Age: <input type="text" name="age" /> <br /> </form>
ContactAction.java
public class ContactAction extends BaseAction { public String execute() { String name = input.getString("name"); Date birthdate = input.getDate("birthdate"); int age = input.getInt("age"); return SUCCESS; } }
public class ContactAction extends BaseAction { public String searchContacts() { EntityManager entityManager = (EntityManager) input.getValue(JpaFilter.KEY); ... } }
public class ConfigManager extends ApplicationManager { @Override public void loadFilters() { filter(new JpaFilter("persistenceUnitNameHere")); } }
<form action="ContactAction.mtw" method="post" enctype="multipart/form-data"> <input type="file" name="photo" /> <input type="submit" value="Send..." /> </form>
public class ConfigManager extends ApplicationManager { @Override public void loadActions() { action("/ContactAction", ContactAction.class).fwdOk("/contact.jsp") .filter(new FileUploadFilter()); } }
public class ContactAction extends BaseAction { public String execute() { FileItem photo = (FileItem) input.getValue("photo"); ... } }
public class Contact { private String name; private String phoneNumber; public Contact() { } // Getters and Setters... }
<form action="ContactAction.mtw" method="post"> Name: <input type="text" name="name" /> <br /> Phone number: <input type="text" name="phoneNumber" /> <br /> </form>
The VOFilter below do the real thing...
public class ConfigManager extends ApplicationManager { @Override public void loadActions() { action("/ContactAction", ContactAction.class).fwdOk("/contact.jsp") .filter(new VOFilter("contact", Contact.class)); } }
public class ContactAction extends BaseAction { public String execute() { Contact contact = (Contact) input.getValue("contact"); ... } }