I wish it were so easy. BlockImpl toString() prints out useful information such as where the block was defined in the template but it doesn't render. The normal route is to use render() which requires a RenderQueue. At that point the were using internal APIs.

Thanks for the suggestion.

Chuck

Alex Kotchnev wrote:
Chuck,
   I think you already know more than I do on the subject, but here's what
came to mind :

1. The documentation of Block (
http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/Block.html)
indicates that they should be easily convertible to Strings (e.g. via
BlockImpl.toString()

2. It should be pretty easy to build a JSONObject (
http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/json/JSONObject.html),
and add a key and put the value as the stringified block. Then , have an
event handler that returns the JSONObject and have the event handler
triggered by an JS function or something similar.

   Once again, I'm not an expert on this, maybe one of the T5 devs can chime
if I'm sputtering complete garbage.

Regards,

Alex K

On Tue, May 11, 2010 at 12:57 AM, Chuck Kring <cjkr...@pacbell.net> wrote:

Hi Alex,

No quite.  Currently, you can return a Block to refresh a zone or a JSON
array to send data to a custom handler on the client.  My project has a
number of dashboards and I use JSON data to refresh image tags to make
'real-time' charts and icons that automatically update.   My handler
replaces the <img> src tags when it receives the response.

I'd like to use the same framework to replace div bodies - essentially
zones.  In trying to get this to work I looked at the implementation of
MultiZoneUpdate and I think that code could easily be reused to allow
rendered blocks to be included in JSON responses.    That would open up
Tapestry 5 to developers creating applications like my dashboard that don't
lend themselves to Zones.
If you know a route to render a Block as part of a JSON XHR response I'd
really appreciate a pointer.   Otherwise I'm trying to understand if I
should file a Jira suggesting this as an enhancement.

Thanks.

Chuck


Alex Kotchnev wrote:

Chuck,
 it is my understanding that today, when you return a Block in response to
an ajax request, the contents of that block do get serialized into a JSON
structure which is then parsed on the client. Isn't that what you need ?

Regards,

Alex Kotchnev

On Mon, May 10, 2010 at 2:18 AM, Chuck Kring <cjkr...@pacbell.net> wrote:



Hi guys,

My application uses Ajax extensively  to provide a dashboard-like
functionality.  I use a rather small Javascript library that contains a
poller and then updates img src= fields for every registered components.
This works very well for dashboard pages that have charts and status
icons.

I'd love to be able to put zones in the page and call the ZoneUpdater
from
my Javascript loop.   This seems easy because it's essentially the
behavior
of the MultiZoneUpdate.

My question is shouldn't there be a coercer that allows a rendered block
or
component to be added to a JSON return?
Chuck Kring

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






Reply via email to