JavaFX - WebServices

JavaFX provides API to perform asynchronous HTTP request and also utilize RESTful webservices. It also provides parsers for XML and JSON data formats.

Related Posts:

HttpRequest class provides way to specify a location (HTTP URL) and transfer data via InputStream and OutputStream.

def httpRequest = HttpRequest {
    location: ""
    method: HttpRequest.GET
    onInput: function(in: {
        try {
            // Read the content from this InputStream
            // Pass the InputStream to parser 
        finally {

The InputStream obtained from HttpRequest can be parsed using PullParser API. It can parse both XML and JSON data type.

def parser = PullParser {
    documentType: PullParser.XML
    input: <InputStream obtained from HttpRequest>
    onEvent: function(event: Event) {
        // Handle events triggered for each node
        // and retrieve the data

Now we can utilize these APIs to enhance the existing Image Viewer sample so as to retrieve the photos dynamically from Flickr. Source code for PhotoPullParser.fx and Photo.fx are copied directly from InterestingPhotos sample.

For Applet mode, click on above image

For standalone mode

There are many samples at JavaFX Samples website which uses HttpRequest and PullParser APIs. You can refer to those source code for more information.



Very cool sample !

Posted by Vaibhav Choudhary on April 14, 2009 at 01:16 PM IST #

i have created a javafx widget which uses rss feed and show the news,
now i want to use it in our website or i want to be embedded with my website.. can you please tell me the procedure in detail how to run widget from my website, please rply

Posted by banita on June 15, 2009 at 08:09 AM IST #

@banita You can refer to this tutorial I have also uploaded the html and jnlp files for reference

Posted by Rakesh Menon on June 15, 2009 at 08:43 AM IST #

Cool sample!!!!!

Posted by Mohammed Sanaulla on June 24, 2009 at 06:57 AM IST #

Could you please check the availability of the Image Viewer sample? I'm getting an error message and an exception: Cannot find cached resource for URL:

also starting in standalone mode doesn't work here. But still you can download the and locally save the jar. Don't know what happens here.

Posted by Maximilian Stempfhuber on July 06, 2009 at 09:43 PM IST #

Follow up:
Java Web Start shows an encapsulated exception: Not in GZIP format
at Source)
at<init>(Unknown Source)
at<init>(Unknown Source)
at Source)
at com.sun.deploy.cache.Cache.downloadResourceToTempFile(Unknown Source)

Posted by Maximilian Stempfhuber on July 06, 2009 at 09:45 PM IST #

@Maximilian Stempfhuber I'm not sure about exact reason, it may be due to network outage. Anyway I have updated the sample to use JavaFX 1.2 runtime.

Posted by Rakesh Menon on July 07, 2009 at 03:08 AM IST #

Por favor me mandan una erl de sun en español gracias soy novato en lo ke respecta a todo esto de la programacion y me gustaria leer sus blogs y participar y capacitarme. Gracias

Posted by leonardo gomez on October 18, 2009 at 02:07 AM IST #

@leonardo gomez Sorry, I'm not aware of any site. For now may be best bet for technical articles.

Posted by Rakesh Menon on October 23, 2009 at 09:27 AM IST #

I'm trying to run this application in eclipse, but i get the following error:

C:\\MyWebProjects\\WebServices\\src\\carousel\\Carousel.fx:152: cannot find symbol
symbol : function enqueue()
location: class

What could that be?

Posted by Dmitry Anosov on November 02, 2009 at 08:09 AM IST #

@Dmitry Anosov Thanks for pointing out. I have not updated the sample source to JavaFX 1.2. The name of method is changed from enqueue() to start(). I'll update the source. You may also refer to sample in doc -

Posted by Rakesh Menon on November 02, 2009 at 09:54 AM IST #

@Dmitry Anosov I have putback the latest source to

Posted by Rakesh Menon on November 02, 2009 at 10:10 AM IST #

Тhanks for your reply, Rakesh. I just couldn't think of any reason for that error.

Posted by Dmitry Anosov on November 02, 2009 at 02:50 PM IST #

Hi Rakesh....
I just want to know abt Google maps support in javafx.. As in i should be able to customize the map.(ie: adding markers,drawing lines etc).. can u please help me...


Posted by rakshith on January 18, 2010 at 12:12 AM IST #

@rakshith There is no Map component as such, but you can implement it by a combination of approach mentioned in below posts..

Posted by Rakesh Menon on April 08, 2010 at 03:31 AM IST #

Good job…
Could you please tell me how can we just change the displayed image when we click on the scaled image in this exemple.
i mean if we have two groups of image, the first one is displayed by default and when we click on the scaled image then we have a new carousel with the new image group.
thanks in advance

Posted by Mohamed on April 10, 2010 at 08:24 PM IST #

@Mohamed You can change the Image-URL of those Thumb images, as done in Carousel.updateImages()

Posted by Rakesh Menon on April 12, 2010 at 03:02 AM IST #

Post a Comment:
Comments are closed for this entry.

The views expressed on this blog are my own and do not necessarily reflect that of my organization


« February 2016