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 ChristianKoeberl: http://wiki.apache.org/tapestry/Tapestry5HowToUseForms The comment on the change is: Added a howto for multiple submits ------------------------------------------------------------------------------ } }}} + ==== Dealing with multiple submits ==== + + If you want to have two or more submits on a form with different actions (e.g. different pages to invoke) you have to do thw following: + + 1. add the two submit buttons to the form {{{ + @Component + private Submit submit1; + @Component + private Submit submit2; + }}} + 1. add event listeners for "select" event on both buttons and save the return value the form action should return on success: {{{ + private Object formEventReturn; + void onSelectFromSubmit1() { + // do whatever; + formEventReturn = AnotherPage.class; // go to AnotherPage + } + void onSelectFromSubmit2() { + // do whatever + formEventReturn = null; // stay on this page + } + }}} + 1. in the event from the form (see above) return the formEventReturn {{{ + Object onSuccessFromFoo() { + //do things specific to form Foo + return formEventReturn; + } + }}} + + All this has to be done because the Submit cannot add a context to the form and the "select" events must not return any objects (just void). The idea for this solution is from HLS (see [http://mail-archives.apache.org/mod_mbox/tapestry-users/200703.mbox/[EMAIL PROTECTED] HLS on mailing-list about multiple submits]) ==== 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. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
