Wednesday, November 21, 2007

Yahoo maps with csv and ws url datacontrol

In this example I have a Yahoo maps page where the markers on the maps comes from a csv file which contains our companu offices and it is enriched by a rest web service to get the longitude and latitude coordinates of these locations. The csv and rest webservice are adf url datacontrols. In this example I only have to make a pagedef with the operations and iterators on these datacontrols. The next step is backing bean for calling the operations and collecting the data for the yahoo maps page. Here is the result.

Let's look how we create the adf url datacontrols. For the coordinates I use a web service from geonames. I can call an url with parameters in a normal browser and it gives me a result xml.

I put the parameters of the geonames ws in the source attribute where the values of the parameters are changed to ##abc## in this case ?placename=##place##&postalcode=.....

This datacontrol needs a xsd for the xml output. Geonames don't supply the xsd so we need to generate this with altova xmlspy. If we are ready then we can create a page where we drag loaddata method from the datacontrol, I use an adf parameter form. Then we have to drag the result from the datacontrol to the page ( read only table)

Now we can make an url datacontrol on the csv file with the addresses. the file looks like this


Ordina Headquarters;+ 31 30 66 37 000;Ringwade 1;3439;LM;Nieuwegein

You need to have a web server to put the csv on. You can use the embedded oc4j for this.

when you create a page and drag the csv method from the datacontrol as parameter form and the result as read only table, then the result can look like this.

If everything works fine then we are ready to make the maps page and his pagedef. We create the page and then go to the pagedef . Here we put in the methodIterator and the accessorIterator of the two other demo pages. We copy the two methodActions too and we add two table bindings on these method and acessoriterators.

Create the bean and add the bean definition in the afdc-config. In this bean we put in a method which gathers the required data for the markers on the yahoo maps page.

The last step is to put in the yahoo maps javascript in the page and fill the javascript variables with the bean getters

We are ready to test it. This is a jdeveloper 11g technical preview 2 example and this project has some problems to execute the geonames webservice twice in a loop.

Here you can download the example

No comments:

Post a Comment