Hi Tim

It's easy to get into trouble if you Prototype directly with Stripes to submit forms. Due to the way Stripes looks for events (by looking through a Set where the order isn't guaranteed) and the fact that Prototypes Form.serialize() also includes buttons/submits buttons and reset buttons. The case where I spotted this was a form with two buttons a cancel and a register button. There match the cancel and register eventhandler methods in our ActionBean. But since prototype serializes the entire form including the buttons, and eventhough I tried to make sure that register would be first in the querystring (that was before I checked that it used a Set) cancel would almost always have a higher order than register and therefore all submits would result in the cancel event handler being called.

I've created a workaround which copies from Prototypes Form.serialize() and excludes buttons of various sorts.

function serializeForm(form) {
   var elements = Form.getElements($(form));
   var queryComponents = new Array();

   for (var i = 0; i < elements.length; i++) {
       var element = elements[i];
var isButton = element.type == "submit" || element.type == "button" || element.type == "reset";
       if (!isButton) {
           var queryComponent = Form.Element.serialize(element);
           if (queryComponent) {
               queryComponents.push(queryComponent);
           }
       }
   }
   return queryComponents.join('&');
}

/Jeppe


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development

Reply via email to