Friday July 27, 2007
jMaki - Accessing External Services
A jMaki widget in a page can communicate with:
service="data.jsp".This blog entry explains how external services are accessed by jMaki widgets.

This image shows a Web application with multiple pages (Page1, Page2, Page3) where one of the page (Page2) contain at least one jMaki widget. For a BlockList widget, the generated code fragment looks like:
<a:widget name="jmaki.blockList" value="[
{title : 'jMaki Project Home', link : 'https://ajax.dev.java.net',
description : 'Where to go for the latest jMaki.' },
{title : 'jMaki Widgets Home', link : 'https://widgets.dev.java.net',
description : 'The source for the latest jMaki widgets.' },
{title : 'jMaki-Charting Home', link : 'https://jmaki-charting.dev.java.net',
description : 'Enables complex charts rendered on the client in any modern
browser.' }
]" />
This code fragment populates the widget with static data specified in the
value attribute. In order to populate the widget with data from an
external service, such as an RSS feed, the value attribute needs to be replaced
with service="/xhp?id=rss". Let me explain how that works.
If any page consists of a jMaki widget then the jMaki runtime is bundled with
the application. The runtime consists of jmaki.xhp.XmlHttpProxyServlet
class that maps to "/xhp" URL pattern within the application
context. The id specified in the URL, "rss", is configured in a
configuration file named "xhp.json". This file consists of a list
of default external services that can be accessed by the widgets in a page. Each
entry in this file can can be specified using up to 5 different parameters:
So if BlockList widget needs to access the RSS feed, then the code fragment needs to look like:
<a:widget name="jmaki.blockList" service="/xhp?id=rss" />
The corresponding entry in xhp.json is:
{"id": "rss",
"url":"http://weblogs.java.net/blog/ludo/index.rdf",
"xslStyleSheet": "rss.xsl"
}
The tag and the default entry tells the jMaki runtime to fetch the RSS feed
from http://weblogs.java.net/blog/ludo/index.rdf, apply the 'rss.xsl'
stylesheet (that understand the multiple RSS/Atom formats) to the received
response and convert the data into into a common JSON data format of the type
"dataType" : "jMakiRSS". The BlockList widget knows how to convert
jmakiRSS data to its specific data model.
This approach allows all widgets, that take a "value" attribute,
to consume data from external services.
Technorati: jmaki rss services web2.0
Posted by Arun Gupta in web2.0 | Comments[2]
|
|
|
|
Posted by Ludovic Champenois's Blog on July 31, 2007 at 06:09 PM PDT #
Posted by Arun Gupta's Blog on January 01, 2008 at 03:53 PM PST #