JavaFX 1.2 provides new APIs to handle RSS and ATOM feeds. RssTask and AtomTask parses the feeds and provide the content as JavaFX objects. It can also be configured to provide updates on regular intervals.

RssTask parses the feed and provides the content as Channel and Item objects. These objects in-turn provides other information such as image, link, title, category, date etc.

Similarly AtomTask parses feed and provides Feed and Entry objects. These objects in-turn provides information such as author, category, link, logo, contributors etc.

News ticker using Yahoo RSS feed is given below.

For Applet mode, click on above image

For standalone mode

RssTask Usage:

var rssTask = RssTask {
    
    location: "http://rss.news.yahoo.com/rss/world"
    interval: 300s

    onException: function(e) {
        e.printStackTrace();
    }

    onChannel: function(channel) {
        println("{channel.title}");
    }

    onItem: function(item) {
        println("{item.title}");
    }
}
rssTask.start();

AtomTask Usage:

var atomTask = AtomTask {
    
    location: "http://jfxstudio.wordpress.com/feed/atom"
    interval: 300s

    onException: function(e) {
        e.printStackTrace();
    }

    onFeed: function(feed) {
        println("{feed.title}");
    }

    onEntry: function(entry) {
        println("{entry.title}");        
    }
}
atomTask.start();

JavaFX Tweeter sample demonstrates use of both RssTask and HttpRequest.

Source:



Comments:

Too cool :)

Posted by Vaibhav Choudhary on June 18, 2009 at 06:27 PM IST #

thanks a lot. Very informative and unique post.

Posted by Arabica` on October 02, 2009 at 01:51 AM IST #

@Arabica` Glad! Thanks!

Posted by Rakesh Menon on October 23, 2009 at 06:22 PM IST #

Post a Comment:
  • HTML Syntax: NOT allowed

This blog copyright 2009 by Rakesh Menon