Difference between revisions of "Feeds integration"
Jump to navigation
Jump to search
Line 13: | Line 13: | ||
===How to=== | ===How to=== | ||
To use the Google AJAX API | To use the Google AJAX API, just reuse the following code and adapt the red parts with your configuration: | ||
<code> | <code> | ||
<script src="<nowiki>http://www.google.com/jsapi</nowiki>">&#160;</script> | |||
<script src="http://www.google.com/jsapi">&#160;</script> | |||
<script> | <script> | ||
google.load("feeds", "1"); | google.load("feeds", "1"); | ||
function | function initialize() | ||
{ | { | ||
var feedControl = new google.feeds.FeedControl(); | var feedControl = new google.feeds.FeedControl(); | ||
feedControl.addFeed("http://url/of/the/feed/", "Feed name"); | feedControl.addFeed("<span style="color:red"><nowiki>http://url/of/the/feed/</nowiki></span> ", "<span style="color:red">Feed name</span>"); | ||
feedControl.setNumEntries(6); | feedControl.setNumEntries(<span style="color:red">6</span>); | ||
feedControl.draw(document.getElementById("feedControl")); | feedControl.draw(document.getElementById("feedControl")); | ||
} | } | ||
google.setOnLoadCallback( | google.setOnLoadCallback(initialize); | ||
</script> | </script> | ||
</code> | </code> |
Revision as of 15:20, 2 February 2009
Possible solutions[edit]
Google AJAX API[edit]
Pros[edit]
- Very simple to implement and to reuse.
Cons[edit]
- Google Terms of use : [1]
How to[edit]
To use the Google AJAX API, just reuse the following code and adapt the red parts with your configuration:
<script src="http://www.google.com/jsapi"> </script>
<script>
google.load("feeds", "1");
function initialize()
{
var feedControl = new google.feeds.FeedControl();
feedControl.addFeed("http://url/of/the/feed/ ", "Feed name");
feedControl.setNumEntries(6);
feedControl.draw(document.getElementById("feedControl"));
}
google.setOnLoadCallback(initialize);
</script>
Remarks:[edit]
- The first script element should not be minimized. To avoid the auto-minimization from JSF please write like it is on the previous code.
- The url of the feed should be access from a backing bean with either
<h:outputText value="#{MyBackingBean.feedUrl}"/>
or replace the url with
document.getElementById("rssFeedUrl").value
and add in your jsp
<h:inputHidden id="rssFeedUrl" value="#{BlogBean.rssFeedUrl}"></h:inputHidden>
- The Google AJAX Feed API might be used with a Google AJAX key [2]. This key is defined for one server (that means one key is needed for dev, qa, demo, live, ..., servers). The usefulness of that key is described here [3]. If you want to use it, add it as parameter in the url source of the first script
<script src="http://www.google.com/jsapi?key=your-key"> </script>
- You can easily add additional feeds to your feedControl:
feedControl.addFeed("http://url/of/second/feed/", "Second Feed name");
feedControl.addFeed("http://url/of/third/feed/", "ThirdFeed name");
...