Hugo Madureira wrote: > I don't want to have a whole page with the form. Instead, I need to > use a div to hold the forms and use the Cocoon Forms using Ajax > Requests. The problem is that the forms block include .js files in the > html head tag and this can't be done using Ajax.
I had a similar problem: I included some forms with CIncludes, so the XSLT that would add the .js files to the head section would operate on a snippet of a page and didn't even see a head tag. I solved the problem by moving the XSLT transformer into the main pipeline, so that it now operates on the whole page, after the CIncludes, so it sees both the head section and the different forms. Your situation is a bit more difficult though, as you probably haven't even created the forms at the time when the page is sent to the browser. I can see two solutions. The safer one, although more difficult, is to create a dummy head tag in your forms' .jx files, so that the transformer can add the required .js links to the Ajax response. Then modify your form-loading Ajax code so that it extracts the fake head section from the Ajax response and does something appropriate with the .js files, such as adding them to the real head section using DOM or some other trick. The easier solution would be to add the needed .js files statically to all your pages. > find all the .js files needed to load Just look for templates that match "head" in the various src/blocks/forms/java/org/apache/cocoon/forms/resources/forms-*.xsl (and other templates called by them.) Keep in mind that the list of needed .js files varies depending on what components you use in your forms. You might even have to recreate some of the logic in those XSLTs in client-side javascript, for example if those templates add a few custom lines of script to the head section depending on the particular form. Toby -- Signed/encrypted mail welcome. GPG/PGP Key-Id: 0x15C5C2EA --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]