jMaki - Accessing External ServicesA jMaki widget in a page can communicate with:
This blog entry explains how external services are accessed by jMaki widgets. Cannot resolve external resource into attachment. 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.java.net', description : 'Where to go for the latest jMaki.' }, {title : 'jMaki Widgets Home', link : 'https://widgets.java.net', description : 'The source for the latest jMaki widgets.' }, {title : 'jMaki-Charting Home', link : 'https://jmaki-charting.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-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-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. 日本語翻訳: Kana |