Wie der Titel schon sagt versuche ich grade Google Map bei mir unter Hilfenahme von der JSP Tag Libary (lamatek) zum laufen zu bringen. Das ganze sollte in einer myFaces Umgebung mit Tomcat laufen. Es funktioniert auch alles einwandfrei ausser das EventHandling, hierbei bringe ich es einfach nicht zusammen dass der entsprechende Controller aufgerufen wird.
**EDIT**
Bzw kennt jemand eine andere Lösung mit welcher ich Google Map integrieren kann und eben diese mit Koordinaten versorgen kann (Stichwort jMaki?)
Hier mal alle wichtigen Dinge:
web.xml
faces-config
jsp
controller:
**EDIT**
Bzw kennt jemand eine andere Lösung mit welcher ich Google Map integrieren kann und eben diese mit Koordinaten versorgen kann (Stichwort jMaki?)
Hier mal alle wichtigen Dinge:
web.xml
Code:
<?xml version="1.0"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<description>MyProject web.xml</description>
<context-param>
<description>Comma separated list of URIs of (additional) faces config files.
(e.g. /WEB-INF/my-config.xml)
See JSF 1.0 PRD2, 10.3.2
Attention: You do not need to put /WEB-INF/faces-config.xml in here.
</description>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/examples-config.xml</param-value>
</context-param>
<context-param>
<description>State saving method: "client" or "server" (= default)
See JSF Specification 2.5.3</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<description>Only applicable if state saving method is "server" (= default).
Defines the amount (default = 20) of the latest views are stored in session.</description>
<param-name>org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION</param-name>
<param-value>20</param-value>
</context-param>
<context-param>
<description>Only applicable if state saving method is "server" (= default).
If true (default) the state will be serialized to a byte stream before it
is written to the session.
If false the state will not be serialized to a byte stream.</description>
<param-name>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description>Only applicable if state saving method is "server" (= default) and if
org.apache.myfaces.SERIALIZE_STATE_IN_SESSION is true (= default)
If true (default) the serialized state will be compressed before it
is written to the session. If false the state will not be compressed.</description>
<param-name>org.apache.myfaces.COMPRESS_STATE_IN_SESSION</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description>This parameter tells MyFaces if javascript code should be allowed in the
rendered HTML output.
If javascript is allowed, command_link anchors will have javascript code
that submits the corresponding form.
If javascript is not allowed, the state saving info and nested parameters
will be added as url parameters.
Default: "true"</description>
<param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<description>If true, rendered HTML code will be formatted, so that it is "human readable".
i.e. additional line separators and whitespace will be written, that do not
influence the HTML code.
Default: "true"</description>
<param-name>org.apache.myfaces.PRETTY_HTML</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description>If true, a javascript function will be rendered that is able to restore the
former vertical scroll on every request. Convenient feature if you have pages
with long lists and you do not want the browser page to always jump to the top
if you trigger a link or button action that stays on the same page.
Default: "false"</description>
<param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description>Used for encrypting view state. Only relevant for client side
state saving. See MyFaces wiki/web site documentation for instructions
on how to configure an application for diffenent encryption strengths.
</description>
<param-name>org.apache.myfaces.SECRET</param-name>
<param-value>NzY1NDMyMTA=</param-value>
</context-param>
<context-param>
<description>
Validate managed beans, navigation rules and ensure that forms are not nested.
</description>
<param-name>org.apache.myfaces.VALIDATE</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description>
Treat readonly same as if disabled attribute was set for select elements.
</description>
<param-name>org.apache.myfaces.READONLY_AS_DISABLED_FOR_SELECTS</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description>
Use the defined class as the class which will be called when a resource is added to the
ExtensionFilter handling. Using StreamingAddResource here helps with performance. If you want to add
custom components and want to use the ExtensionFilter, you need to provide your custom implementation here.
</description>
<param-name>org.apache.myfaces.ADD_RESOURCE_CLASS</param-name>
<param-value>org.apache.myfaces.renderkit.html.util.DefaultAddResource</param-value>
</context-param>
<context-param>
<description>
Virtual path in the URL which triggers loading of resources for the MyFaces extended components
in the ExtensionFilter.
</description>
<param-name>org.apache.myfaces.RESOURCE_VIRTUAL_PATH</param-name>
<param-value>/faces/myFacesExtensionResource</param-value>
</context-param>
<context-param>
<description>
Check if the extensions-filter has been properly configured.
</description>
<param-name>org.apache.myfaces.CHECK_EXTENSIONS_FILTER</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description>
Define partial state saving as true/false.
</description>
<param-name>javax.faces.PARTIAL_STATE_SAVING_METHOD</param-name>
<param-value>false</param-value>
</context-param>
<filter>
<filter-name>extensionsFilter</filter-name>
<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
<init-param>
<description>Set the size limit for uploaded files.
Format: 10 - 10 bytes
10k - 10 KB
10m - 10 MB
1g - 1 GB</description>
<param-name>uploadMaxFileSize</param-name>
<param-value>100m</param-value>
</init-param>
<init-param>
<description>Set the threshold size - files
below this limit are stored in memory, files above
this limit are stored on disk.
Format: 10 - 10 bytes
10k - 10 KB
10m - 10 MB
1g - 1 GB</description>
<param-name>uploadThresholdSize</param-name>
<param-value>100k</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>extensionsFilter</filter-name>
<url-pattern>*.jsf</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>extensionsFilter</filter-name>
<url-pattern>/faces/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>extensionsFilter</filter-name>
<url-pattern>/jsp/faces/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
faces-config
Code:
<?xml version="1.0"?>
<!DOCTYPE faces-config PUBLIC
"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
"http://java.sun.com/dtd/web-facesconfig_1_1.dtd" >
<faces-config>
<managed-bean>
<managed-bean-name>helloWorldBacking</managed-bean-name>
<managed-bean-class>org.apache.myfaces.blank.HelloWorldBacking</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>eventListenerServlet </managed-bean-name>
<managed-bean-class>org.procon.googleMap.controller.EventListenerServlet </managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<navigation-rule>
<from-view-id>/jsp/helloWorld.jsp</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/jsp/page2.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/jsp/page2.jsp</from-view-id>
<navigation-case>
<from-outcome>back</from-outcome>
<to-view-id>/jsp/helloWorld.jsp</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>
jsp
Code:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
<%@ taglib uri="/WEB-INF/googlemaps.tld" prefix="googlemaps"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Test Googlemaps</title>
<googlemaps:map id="map" width="250" height="300" version="2" type="STREET" zoom="12">
<googlemaps:key domain="localhost" key="ABQIAAAAU5IDceLqYFSp4k84FYLxyRTwM0brOpm-All5BF6PoaKBxRWWERSDiAIGyx-hbmMfA3v7tHF4Tvwfaw"/>
<googlemaps:point id="point1" address="74 Connors Lane" city="Elkton"
state="MD" zipcode="21921" country="US"/>
<googlemaps:marker id="marker1" point="point1">
<googlemaps:event action="click" url="Hier sollte der Controller aufgerufen werden, aber wie?"/>
</googlemaps:marker>
</googlemaps:map>
<googlemaps:scripttag id="map" scope="page" />
<googlemaps:javascript id="map"></googlemaps:javascript>
</head>
<body onunload="GUnload()">
<googlemaps:div id="map" scope="page"></googlemaps:div>
<googlemaps:initialize id="map" scope="page"/>
</body>
</html>
controller:
Code:
package org.procon.googleMap.controller;
import java.io.IOException;
import java.util.Date;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.lamatek.servlets.google.DefaultEventListenerServlet;
import com.lamatek.tags.google.GoogleMapEventTag;
import com.lamatek.tags.google.GoogleMapInfoWindowTag;
import com.lamatek.tags.google.GoogleMapMarkerTag;
import com.lamatek.tags.google.GoogleMapPointTag;
import com.lamatek.tags.google.GoogleMapTag;
public class EventListenerServlet extends DefaultEventListenerServlet{
private static final long serialVersionUID = 1785657L;
public EventListenerServlet() {
// TODO Auto-generated constructor stub
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
super.doGet(request, response);
response.sendRedirect("/jsp/event.jsf");
}
public void processClickEvent(GoogleMapTag map, double longitude, double latitude) {
super.processClickEvent(map, longitude, latitude);
String name = "marker" + (new Date()).getTime();
String pointName = "point" + (new Date()).getTime();
GoogleMapPointTag point = new GoogleMapPointTag();
point.setId(pointName);
point.setLatitude(latitude);
point.setLongitude(longitude);
map.addPoint(point);
GoogleMapMarkerTag marker = new GoogleMapMarkerTag();
marker.setPoint(pointName);
marker.setId(name);
GoogleMapInfoWindowTag info = new GoogleMapInfoWindowTag();
info.setDisplay(true);
info.setHtml(true);
info.setContent("<form action=\"\" method=\"POST\">" +
"<table><tr><td>Title: </td><td>" +
"<input type=\"text\" name=\"title\"/></td>" +
"</tr><tr><td>URL: </td><td>" +
"</tr><tr><td>URL: </td><td>" +
"</tr><tr><td>URL: </td><td>" +
"<input type=\"text\" name=\"url\"/>" +
"</td></tr><tr><td></td><td>" +
"<input type=\"submit\" value=\"Add\"/></td>" +
" </tr></table></form>");
marker.setInfoWindow(info);
GoogleMapEventTag event = new GoogleMapEventTag();
event.setAction("dblclick");
event.setAsynchronous(false);
event.setUrl("/GoogleMaps/servlet/event.do");
marker.addEvent(event);
map.addMarker(marker);
}
public void processOverlayDoubleClickEvent(GoogleMapTag map, String component, String type) {
super.processOverlayDoubleClickEvent(map, component, type);
if (type.equals("marker")) {
GoogleMapMarkerTag m = map.getMarker(component);
map.removeMarker(m);
}
}
}