Monday, May 24, 2004

Cocoon's server-side javascript debugger

...is almost as bad as MSIE's client-side javascript debugger. At least IE tells you a line and a column reference (even if they're totally bogus, and let's not even mention the way IE chokes on debugging external scripts). While coding, I accidentally put new newList = new Array(); instead of var newList = new Array();.

It blows up with org.apache.avalon.framework.CascadingRuntimeException: Invalid assignment left-hand side.. No hint of a line number, mind you. That'd be too useful. In this case, I was lucky -- the error message itself pretty much tells you what to look for. But in more subtle coding errors, this is a major flaw in the Cocoon framework. It's not "rapid application development" if you're spending an hour debugging silly JS mistakes that the server is too dumb to help you with.

As an aside, I think I've solved the problem of having multiple submit buttons. Here's the use case: I'm adding individuals to a client account. I want the user to be able to delete/edit parties they have already added to the client listing. But due to some issues with WoodyTemplateTransformer, you can't dynamically use JXTemplateTransformer to generate extra submit buttons on the fly -- they won't be recognized as real submit events.

My (half-baked?) solution: In your form binding, define two submit buttons, one for edit, one for delete. Also, define a field to indicate which party you wish to edit. In your layout, make the party indicator a hidden field. Then display the same edit/delete button for each party, but make them set the party indicator on onclick. Works beautifully.

Comments: Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?