You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Jorg Heymans <jh...@domek.be> on 2004/08/20 17:36:10 UTC

cforms forms_onsubmit()

Hi,

Is it possible to fully override the onsubmit handler that is generated 
by cforms? Cocoon allways puts a forms_onsubmit() infront of whatever i 
put in the handler of the form template, causing my javascript code not 
to be executed upon submit. The whole of google has only 2 references to 
forms_onsubmit() so i am really wondering what this thing actually does.


Also: is it possible to just use plain cforms without continuations? I 
used to do form.showForm() but that creates a new continuation each 
time. My usecase really does not need continuations, so i tried doing 
cocoon.sendPage("display", {"CocoonFormsInstance": form}) resulting in a 
classcastexception.
(http://marc.theaimsgroup.com/?l=xml-cocoon-users&m=109300831129697&w=2)

I am using 2.1.5.1, should i switch to CVS for using basic cforms?

Regards
Jorg


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: cforms forms_onsubmit()

Posted by Marc Portier <mp...@outerthought.org>.
Jorg,

I hope you're not serious on wanting to override: there are (well could 
be) functions that cforms really need to be called.

Now, since of course you're likely to have some functions you want to 
call as well, there has been a provisioning for this through the use of 
so called on-submit handlers (functions you can register to be called on 
submit)

Here is how you do it:

by some magic (xslt most probably) you need to make sure you include 
something like the following in the resulting html-page:

   <script language="javascript">
       // making my on-submit...
       var myFSHandler = new Object();
       myFSHandler.forms_onsubmit = function() {
           alert('hello');
       };


       // registring your on-submit
       forms_onsubmitHandlers[forms_onloadHandlers.length] = myFSHandler;
   </script>


the same pattern exists for 'on_load' of the form-page (allowing to 
initialize some stuff)

for the machinery behind this, pls check: 
http://cvs.apache.org/viewcvs.cgi/cocoon/trunk/src/blocks/forms/samples/resources/forms-lib.js?rev=36594&root=Apache-SVN&view=auto
(search for onsubmit and onload)

HTH,
-marc=

Jorg Heymans wrote:

> 
> 
> Jorg Heymans wrote:
> 
>> Hi,
>>
>> Is it possible to fully override the onsubmit handler that is 
>> generated by cforms? Cocoon allways puts a forms_onsubmit() infront of 
>> whatever i put in the handler of the form template, causing my 
>> javascript code not to be executed upon submit. The whole of google 
>> has only 2 references to forms_onsubmit() so i am really wondering 
>> what this thing actually does.
> 
> 
> Thanks to the very active google-spider, google now contains 5 
> references to forms_onsubmit() :-)
> 
> Anyone have a clue what this thing actually does?
> my
> 
> <ft:form-template onsubmit="alert('hello')">
> 
> is transformed by cforms to
> 
> <form onsubmit="forms_onsubmit(); alert('hello');">
> 
> causing the alert function not to be executed anymore...
> 
> 
> Regards
> Jorg Heymans
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 

-- 
Marc Portier                            http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
Read my weblog at                http://blogs.cocoondev.org/mpo/
mpo@outerthought.org                              mpo@apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: cforms forms_onsubmit()

Posted by Jorg Heymans <jh...@domek.be>.

Jorg Heymans wrote:

> Hi,
> 
> Is it possible to fully override the onsubmit handler that is generated 
> by cforms? Cocoon allways puts a forms_onsubmit() infront of whatever i 
> put in the handler of the form template, causing my javascript code not 
> to be executed upon submit. The whole of google has only 2 references to 
> forms_onsubmit() so i am really wondering what this thing actually does.

Thanks to the very active google-spider, google now contains 5 
references to forms_onsubmit() :-)

Anyone have a clue what this thing actually does?
my

<ft:form-template onsubmit="alert('hello')">

is transformed by cforms to

<form onsubmit="forms_onsubmit(); alert('hello');">

causing the alert function not to be executed anymore...


Regards
Jorg Heymans


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org