Java Reference
In-Depth Information
updated with the latest weather data received from the GeoNames weather ser-
vice. We'll examine the data structure and request process later in the chapter.
The entire weather request sequence is started when you enter a valid ZIP code
and press the Return key. The weather widget can be considered a mashup appli-
cation, as it uses data from both Yahoo! and GeoNames. Let's take a closer look
at this process now.
A Mashup Application
The weather widget first requests location data from Yahoo! Web Services with the
ZIP code provided, then it makes a request to the GeoNames weather service with
the returned location data. This four-step process is illustrated in Figure 10.5.
Ya h o o !
Web Services
GeoNames
Web Services
2
JSON location
results including:
CITY, STATE,
LONGITUDE,
and LATITUDE
3
Request weather
by location
(LNG & LAT)
4
JSON
weather results
1
Send City
Search with
ZIP code
Weather
Widget
Figure 10.5
The Mashup Data Flow
As data is received, and the bound data structure values are updated, the widget's
GUI is automatically updated to reflect the new data.
Using Yahoo! Web Services
Because the GeoNames service requires location data in terms of longitude and
latitude to return local weather conditions, we use Yahoo!'s city search feature to
get this data. The request is made, including the ZIP code entered, with the fol-
lowing URL in the JavaFX code:
 
Search WWH ::




Custom Search