You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Janko Muzykant <um...@gmail.com> on 2009/08/26 10:02:30 UTC

actionliks and XHR response problem

hi guys,

this is quite strange, but i noticed that actionlinks "sometimes" return
unexpected results. i have a page containing lot of actionlinks
changing/updating certain elements via ajax request/response. from java side
it's nothing more than just returning a block or MultiZoneUpdate as a result
of action. sounds simple. surprisingly it's enough to wait a few minutes,
click the same (working correctly so far) action link to get an error saying
that Tapestry was not expecting a Block in result but a String rather.

to be sure, I changed the way how I return a block, detecting first if i'm
really answering to ajax request:

  return request.isXHR() ? myBlock : null;

and guess what. i started receiving whole the page (instead of blocks) in
ajax responses! that obviously resulted in blackbird message "reply is
null".

again, problem is not simply reproducible but i noticed it's enough to wait
a few minutes to observe this strange behavior. it's also enough to click
the link again to get a correct response. for sure it has nothing to do with
my session expiration (set to 30 minutes) and I have no other "timeouting"
mechanisms.

could you please give me a hint what may be wrong here?

thanks,
m.

-- 
View this message in context: http://www.nabble.com/actionliks-and-XHR-response-problem-tp25148353p25148353.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: actionliks and XHR response problem

Posted by Janko Muzykant <um...@gmail.com>.
i did a few more investigations and there is one thing i can't understand.
this is how problematic requests look like:

Host:	localhost:8080
User-Agent: Mozilla/5.0 (X11; U; Linux i686; pl; rv:1.9.1.1) Gecko/20090715
Firefox/3.5.1
Accept: text/javascript, text/html, application/xml, text/xml, */*
Accept-Language: pl,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-2,utf-8;q=0.7,*;q=0.7
Keep-Alive:	300
Connection: keep-alive
X-Requested-With: XMLHttpRequest
X-Prototype-Version: 1.6.1_rc2
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Referer: http://localhost:8080/my-webapp/identity
Content-Length:	0
Cookie: blackbird={"pos": 1, "size": 0, "load": null};
JSESSIONID=1k1mtrom1uxhy

and following is the answer:

X-Tapestry-ErrorMessage: A component event handler method returned the value
Block[reportBlock within Identity, at
classpath:org/myapp/tapestry/pages/Identity.tml, line 172]. Return type
org.apache.tapestry5.internal.structure.BlockImpl can not be handled.
Configured return types are java.lang.Class, java.lang.String, java.net.URL,
org.apache.tapestry5.Link, org.apache.tapestry5.StreamResponse,
org.apache.tapestry5.runtime.Component.
Content-Type: text/html; charset=utf-8
Content-Encoding: gzip
Transfer-Encoding: chunked
Server: Jetty(6.1.12rc1)


the question is, how it is possible that T5.1.0.5 rejects Block as response
to ajax request? 'X-Requested-With" header confirms that it was XHR for
sure.

cheers,
m.



Janko Muzykant wrote:
> 
> hi guys,
> 
> this is quite strange, but i noticed that actionlinks "sometimes" return
> unexpected results. i have a page containing lot of actionlinks
> changing/updating certain elements via ajax request/response. from java
> side it's nothing more than just returning a block or MultiZoneUpdate as a
> result of action. sounds simple. surprisingly it's enough to wait a few
> minutes, click the same (working correctly so far) action link to get an
> error saying that Tapestry was not expecting a Block in result but a
> String rather.
> 
> to be sure, I changed the way how I return a block, detecting first if i'm
> really answering to ajax request:
> 
>   return request.isXHR() ? myBlock : null;
> 
> and guess what. i started receiving whole the page (instead of blocks) in
> ajax responses! that obviously resulted in blackbird message "reply is
> null".
> 
> again, problem is not simply reproducible but i noticed it's enough to
> wait a few minutes to observe this strange behavior. it's also enough to
> click the link again to get a correct response. for sure it has nothing to
> do with my session expiration (set to 30 minutes) and I have no other
> "timeouting" mechanisms.
> 
> could you please give me a hint what may be wrong here?
> 
> thanks,
> m.
> 
> 

-- 
View this message in context: http://www.nabble.com/actionliks-and-XHR-response-problem-tp25148353p25167521.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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