| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| <!-- $Id$ --> |
| <html> |
| <head> |
| <title>Submit</title> |
| <link rel="stylesheet" type="text/css" href="Tapestry.css" title="style"> |
| </head> |
| <body> |
| |
| <table border="0" cellpadding="0" cellspacing="0" width="100%"> |
| <tr> |
| <td align="left"><A href="Shell.html"><IMG alt=Shell src="common-images/prev.png"></A></td> |
| <td align="middle"><A href="index.html"><IMG alt="Component Index" src="common-images/home.png" ></A></td> |
| <td align="right"><A href="TextArea.html"><IMG alt=TextArea src="common-images/next.png"></A></td> |
| <tr> |
| <tr> |
| <td colspan="3"><hr></td> |
| </tr> |
| <tr> |
| <td colspan="3"> |
| <table border="0" cellpadding="4" cellspacing="4" width="100%"> |
| |
| <tr valign="top"> |
| <td> |
| <table> |
| <tr> |
| <td><font size="+2"><b>Submit</b></font></td> |
| </tr> |
| <tr> |
| <td> |
| <A href="../api/org/apache/tapestry/form/Submit.html"> |
| org.apache.tapestry.form.Submit</A> |
| </td> |
| </tr> |
| </table> |
| </td> |
| <td> |
| <table align="right" valign="middle" bgcolor="#c0c0c0" cellspacing="8"> |
| <tr> |
| <td><input type="submit" value="Submit"></td> |
| </tr> |
| </table> |
| </td> |
| |
| </table></td> |
| </tr> |
| |
| <tr valign="center"> |
| <td colspan="2"> </td> |
| </tr> |
| |
| <tr> |
| <td colspan="2"> |
| <b>Description</b> |
| <br> |
| Provides a HTML form submission element <input type="submit">. |
| The Submit component must be wrapped by a <A href="Form.html">Form</A>. |
| <p> |
| This component is generally only used when the form has multiple submit |
| buttons, and it is important for the application to know which one was |
| pressed. You may also want to use |
| <A href="ImageSubmit.html">ImageSubmit</A> |
| which accomplishes much the same thing, but uses a graphic image instead. |
| <P> |
| In typical use, the application needs to know which Submit was |
| the one clicked by the user. This can be accomplished in two ways: |
| <UL> |
| <LI>Use the <B>listener</B> to perform an operation directly</LI> |
| <LI>Use the <B>selected</B> and <B>tag</B> parameters to identify the button.</LI> |
| </UL> |
| <P> |
| If a listener is used, it will be invoked as the Submit component is rewound. |
| In addition, the <A href="Form.html">Form</A>'s listener be invoked if defined. |
| <P> |
| Use the first method if you need to be sure that the entire form has rewound |
| before any logic specific to the ImageSubmit is triggered. |
| </P> |
| </td> |
| </tr> |
| |
| <tr> |
| <td colspan="2"> |
| <b>See Also</b> |
| <br> |
| <A href="Button.html">Button</A>, |
| <A href="Form.html">Form</A>, |
| <A href="Checkbox.html">Checkbox</A>, |
| <A href="Hidden.html">Hidden</A>, |
| <A href="ImageSubmit.html">ImageSubmit</A>, |
| <A href="ListEdit.html">ListEdit</A>, |
| <A href="Option.html">Option</A>, |
| <A href="Radio.html">Radio</A>, |
| <A href="RadioGroup.html">RadioGroup</A>, |
| <A href="Select.html">Select</A>, |
| <a href="TextArea.html">TextArea</a>, |
| <A href="TextField.html">TextField</A>, |
| <A href="ValidField.html">ValidField</A> |
| </td> |
| </tr> |
| |
| <tr> |
| <td colspan="2"> |
| <b>Parameters</b> |
| <br> |
| <table border="1" cellpadding="4" cellspacing="4" class="parameters"> |
| <tr> |
| <th>Name</th> |
| <th>Type</th> |
| <th>Direction</th> |
| <th>Required</th> |
| <th>Default</th> |
| <th>Description</th> |
| </tr> |
| <tr> |
| <td>label</td> |
| <td>String</td> |
| <td>in</td> |
| <td>no</td> |
| <td> </td> |
| <td>The label put on the button (this becomes the HTML value attribute). |
| </td> |
| </tr> |
| <tr> |
| <td>disabled |
| <td>boolean</td> |
| <td>in</td> |
| <td>no</td> |
| <td>false</td> |
| <td> |
| If set to true, the button will be disabled (will not respond to |
| the mouse); the browser should provide a "greyed out" appearance. |
| </td> |
| </tr> |
| <tr> |
| <td>selected</td> |
| <td>Object</td> |
| <td>out</td> |
| <td>no</td> |
| <td> </td> |
| <td> |
| This parameter is bound to a property that is updated when the submit |
| button is clicked by the user. The property is updated to match the tag |
| parameter. |
| </td> |
| </tr> |
| <tr> |
| <td>tag</td> |
| <td>Object</td> |
| <td>in</td> |
| <td>no</td> |
| <td> </td> |
| <td> |
| Tag used with the selected parameter to indicate which Submit button |
| on a form was clicked. |
| </td> |
| </tr> |
| <tr> |
| <td>listener</td> |
| <td> |
| <A href="../api/org/apache/tapestry/IActionListener.html"><tt>IActionListener</tt></A> |
| </td> |
| <td>in</td> |
| <td>no</td> |
| <td> </td> |
| <td> |
| If specified, the listener is notified. This notification occurs as the |
| component is rewinded, i.e., prior to the <A href="Form.html">Form</A>'s |
| listener. In addition, the selected property (if bound) will be updated |
| <u>before</u> the listener is notified. |
| </td> |
| </tr> |
| </table> |
| <P> |
| Body: <STRONG>removed</STRONG><BR> |
| Informal parameters: <STRONG>allowed</STRONG><br> |
| Reserved parameters: "name", "type" |
| </P> |
| </td> |
| </tr> |
| |
| <tr> |
| <td colspan="2"> |
| <b>Examples</b> |
| <p> |
| In this login form the <b>loginSubmit</b> and <b>helpSubmit</b> components use |
| <A href="../api/org/apache/tapestry/IActionListener.html">listener</A>s |
| to invoke their actions. Also note how the helpSubmitAction() method |
| redirects to another page using a |
| <A href="../api/org/apache/tapestry/PageRedirectException.html"><tt>PageRedirectException</tt></A> |
| . |
| <p> |
| |
| <table class="examples" cellpadding="4"> |
| <form> |
| <tr> |
| <td>Username:</td><td><input size="12"></td> |
| </tr> |
| <tr> |
| <td>Password:</td><td><input type="password" size="12"></td> |
| </tr> |
| <tr align="right"> |
| <td colspan="2"> |
| <input type="submit" value="Login"> |
| <input type="submit" value="Help"> |
| </td> |
| </tr> |
| </form> |
| </table> |
| |
| <pre> |
| <form jwcid="@<a href="Form.html">Form</a>"> |
| <table cellpadding="4"> |
| <tr><td>Username:</td><td><input jwcid="@<a href="TextField.html">TextField</a>" value="ognl:username" size="12"/></td> |
| </tr> |
| <tr><td>Password:</td><td><input jwcid="@<a href="TextField.html">TextField</a>" value="ognl:password" hidden="ognl:true" size="12"/></td> |
| </tr> |
| <tr align="right"> |
| <td colspan="2"> |
| <input type="submit" jwcid="<span class="jwcid">@</span><a href="Submit.html">Submit</a>" listener="ognl:listeners.loginSubmitAction" value="Login"/> |
| <input type="submit" jwcid="<span class="jwcid">@</span><a href="Submit.html">Submit</a>" listener="ognl:listeners.helpSubmitAction" value="Help"/> |
| </td> |
| </tr> |
| </table> |
| </form> |
| |
| <property-specification name="username" type="java.lang.String"/><br><property-specification name="password" type="java.lang.String"/><br> |
| public abstract class LoginPage extends BasePage { |
| |
| public abstract String getUsername(); |
| |
| public abstract void setUsername(String value); |
| |
| public abstract String getPassword(); |
| |
| public abstract void setPassword(String value); |
| |
| public void loginSubmitAction(IRequestCycle cycle) { |
| // Authenticate user's login attempt |
| .. |
| } |
| |
| public void helpSubmitAction(IRequestCycle cycle) throws RequestCycleException { |
| // Redirect to Help Desk page |
| throw new PageRedirectException("HelpDesk"); |
| } |
| |
| } |
| </pre> |
| |
| <td></td> |
| |
| <tr> |
| <td colspan="2"><hr></td> |
| </tr> |
| |
| <tr> |
| <td colspan="2"> |
| In the following example the Submit component uses the <b>selected</b> and |
| <b>tag</b> parameters to identify the event source in the Form's |
| <A href="../api/org/apache/tapestry/IActionListener.html">listener</A> method. |
| For more information about this example please see |
| <A href="PropertySelection.html">PropertySelection</a>. |
| <p> |
| |
| <table class="examples" valign="middle" cellspacing="8"> |
| <tr> |
| <td> |
| <form> |
| <br> |
| Item: |
| <select> |
| <option selected>Dress</option> |
| <option>Jacket</option> |
| <option>Pants</option> |
| <option>Shirt</option> |
| <option>Skirt</option> |
| </select> |
| <p> |
| Description: Cotton full length Summer dress |
| <p> |
| Label: CountryClub |
| <p> |
| Price: $89.95 |
| <p> |
| <input type="Submit" value="Add to Cart"/> |
| </form> |
| </td> |
| </tr> |
| </table> |
| |
| <pre> |
| <form jwcid="@<A href="Form.html">Form</a>" listener="ognl: listeners.formSubmit"> |
| Item: <span jwcid="selectItem"/> |
| <p> |
| Description: <span jwcid="@<A href="Insert.html">Insert</a>" value="ognl: clothingItem.description">100% Egyptian Cotton</span> |
| <p> |
| Label: <span jwcid="@<A href="Insert.html">Insert</a>" value="ognl: clothingItem.label">Jersey Bed Sheet</span> |
| <p> |
| Price: $<span jwcid="@<A href="Insert.html">Insert</a>" value="ognl: clothingItem.price">$150.00</span> |
| <p> |
| <input jwcid="<span class="jwcid">addToCartSubmit</span>" type="Submit" value="Add to Cart"/> |
| </form> |
| |
| |
| <property-specification name="itemSelectionModel" type="ItemSelectionModel" persistent="yes"/><br><property-specification name="clothingItem" type="Item" persistent="yes"/><br><property-specification name="selectedComponent" type="java.lang.String"/><br> |
| <component id="selectItem" type="<A href="PropertySelection.html">PropertySelection</a>"> |
| <binding name="model" expression="itemSelectionModel"/> |
| <binding name="value" expression="clothingItem"/> |
| <binding name="submitOnChange" expression="true"/> |
| </component> |
| |
| <component id="<span class="jwcid">submitAddToCart</span>" type="<A href="Submit.html">Submit</a>"> |
| <binding name="selected" expression="selectedComponent"/> |
| <binding name="tag" expression='"SUBMIT_ADD_TO_CHART"'/> |
| </component> |
| |
| public abstract class PurchagePage extends BasePage { |
| |
| public abstract String getSelectedComponent(); |
| |
| public abstract void setSelectedComponent(String value); |
| |
| public abstract Item getClothingItem(); |
| |
| public abstract void setClothingItem(Item value); |
| |
| public abstract ItemSelectionModel getItemSelectionModel(); |
| |
| public abstract ItemSelectionModel setItemSelectionModel(ItemSelectionModel value); |
| |
| public void formSubmit(IRequestCycle cycle) { |
| if (getSelectedComponent().equals("SUBMIT_ADD_TO_CHART")) { |
| // Submit from submitAddToCart component. |
| // Add selected item to shopping cart |
| Item item = getClothingItem(); |
| .. |
| } else { |
| // Submit from selectItem component. |
| // Item display will automatically update, but we will log user's |
| // interest in the selected clothing item |
| .. |
| } |
| } |
| } |
| |
| public class Item implements Serializable { |
| private Integer id; |
| private String name; |
| private String description; |
| private String label; |
| private String price; |
| |
| public Item(Integer id, String name, String desc, String label, String price) { |
| this.id = id; |
| this.name = name; |
| this.description = desc; |
| this.label = label; |
| this.price = price; |
| } |
| |
| public int getId() { return id; } |
| |
| public String getName() { return name; } |
| |
| public int getDescription() { return description; } |
| |
| public int getLabel() { return label; } |
| |
| public int getPrice() { return price; } |
| } |
| |
| public class ItemSelectionModel implements <A href="../api/org/apache/tapestry/form/IPropertySelectionModel.html">IPropertySelectionModel</a>, Serializable { |
| private List itemList; |
| |
| public ItemPropertySelectionModel(List itemList) { |
| this.itemList = itemList; |
| } |
| |
| public int getOptionCount() { return itemList.size(); } |
| |
| public Object getOption(int index) { |
| return itemList.get(index) |
| } |
| |
| public String getLabel(int index) { |
| return ((Item) itemList.get(index)).getName(); |
| } |
| |
| public String getValue(int index) { Integer.toString(index); } |
| |
| public Object translateValue(String value) { |
| return getOption(Integer.parseInt(value)); |
| } |
| } |
| </pre> |
| </td> |
| </tr></table> |
| <tr> |
| <td colspan="3"><hr></td> |
| </tr> |
| <tr> |
| <td align="left"><A href="Shell.html"><IMG alt=Shell src="common-images/prev.png"></A></td> |
| <td align="middle"><A href="index.html"><IMG alt="Component Index" src="common-images/home.png" ></A></td> |
| <td align="right"><A href="TextArea.html"><IMG alt=TextArea src="common-images/next.png"></A></td> |
| </tr> |
| |
| </body> |
| </html> |