6.1. What's This Application Do Anyway?

Let's get the silly terminology out of the way first, shall we? What we're actually creating here is called a mashup. A mashup, as these types of web apps have come to be known, is basically a web site or application that takes content from multiple sources (usually via some sort of public programmatic interface—a remote API, in other words), and integrates it all into a new experience—that is, a new application.

The term mashup might sound a bit silly (it does to me!), but it's the term That's been applied to what is at its core an extremely powerful vision: people provide various services and data over the Internet via a well-defined programmatic interface, and anyone can come along and combine them to create applications. In other words, we're talking about a relatively simple, open, platform-agnostic service-oriented architecture (SOA).

MORE ON SOA

The idea of SOA has been gaining steam over the past few years. Most notably, the concept of web services has been evolving rapidly over that time. However, the meaning of that term has been evolving as well. People now often consider things such as the Yahoo! services, which will be used in this application, to be web services, even though they don't use the full web services stack (that is, SOAP, WS-Security, and all the other specifications that can go along with it).

Whatever line of demarcation you choose to use, the bottom line is that you're developing using a SOA, which means you have loosely coupled components that expose a remote service interface that, usually, is platform- and language-agnostic and can therefore be married together in nearly limitless ways.

The benefits of this approach are numerous. The simple fact that you aren't generally tied to any particular technology or language is a big one. The ease with which updates can be done, assuming the interface doesn't change, is another big one (this is the same reason people love web apps in general). The ability to use all sorts of automated tools to both create and consume services is another (although this Isn't always a good thing, if those tools become a crutch that allows you to not understand what you're doing). Realizing the goal of building your application on top of established standards is another. Reusing existing assets and therefore increasing the speed with which solutions can be delivered is another (some would argue this is the biggest benefit). There are plenty more; these are just some that come to mind immediately.


You've almost certainly heard the term web services before too. Web services are sometimes involved in mashups. However, web services, as most people mean when they use the term, can be pretty complicated beasts! SOAP; Universal Description, Discovery, and Integration (UDDI) directories; Web Services Description Language (WSDL) documents—not to mention a whole host of other specifications—are the types of things you deal with in working with web services. Although there's nothing that says that stuff can't be involved when writing a mashup, typically they aren't. There are other techniques available for writing mashups, as We'll soon see.

Today, the term mashup can also refer to a web app that, by and large, runs within your browser. In fact, for many people, mashup implies a JavaScript-based application that can run locally with no server interaction (aside from loading it in the first place, which is actually optional too) and calling on remote servers. The term mashup has generally come to mean browser-based JavaScript clients aggregating content through public APIs from various companies and vendors to form new applications. These APIs are often referred to as web services, and even though they may not truly be web services in the sense of using the full technology stack—the whole alphabet soup of terms I threw around in the preceding paragraph—they still fulfill the same basic goal as those types of web services. They provide services and function over a network (specifically, the Web), so calling them web services isn't too far-fetched anyway.

Many companies are getting into the API business, including companies You've certainly heard of: Google, Yahoo!, Amazon, and eBay, just to name a few. Google and Yahoo! have led the charge, and Yahoo!, in particular, originated a neat trick that will be central to the application We'll build in this chapter: the dynamic <script> tag trick, or <script> injection trick (it's sometimes referred to both ways). Now with the preliminaries out of the way, Let's go ahead and spell out what this application is going to do:

  • By using a remote service, we will be able to perform a search for businesses given an address or some components of a location. We'll be able to see a list of search results, page through large result sets, and select one to view in more detail, including the address, phone number, web site, and average user ratings.

  • We'll also be able to view a map of the location around the business and be able to zoom in and out of that map.

  • We can save a selected business as a favorite so that we can quickly call up its details later. These favorites will naturally be stored in a local database via Gears.

  • The application will need something like a toolbar at the top, but we've seen that a bunch of times before so Let's see if we can use some of the visual effect functions Ext JS provides to do something a little cooler, roughly emulating the Mac OS doc.

  • The address used for a search can be saved as the default location to save time later, and We'll do this via cookies, just for something different.

Let's kick things off with Figure 6-1, depicting the application as it's seen at startup.

Here you can see that I have some favorites already stored, and the search form is cleared, all ready to receive my search criteria to look up more pizza parlors to feed my face at!

Now Let's have a look at the web services we'll use to pull this off, and look at how we're going to be calling on them.

Figure 6.1. The Local Business Search application as it appears at startup

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.59.95.150