Setup Primefaces Website with Google Maps (Tutorial and Example)

simple

January 17, 2016

Java

To setup a JSF Website using Primefaces with Google Maps not much time is necessary. As en environment this tutorial requires you to use a current Java Development Kit JDK, the Netbeans IDE and a working Tomcat Installation.

Prerequisite
If there is no JDK installed on your System you must first download it for the appropriate platform.

http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

You also need a current installation of Netbeans which you can download from:

https://netbeans.org/downloads/

Last but not least we also need an application server and choose therefor Tomcat, which you can find here:

http://tomcat.apache.org/download-80.cgi

Tutorial
Step 1. – Integrate Primefaces

Create a new project called “google-maps” or any other name that you prefer. The type of the application should be a Java Maven Web Application.

  1. Now open the folder “Project Files” and edit the “pom.xml”. Just put the dependencyManagement tag under the packaging tag:
  2. Add the necessary dependencies to Java EE and Primefaces in the dependency tag:
  3. The last change you need to do to the pom.xml is to add the primefaces repository to the end just before the project tag:
  4. Go to “Web Pages” folder again and open the underlying subfolder “WEB-INF” (if it does not exist create it). In the “WEB-INF” folder create a new XML file called “web.xml”. Replace the content of the file with the following:
  5. Go to “Web Pages” folder and remove the index.html file. Now create an index.xhtml file replacing the content with the following:

Step 2. – Add a View and a DefaultMapModel

  1. In the next step we want to show markers on the Google Map. To achieve that we just create a new Java Class called GoogleMapView.java in our package path e.g. com.company.project and add the following code:
  2. Now we need to set the model as a reference for the google map widget by adding the parameter model=”#{googleMapView.mapModel}” to it.

References

Related Posts

Prerequisites for a Java Web Application

simple

January 19, 2016

Java

Prerequisites for a Java Web Application If there is no JDK installed on your System you must first download it for the appropriate platform. http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html You also need a current installation of Netbeans which you can download from: https://netbeans.org/downloads/ Last but not least we also need an application server and choose therefor Tomcat, which you […]

Read More

Eclipse: convert upper case text to lower case and viceversa with a simple shortcut

simple

November 7, 2012

Development, Java

No Comment

This is just a quick post to share these 2 little shortcuts to convert text from lower case to uppercase and vice-versa in Eclipse. Lower case: CTRL+SHIFT+Y (CMD+SHIFT+Y on Mac OS X) Upper case: CTRL+SHIFT+X (CMD+SHIFT+X on Mac OS X) Camel case: Anyone knows a shortcut? You can select one or more characters to convert.

Read More

RSS RSS Feed

  • An error has occurred, which probably means the feed is down. Try again later.

Categories

Tags