Liferay 6.0, OpenSocial and Gadgets - Part 2
Company Blogs August 22, 2010 By Barrie Selack Staff
This is the second part of a series of blogs and wiki articles on using gadgets in Liferay. In the blog we'll look at a gadget in action and in the associated wiki post we'll breakdown the gadget, as well as have downloadable source code for you to try out
In the first post in the series, we talked about how to deploy a gadget. This time we'll build a gadget that will call a web service.
The web service we are using is one at GeoNames (www.geonames.org/export/ajax-postalcode-autocomplete.html)
If we fill in the data with a zip code of 91789 and press the Get Location we'll see the following. Normally for the US we''ll only get one result as that's how postal codes are set up. But for other countries we may get multiple results.
Note that by default it will return up to 10 results. But we may need more. So the gadget has a configuration to set the max rows to return. We can set this higher if we need to get more results. The maxrows setting is part of your gadget definition and automatically becomes a configuration option in Liferay through the OpenSocial portlet. No programming necessary!
So after configuring it to return up to 25 rows, we see that there are more than 10 results.
The web service returns more items than we are using, so if you download the gadget and read about the GeoNames web service, you can add more items to display to the user (such as latitude and longitude).
I hope the blog and wiki article and source are helpful for you. Thanks for reading!