Dear Wiki user, You have subscribed to a wiki page or wiki category on "Tapestry Wiki" for change notification.
The following page has been changed by DanielJue: http://wiki.apache.org/tapestry/Tapestry5HowToUseForms New page: How to use forms in Tapestry 5 [[BR]] Forms are probably the most used way of getting data from an end user. Tapestry does a lot to hook up actions on your forms to methods in your supporting page/component class. Keep in mind that page classes are (usually) just POJOs that live in a certain package that mirrors the template location. More details are here: [http://tapestry.apache.org/tapestry5/tapestry-core/apidocs/org/apache/tapestry/corelib/components/Form.html] ==== Form Events ==== *prepare -> calls OnPrepare() *validate -> calls OnValidate() *success -> calls OnSuccess() *failure -> calls OnFailure() *submit -> calls OnSubmit() ==== Dealing with multiple forms ==== It's a good idea to give an id to your forms, either in a component annotation in your code, or in the html template. Here's how it looks using annotations: {{{ @Component(id = "runsocmpform") private Form form; }}} Here's how it looks using your html template: {{{ <t:form t:id="foo"> ...stuff... </t:form> }}} Now when you have ids for your forms, you probably want a specific method to get called when a particular form is acted on. Lets say we have forms with ids "foo" and "bar". If you have a method called OnSubmit() or OnSuccess(), etc, they will get called for either form. This happens even if the forms are nested in subcomponents on the page! To make form "foo" call a specific method, suffix the On_____() with On_____FromFoo() i.e. {{{ OnSubmitFromFoo(){ //do things specific to form Foo } }}} ==== Forms and Names ==== If you don't specify a name for the form, tapestry will generate a form whose name is the same as the id. {{{ <t:form t:id="foo"> ...stuff... </t:form> }}} becomes {{{ <form id="foo" name="foo"> ...stuff... </form> }}} --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
