Javascript form submission to activate Spring Web Flow transitions with JSF integration

faceletsjavascriptjsfspring-webflow

I`m developing an application using Spring WebFlow 2, Facelets and JSF. One of my flows does have a page that must trigger a form submit at certain events. For each different action, a different view must be presented. So, I'm trying to activate the following javascript code to perform the submission:

function myFormSubmit( eventId ) {
   var formAction = document.myForm.action;
   document.myForm.action = formAction + '&_eventId=' + eventId;
   document.myForm.submit();
}

Unfortunatelly, this doesn't triggers the requested transition in my flow. The page doesn't change. Does anyone knows how to deal with this?

Thanks,
Alexandre

Best Answer

Don't know anything about SringFaceletsSF, but I think that event handler should probably return true. Otherwise your browser will not submit the form.

so:

function myFormSubmit( eventId ) {
   var formAction = document.myForm.action;
   document.myForm.action = formAction + '&_eventId=' + eventId;
   document.myForm.submit();
   return true;
}
Related Topic