Home > Articles > Software Development & Management

  • Print
  • + Share This
This chapter is from the book

Implementing a Simple Mashup

This section demonstrates the application of concepts discussed in this chapter to create a simple presentation-oriented mashup. Apart from a local service platform, the sources used for the mashup are publicly available and provide either a service API, an RSS data feed, or a dynamic script feed. This section does not discuss issues such as application keys, security, and governance for this mashup; these topics are discussed in depth in later chapters.

For the sake of complete coverage of the mashup domains discussed, the mashup will make service calls and retrieve data from external sites as well as a local service platform that operates around the model illustrated in Figure 1.11.

Figure 1.11

Figure 1.11 Services platform architecture

Figure 1.11 illustrates a service platform that uses only a small number of primary components to process service and resource requests. The platform uses the Representational State Transfer (REST) approach (to be discussed later) for service and resource request/responses. The service platform provides access to services and uses a simple resource framework to create, retrieve, update, and delete resources.

The application (shown in Listing 1.8 and in Figure 1.12) allows users to view disparate data that might be available in a typical enterprise. The data is presented in a portal-like manner to simplify the layout and UI-management code. The application integrates a list of corporate documents, a map feed, an RSS feed, a calendar gadget, a Twitter counter chicklet, and a Twitter archive list delivered as RSS.

Figure 1.12

Figure 1.12 Presentation-oriented mashup example

Listing 1.8. Presentation-Oriented Mashup Using Aggregated UI Artifacts

<!-- Include Google Maps Javascript Library -->
<script type="text/javascript" src="https://maps.google.com/maps?file=api&v=1& key=

<script type="text/javascript">

Figure 1.12 illustrates the final result of the presentation-oriented mashup example discussed in this section.

The load function in Listing 1.9 retrieves a hard-coded Google map and applies it to the map div element in the HTML DOM.

Listing 1.9. Applying a Google Map to a Web Page

  function load()
    if (GBrowserIsCompatible())
      // create map component in div with the id = "map"
      var map = new GMap2(document.getElementById("map"));
      // create map components components
      map.addControl(new GSmallMapControl());
      map.addControl(new GMapTypeControl());
      // create center point when map is displayed
      map.setCenter(new GLatLng(37.4419, -122.1419), 13);
                         "<b>Your Company Here</b>");
      // re-open the info balloon if they close it
      var point = new GLatLng(37.395746, -121.952234);
      map.addOverlay(createMarker(point, 1));

  function createMarker(point, number)
    var marker = new GMarker(point);
    // create clickable point with title for address
    GEvent.addListener(marker, "click", function()
       marker.openInfoWindowHtml("<b>Your Company Here</b>");
    return marker;

  function retrieveExternalData()
      var script = document.createElement("script");
      script.src =
      script.type = 'text/javascript';

<body onload="load()">

In the example shown in Listing 1.10 a div element is added to contain a list of corporate documents retrieved from a Google Docs account using dynamic script.

Listing 1.10. Dynamic Script to Show a List of Documents

    <!-- div to hold documents -->
    <div id="docs"
         style="border-style:ridge; position: absolute;
            left: 10px; top: 10px; width:200px; height:930px">
    <script src="https://gmodules.com/ig/ifr?

Listing 1.11 illustrates a div element that will hold the results from the Google map retrieval.

Listing 1.11. Element to Contain a Google Map

    <div id="map"
         style="border-style:ridge; position: absolute;
         left: 220px; top: 10px; width:400px; height:300px">

In Listing 1.12 a div element is added to contain an RSS feed using dynamic script.

Listing 1.12. Element to Contain an RSS Feed

    <!-- div to hold RSS feed -->
    <div id="feed"
         style="border-style:ridge; position: absolute;
         left: 630px; top: 10px; width:400px; height:300px">
    <script src="https://gmodules.com/ig/ifr?

Listing 1.13 shows a div element to contain a Google calendar retrieved using a JavaScript badge.

Listing 1.13. Google Calendar Element

    <!-- div to hold calendar -->
    <div id="calendar"
         style="border-style:ridge; position: absolute;
         left: 220px; top: 320px; width:810px; height:620px">
    <iframe src="https://www.google.com/calendar/embed?
      style="border: 0"
      width="800" height="600" frameborder="0" scrolling="no">

Shown in Listing 1.14 is a div element to contain the Twitter counter chicklet.

Listing 1.14. A div Element to Contain a Twitter Chicklet

    <!-- div to hold the Twitter counter chicklet -->
    <div id="chicklet"
         style="border-style:ridge; position: absolute;
         left: 1040px; top: 10px; width:200px; height:40px">
    <a href="http://twittercounter.com/?username=jhanson583"
       title="TwitterCounter for @jhanson583"><img src="https://twittercounter.com/
for @jhanson583" /></a>

Listing 1.15 illustrates the div element to contain the Twitter RSS feed using dynamic script.

Listing 1.15. Twitter RSS Feed div Element

    <!-- div to hold twitter feed -->
    <div id="ufbadge"
         style="border-style:ridge; position: absolute;
         left: 1040px; top: 60px; width:200px; height:880px">
      <script src="https://pipes.yahoo.com/js/listbadge.js">

In Listing 1.16 I add the div element to contain the local RSS feed using dynamic script.

Listing 1.16. RSS Feed Element

    <!-- div to hold local RSS feed -->
    <div id="localfeed"
         style="border-style:ridge; position: absolute;
         left: 10px; top: 950px; width:1210px; height:200px">
      <script src="https://localhost:8080/mashups/js/rssbadge.js">

The mashup in the preceding example illustrates many different techniques and technologies as applied to a simple presentation-oriented mashup. In the next chapter I discuss the preparations that need to be made before building an enterprise mashup.

  • + Share This
  • 🔖 Save To Your Account