This topic explains how to set up user data submission using an HTML form, a form bean (a Java representation of the HTML form), and an action.
The purpose of these instructions is to make you familiar with some of the main dialogs and wizards to help you accomplish this coding goal. These instructions are not intended to apply to every case where a form is required for user submitted data. For example, these instruction may not apply directly if you already have a pre-existing form beans. In that case, the instruction below can modified to utilize your pre-existing resources: where the instructions tell you to create a form bean, simply select the pre-existing item from the dropdown list.
These instructions assume that you have a dynamic web project (New > Project > Other > Web > Dynamic Web Project) that contains a page flow.
(If you already have a form bean, you can skip this step.)
@Jpf.FormBean public static class Customer implements java.io.Serializable { private String firstName; private String lastName; }
The code created should look like something like the following:
form.jsp page
<netui:form action="nameAction"> <table> <tr valign="top"> <td><label for="field1"> FirstName: </label></td> <td><netui:textBox dataSource="actionForm.firstName" tagId="field1"></netui:textBox></td> </tr> <tr valign="top"> <td><label for="field2"> LastName: </label></td> <td><netui:textBox dataSource="actionForm.lastName" tagId="field2"></netui:textBox></td> </tr> </table> <netui:button value="nameAction" type="submit" /> </netui:form>
Controller.java
@Jpf.Action(forwards = { @Jpf.Forward(name = "success", path = "confirm.jsp") }) public Forward nameAction(Controller.NameForm form) { Forward forward = new Forward("success"); return forward; } ... @Jpf.FormBean public static class NameForm implements java.io.Serializable { private static final long serialVersionUID = 1815159769L; private String firstName; private String lastName; public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } }