You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Tobias Wehrum <Le...@dragonlab.de> on 2008/08/22 10:22:19 UTC
[T5] AJAX Tapestry Forms?
Hi there,
as the title suggests, I want to submit a form without refreshing the
page. I don't even want to refresh a zone, but I need to specify a
javascript function handling the return value of my function.
While this is quite easy with normal HTML forms, I don't want to break
with Tapestry - especially with the validation, the automatic object
updating and a couple of form components, but unfortunatly I have no
clue where to start with and don't even know if it is possible.
Any thoughts on this?
(By the way, what I want to do is to put a Tapestry form in a Lightbox -
which should just just close after the submit.)
- Tobias
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: [T5] AJAX Tapestry Forms? / strange behavior of AjaxComponentEventRequestHandler
Posted by Tobias Wehrum <Le...@dragonlab.de>.
CORRECTION:
"I spent some time with the debugger and it seems that
104: if (callback.isAborted()) return;
just doesn't get called"
would be
"I spent some time with the debugger and it seems that in
104: if (callback.isAborted()) return;
callback.aborted == false"
Tobias Wehrum schrieb:
> And again hi everyone,
>
> I managed to ajaxify my forms - but I have a problem left with the
> return value of my onSubmit function.
>
> First to explain, to make AJAX possible, I use a slightly modified
> Tapestry.linkZone:
>
> --------------------------------------------------------------------------------------------------
>
> function ajaxifyForm(element)
> {
> element = $(element); var successHandler = function(transport)
> {
> // outputting transport for debug reasons
> };
> if (element.tagName == "FORM")
> {
> Tapestry.getFormEventManager(element).preventSubmission = true;
> element.observe(Tapestry.FORM_PROCESS_SUBMIT_EVENT, function()
> {
> element.request({ onSuccess : successHandler, onFailure:
> Tapestry.ajaxFailureHandler });
> });
> }
> --------------------------------------------------------------------------------------------------
>
>
> So far, it works quite nice, but transport.responseJSON was empty
> despite my onSubmit returning a JSONObject.
>
> Looking at the Firebug Console, I find this for the POST response:
> {"testkey":"testvalue"}{}
> Obviously this isn't correct JSON - it adds a {} to my clean response.
>
> Looking through the tapestry-core, I found
> org.apache.tapestry5.internal.services.AjaxComponentEventRequestHandler,
> and in line 106 a new JSONObject is created (which would be {}). After
> i remove this (and the following) line, the response is just
> {"testkey":"testvalue"} - as it should be.
>
> I spent some time with the debugger and it seems that
> 104: if (callback.isAborted()) return;
> just doesn't get called, despite a ComponentResultProcessorWrapper
> ([...].internal.services, too) gets to handle a result without any
> IOException. But strange, after the method in triggerContextEvent in
> 92 returns, the callback.aborted is false.
>
> Anybody's got a clue what's going on here - or, even better, a solution?
>
> - Tobias
>
> Tobias Wehrum schrieb:
>> Hi there,
>>
>> as the title suggests, I want to submit a form without refreshing the
>> page. I don't even want to refresh a zone, but I need to specify a
>> javascript function handling the return value of my function.
>> While this is quite easy with normal HTML forms, I don't want to
>> break with Tapestry - especially with the validation, the automatic
>> object updating and a couple of form components, but unfortunatly I
>> have no clue where to start with and don't even know if it is possible.
>>
>> Any thoughts on this?
>>
>> (By the way, what I want to do is to put a Tapestry form in a
>> Lightbox - which should just just close after the submit.)
>>
>> - Tobias
>>
>>
>> ---------------------------------------------------------------------
>> 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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: [T5] AJAX Tapestry Forms? / strange behavior of AjaxComponentEventRequestHandler
Posted by Tobias Wehrum <Le...@dragonlab.de>.
And again hi everyone,
I managed to ajaxify my forms - but I have a problem left with the
return value of my onSubmit function.
First to explain, to make AJAX possible, I use a slightly modified
Tapestry.linkZone:
--------------------------------------------------------------------------------------------------
function ajaxifyForm(element)
{
element = $(element);
var successHandler = function(transport)
{
// outputting transport for debug reasons
};
if (element.tagName == "FORM")
{
Tapestry.getFormEventManager(element).preventSubmission = true;
element.observe(Tapestry.FORM_PROCESS_SUBMIT_EVENT, function()
{
element.request({ onSuccess : successHandler, onFailure:
Tapestry.ajaxFailureHandler });
});
}
--------------------------------------------------------------------------------------------------
So far, it works quite nice, but transport.responseJSON was empty
despite my onSubmit returning a JSONObject.
Looking at the Firebug Console, I find this for the POST response:
{"testkey":"testvalue"}{}
Obviously this isn't correct JSON - it adds a {} to my clean response.
Looking through the tapestry-core, I found
org.apache.tapestry5.internal.services.AjaxComponentEventRequestHandler,
and in line 106 a new JSONObject is created (which would be {}). After i
remove this (and the following) line, the response is just
{"testkey":"testvalue"} - as it should be.
I spent some time with the debugger and it seems that
104: if (callback.isAborted()) return;
just doesn't get called, despite a ComponentResultProcessorWrapper
([...].internal.services, too) gets to handle a result without any
IOException. But strange, after the method in triggerContextEvent in 92
returns, the callback.aborted is false.
Anybody's got a clue what's going on here - or, even better, a solution?
- Tobias
Tobias Wehrum schrieb:
> Hi there,
>
> as the title suggests, I want to submit a form without refreshing the
> page. I don't even want to refresh a zone, but I need to specify a
> javascript function handling the return value of my function.
> While this is quite easy with normal HTML forms, I don't want to break
> with Tapestry - especially with the validation, the automatic object
> updating and a couple of form components, but unfortunatly I have no
> clue where to start with and don't even know if it is possible.
>
> Any thoughts on this?
>
> (By the way, what I want to do is to put a Tapestry form in a Lightbox
> - which should just just close after the submit.)
>
> - Tobias
>
>
> ---------------------------------------------------------------------
> 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