Java Reference
In-Depth Information
REST-style development
Part of the main features of a rich client platform is its ability to connect to remote servers in
order to retrieve data. Similar to the popular browser-based XmlHttpRequest object used
to drive AJAX applications, JavaFX exposes the HttpRequest object, which lets developers
connect asynchronously to web servers to exchange data over HTTP. This chapter shows you
how to connect, retrieve data, and handle communication events during different phases of
data exchange. You will also explore how to post data back to the server.
As a modern, rich application platform, JavaFX provides full support for popular data exchange
and data representation formats, such as XML. Out-of-the-box, the JavaFX parser API can
handle pure XML and specific XML-based formats, such as RSS and Atom. Additionally, JavaFX
developers can leverage the wildly popular JavaScript-based data format named JSON, used
extensively for data exchange on the Web. In this chapter, we look at how to access and parse
XML-encoded and JSON-encoded data to build web-enabled JavaFX applications.
RSS and Atom are two of the most common data feed formats used around the Web for one-way
content syndication. JavaFX provides full support of these formats through its Feed API. Later in
this chapter, we will explore how to use JavaFX in order to build RSS and Atom clients.
Data visualization
In addition to accessing and manipulating data in JavaFX, as of version 1.2, you also have the
ability to visualize your data using the Chart API. Built in JavaFX, you will find several different
types of chart components, including area, bar, bubble, bar, bar 3D, line, pie, pie 3D, and
scatter chart. This chapter shows you how to create and integrate charting as part of your
JavaFX application.
Saving data locally with the Storage API
Although your JavaFX applications are expected to be able to connect to remote servers in order
to persist or retrieve data, it is, however, also desirable to have the ability to save data locally on
the user's device. Say, for instance, you have deployed a game. You may want to facilitate your
gamers to save game settings, scores, and states locally, without having to connect to a server.
This recipe shows you how to use the Storage API of JavaFX to save data on local devices.
Getting ready
The concepts presented here rely on classes found in the Storage API located in the javafx.
io package. Prior to using the API, it is advisable that you have a working understanding of
the low-level Java IO API classes used for data persistence and retrieval.
Search WWH ::

Custom Search