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 The comment on the change is: Sorry I had "On" in my examples, should have been "on" ------------------------------------------------------------------------------ ==== Form Events ==== - *prepare -> calls !OnPrepare() + *prepare -> calls !onPrepare() - *validate -> calls !OnValidate() + *validate -> calls !onValidate() - *success -> calls !OnSuccess() + *success -> calls !onSuccess() - *failure -> calls !OnFailure() + *failure -> calls !onFailure() - *submit -> calls !OnSubmit() + *submit -> calls !onSubmit() ==== Dealing with multiple forms ==== @@ -37, +37 @@ 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 inside subcomponents on the page! + If you have a method called onSubmit() or onSuccess(), etc, they will get called for either form. This happens even if the forms are inside subcomponents on the page! - * This is just a friendly reminder that forms themselves cannot be nested. - {{{ - <!--You can't do this! --> - <form> - <form> - </form> - </form> - <!--You CAN do this! --> - <form> - </form> - <form> - </form> - }}} + - To make form "foo" call a specific method, suffix the On{FormEventName}() with On{FormEventName}FromFoo(), where {FormEventName} is an event from the list given earlier. + To make form "foo" call a specific method, suffix the on{FormEventName}() with on{FormEventName}FromFoo(), where {FormEventName} is an event from the list given earlier. i.e. To catch the submit event of a form with id="Foo", you can do this: {{{ - OnSubmitFromFoo(){ + onSubmitFromFoo(){ //do things specific to form Foo } }}} @@ -107, +95 @@ </form> }}} + + + ==== Common Pitfalls ==== + + When you are coding furiously, or haven't had your coffee, you may forget a few things. Here are a few that happened to me: + ===== Nested Forms ===== + A friendly reminder that forms themselves cannot be nested. Make sure that the end result of your layered components won't lead to something like this. + {{{ + <!--You can't do this! --> + <form> + <form> + </form> + </form> + + <!--You CAN do this! --> + <form> + </form> + <form> + </form> + }}} + + ===== Why is my form event method not getting called? ===== + Besides typos in the name of the method, there '''''is''''' a case sensitivity issue to be aware of: the "on" prefix must be lower case. i.e. "OnSubmit" will not get called, but "onSubmit" will. T5's extensive case '''''in'''''sensitivity can cause us to be lazy sometimes. + --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
