You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Michael Gerzabek <mi...@gmx.net> on 2012/01/29 13:28:11 UTC

How to use custom onSubmit handler in form tag?

The form tag automagically renders a javascript handler for the onSubmit
event [1, line 388]. It uses the same snippet that's declared for
onclick handler in MarkupConstants.WAIT_FOR_PAGE
<http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/MarkupConstants.html>
[2] described in [3].

How could I contribute my own javascript snippet to onSubmit attribute
of forms? How can I override this setting?

[1]
http://tapestry.apache.org/current/apidocs/src-html/org/apache/tapestry5/corelib/components/Form.html
[2]
http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/MarkupConstants.html
[3] http://tapestry.apache.org/javascript.html

Re: How to use custom onSubmit handler in form tag?

Posted by Michael Gerzabek <mi...@gmx.net>.
Thank you Thiago and Christian, I now switched over to use an action
link scenario. With that the desired implementation is easier to obtain.


Am 31/01/2012 19:50, schrieb Thiago H. de Paula Figueiredo:
> Why don't you just add a listener to the 'submit' function of the form
> using Prototype's Element.observe() or the similar function in jQuery?
> Anyway, adding onXXX attributes to attach listeners to HTML elements
> isn't recommended at all.
>
> On Tue, 31 Jan 2012 15:51:30 -0200, Christian Köberl
> <ta...@gmail.com> wrote:
>
>> 2012-01-29, Michael Gerzabek:
>>> The form tag automagically renders a javascript handler for the
>>> onSubmit
>>> event [1, line 388]. It uses the same snippet that's declared for
>>> onclick handler in MarkupConstants.WAIT_FOR_PAGE
>>> <http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/MarkupConstants.html>
>>>
>>> [2] described in [3].
>>>
>>> How could I contribute my own javascript snippet to onSubmit attribute
>>> of forms? How can I override this setting?
>>
>> The problem is that this is no setting and therefore cannot be
>> overwritten.
>>
>> One solution is to override the default JavaScriptStack of Tapestry and
>> provide another implementation of the onSubmit handler:
>> 1. copy CoreJavaScriptStack
>> 2. change tapestry.js in array to a modified copy in your project
>> 3. contribute the overridden configuration
>> public static void
>> contributeJavaScriptStackSource(MappedConfiguration<String,
>> JavaScriptStack> configuration)
>> {
>>   configuration.overrideInstance(InternalConstants.CORE_STACK_NAME,
>> MyCoreJavaScriptStack.class);
>> }
>>
>> Has anybody a better idea?
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>
>


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


Re: How to use custom onSubmit handler in form tag?

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Why don't you just add a listener to the 'submit' function of the form  
using Prototype's Element.observe() or the similar function in jQuery?  
Anyway, adding onXXX attributes to attach listeners to HTML elements isn't  
recommended at all.

On Tue, 31 Jan 2012 15:51:30 -0200, Christian Köberl  
<ta...@gmail.com> wrote:

> 2012-01-29, Michael Gerzabek:
>> The form tag automagically renders a javascript handler for the onSubmit
>> event [1, line 388]. It uses the same snippet that's declared for
>> onclick handler in MarkupConstants.WAIT_FOR_PAGE
>> <http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/MarkupConstants.html>
>> [2] described in [3].
>>
>> How could I contribute my own javascript snippet to onSubmit attribute
>> of forms? How can I override this setting?
>
> The problem is that this is no setting and therefore cannot be  
> overwritten.
>
> One solution is to override the default JavaScriptStack of Tapestry and
> provide another implementation of the onSubmit handler:
> 1. copy CoreJavaScriptStack
> 2. change tapestry.js in array to a modified copy in your project
> 3. contribute the overridden configuration
> public static void
> contributeJavaScriptStackSource(MappedConfiguration<String,
> JavaScriptStack> configuration)
> {
>   configuration.overrideInstance(InternalConstants.CORE_STACK_NAME,
> MyCoreJavaScriptStack.class);
> }
>
> Has anybody a better idea?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>


-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
Consultor, desenvolvedor e instrutor em Java, Tapestry e Hibernate
http://www.arsmachina.com.br

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


Re: How to use custom onSubmit handler in form tag?

Posted by Christian Köberl <ta...@gmail.com>.
2012-01-29, Michael Gerzabek:
> The form tag automagically renders a javascript handler for the onSubmit
> event [1, line 388]. It uses the same snippet that's declared for
> onclick handler in MarkupConstants.WAIT_FOR_PAGE
> <http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/MarkupConstants.html>
> [2] described in [3].
> 
> How could I contribute my own javascript snippet to onSubmit attribute
> of forms? How can I override this setting?

The problem is that this is no setting and therefore cannot be overwritten.

One solution is to override the default JavaScriptStack of Tapestry and
provide another implementation of the onSubmit handler:
1. copy CoreJavaScriptStack
2. change tapestry.js in array to a modified copy in your project
3. contribute the overridden configuration
public static void
contributeJavaScriptStackSource(MappedConfiguration<String,
JavaScriptStack> configuration)
{
  configuration.overrideInstance(InternalConstants.CORE_STACK_NAME,
MyCoreJavaScriptStack.class);
}

Has anybody a better idea?

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