Mannar maps with application

It has been a work in progress for Mannar to get google maps working for the application. Problem statement is, mannar would want to locate the address in google maps. Google maps is an open source API that can be used by getting a API key from google. No worries, it is all free. After all one writes their life to google since it is free. At a stock price of $500 and no one else to compete the technology and community give-aways it is fair to say no other API's be considered :).
So first thing to get google maps working for you, get their AJAX API key working. To sign up for one goto http://code.google.com/apis/maps/signup.html. For this application I signed up for two keys one for testing locally and the other one on the production server.
There are also some good examples from google to do a basic map hook up to your web-site. We will be re-using one of this example and tailor it for Mannar web application. The usual actors for this module, a struts action, a struts form, since this involves some validation, we will be touching a bit of struts validation framework and our business class.
So here is the 10,000 feet struts flow for this module









From Sathish Blog



Here is the screen flow for maps flow.










From Sathish Blog


As seen in above image we have the state information populated when page loads. Here is a quick solution for loading something in struts during startup:










From Sathish Blog


Digester plugin is an utility plugin from struts, as shown above we have two xml files that are playing an important role, here are the xml files.










From Sathish Blog











From Sathish Blog


Application uses the label value bean as the state information is a more geared as name value pairs. Display information as shown in maps screen is the states drop box and corresponding expanded state name is used to process the information. One other thing to keep in mind is; since we are using digester api for xml parsing, ensure that the name value pair name in states xml matches object-create-value in lvb_digester_rules.xml file.
Alright we got a little bit side tracked there, further we would want to parse latitude and longitude value for the given address. This value will be fed to the JSP for displaying google map marker.










From Sathish Blog











From Sathish Blog











From Sathish Blog


Now finally to the action classes:










From Sathish Blog


struts form is










From Sathish Blog











From Sathish Blog


Never forget the struts-config file










From Sathish Blog


Validator definition is










From Sathish Blog


Am tired man, but one final screen; here is the validator xml file.










From Sathish Blog


If you like the above example entire code base is hosted in google. Please feel free to review and the best way to improve it.