portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smi...@apache.org
Subject svn commit: r469389 - in /portals/jetspeed-2/trunk/applications: demo/src/webapp/WEB-INF/ demo/src/webapp/WEB-INF/other/googlemaps/ gems/src/java/org/apache/portals/gems/googlemaps/
Date Tue, 31 Oct 2006 06:28:51 GMT
Author: smilek
Date: Mon Oct 30 22:28:50 2006
New Revision: 469389

URL: http://svn.apache.org/viewvc?view=rev&rev=469389
Log:
google maps portlet updated with edit mode for setting Google Maps API key, Location and Map
Height; also revised to express dojo dependencies using newly improved management of html
<head> content via HeaderResource and HeaderAggregatorImpl

Modified:
    portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/other/googlemaps/EditGoogleMaps.vm
    portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/other/googlemaps/GoogleMaps.vm
    portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/portlet.xml
    portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/googlemaps/GoogleMapsPortlet.java

Modified: portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/other/googlemaps/EditGoogleMaps.vm
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/other/googlemaps/EditGoogleMaps.vm?view=diff&rev=469389&r1=469388&r2=469389
==============================================================================
--- portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/other/googlemaps/EditGoogleMaps.vm
(original)
+++ portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/other/googlemaps/EditGoogleMaps.vm
Mon Oct 30 22:28:50 2006
@@ -1,8 +1,18 @@
 <div id="EditGoogleMaps"  class="portlet-section-text"> 
 	<form name="googlemapsform" action="$renderResponse.createActionURL()" method="post"
>
-
-		Enter Location:<input type="text" name="location" value="$renderRequest.getPreferences().getValue('Location','')"
/>
-		<input type="submit" value="submit"  name="LocationSubmit" />
+        <table border="0" cellspacing="3" cellpadding="3">
+            <tr>
+                <td>Location</td><td><input type="text" name="location"
value="$renderRequest.getPreferences().getValue('Location','')" /></td>
+            </tr>
+            <tr>
+                <td>Map Height</td><td><input type="text" name="mapheight"
value="$renderRequest.getPreferences().getValue('MapHeight','')" /></td>
+            </tr>
+            <tr>
+                <td>Google Maps API Key</td><td><input type="text" name="apikey"
size="40" value="$renderRequest.getPreferences().getValue('APIKey','')" /><div style="padding-top:
6px; font-size: x-small;"><a target="_new" href="http://www.google.com/apis/maps/">Sign
up for a Google Maps API key</a></div></td>
+            </tr>
+            <tr><td></td><td><div style="padding-top: 10px"><button
dojoType="Button" onClick="document.forms['googlemapsform'].submit()" >Submit Changes</button></div></td>
+            </tr>
+        </table>
 	</form>
 </div>
 

Modified: portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/other/googlemaps/GoogleMaps.vm
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/other/googlemaps/GoogleMaps.vm?view=diff&rev=469389&r1=469388&r2=469389
==============================================================================
--- portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/other/googlemaps/GoogleMaps.vm
(original)
+++ portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/other/googlemaps/GoogleMaps.vm
Mon Oct 30 22:28:50 2006
@@ -1,18 +1,43 @@
+
 <script language="JavaScript" type="text/javascript">
-	loc = escape("$renderRequest.getPreferences().getValue('Location','')");
-	dojo.io.bind({
-		url: "$renderRequest.getScheme():\/\/$renderRequest.getServerName():$renderRequest.getServerPort()$renderRequest.getContextPath()\/yahoogeocode?location="
+ loc,
-		mimetype: "text/xml",
-		error: function(type, error){
-			top.alert("error");
-		},
-		load: function(type, data, event) {
-			lat = data.getElementsByTagName("Latitude").item(0).firstChild.nodeValue;
-			lng = data.getElementsByTagName("Longitude").item(0).firstChild.nodeValue;
-			//alert ("ll: " + lat + "," + lng);
-			mapit(lat,lng);
-		}
-	});
+    function portletGoogleMapsLoadMap()
+    {
+        var loc = escape("$renderRequest.getPreferences().getValue('Location','')");
+        var getLatitudeLongitudeUrl = "$renderRequest.getScheme():\/\/$renderRequest.getServerName():$renderRequest.getServerPort()$renderRequest.getContextPath()\/yahoogeocode?location="
+ loc ;
+        dojo.io.bind({
+		    url: getLatitudeLongitudeUrl,
+		    mimetype: "text/xml",
+		    error: function(type, error){
+			    dojo.raise( "request failed for yahoo latitude-longitude  type=" + type + " error="
+ error );
+            },
+            load: function( type, data, evt )
+            {
+			    lat = data.getElementsByTagName("Latitude").item(0).firstChild.nodeValue;
+			    lng = data.getElementsByTagName("Longitude").item(0).firstChild.nodeValue;
+			    //alert ("ll: " + lat + "," + lng);
+			    mapit(lat,lng);
+		    }
+	    });
+    }
+    function portletGoogleMapsLoadApi()
+    {
+        var googleMapsApiJSUrl = "http://maps.google.com/maps?file=api&v=2&key=$renderRequest.getPreferences().getValue('APIKey','')"
; 
+        dojo.io.bind({
+		    url: googleMapsApiJSUrl,
+            mimetype: "text/javascript",
+            transport: "ScriptSrcTransport",
+		    error: function(type, error){
+			    alert( "here-error" );
+                dojo.raise( "request failed for google maps api  type=" + type + " error="
+ error );
+            },
+            load: function( type, data, evt )
+            {
+                alert( "here-success" );
+                portletGoogleMapsLoadMap();
+		    }
+	    });
+    }
+    dojo.addOnLoad( portletGoogleMapsLoadMap ) ;
 </script>
 <script language="JavaScript" type="text/javascript">
 	function mapit(la, ln) {
@@ -22,6 +47,5 @@
 		map.setCenter(new GLatLng(la, ln), 13);
 	}
 </script>
-<div id="map" style="width: 100%; height: 100%"></div>
-
+<div id="map" style="width: 100%; height: $renderRequest.getPreferences().getValue('MapHeight','400px')"></div>
 

Modified: portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/portlet.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/portlet.xml?view=diff&rev=469389&r1=469388&r2=469389
==============================================================================
--- portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/portlet.xml (original)
+++ portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/portlet.xml Mon Oct 30 22:28:50
2006
@@ -796,33 +796,45 @@
   </portlet>
 
   <portlet id="GoogleMapsPortlet">
-    <init-param>
-      <name>ViewPage</name>
-      <value>/WEB-INF/other/googlemaps/GoogleMaps.vm</value>
-    </init-param>
-    <init-param>
-      <name>EditPage</name>
-      <value>/WEB-INF/other/googlemaps/EditGoogleMaps.vm</value>
-    </init-param>
-    <portlet-name>GoogleMapsPortlet</portlet-name>
-    <display-name>Google Maps Portlet</display-name>
-    <portlet-class>org.apache.portals.gems.googlemaps.GoogleMapsPortlet</portlet-class>
-    <expiration-cache>-1</expiration-cache>
-    <supports>
-      <mime-type>text/html</mime-type>
-      <portlet-mode>VIEW</portlet-mode>
-      <portlet-mode>EDIT</portlet-mode>
-    </supports>
-    <supported-locale>en</supported-locale>
-    <portlet-info>
-      <title>Google Map</title>
-    </portlet-info>
-    <portlet-preferences>
-      <preference>
-        <name>Location</name>
-        <value>denver, co</value>
-      </preference>
-    </portlet-preferences>
+      <init-param>
+          <name>ViewPage</name>
+          <value>/WEB-INF/other/googlemaps/GoogleMaps.vm</value>
+      </init-param>
+      <init-param>
+          <name>EditPage</name>
+          <value>/WEB-INF/other/googlemaps/EditGoogleMaps.vm</value>
+      </init-param>
+      <portlet-name>GoogleMapsPortlet</portlet-name>
+      <display-name>Google Maps Portlet</display-name>
+      <portlet-class>org.apache.portals.gems.googlemaps.GoogleMapsPortlet</portlet-class>
+      <expiration-cache>-1</expiration-cache>
+      <supports>
+          <mime-type>text/html</mime-type>
+          <portlet-mode>VIEW</portlet-mode>
+          <portlet-mode>EDIT</portlet-mode>
+      </supports>
+      <supported-locale>en</supported-locale>
+      <portlet-info>
+          <title>Google Map</title>
+      </portlet-info>
+      <portlet-preferences>
+          <preference>
+              <name>Location</name>
+              <value>San Francisco, CA</value>
+          </preference>
+      </portlet-preferences>
+      <portlet-preferences>
+          <preference>
+              <name>MapHeight</name>
+              <value>400px</value>
+          </preference>
+      </portlet-preferences>
+      <portlet-preferences>
+          <preference>
+              <name>APIKey</name>
+              <value>ABQIAAAAisHr-hr7f_yfo_m3teTC5RQXGaCFRGWXJQavRKQcb1Ew_fwkKRQ26QnpXVIkxSMwwTECWDV23ZDaLQ</value>
+          </preference>
+      </portlet-preferences>
   </portlet>         
 
   	<portlet id="weather">

Modified: portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/googlemaps/GoogleMapsPortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/googlemaps/GoogleMapsPortlet.java?view=diff&rev=469389&r1=469388&r2=469389
==============================================================================
--- portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/googlemaps/GoogleMapsPortlet.java
(original)
+++ portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/googlemaps/GoogleMapsPortlet.java
Mon Oct 30 22:28:50 2006
@@ -25,6 +25,7 @@
 import javax.portlet.PortletException;
 import javax.portlet.PortletPreferences;
 
+import org.apache.jetspeed.headerresource.HeaderResource;
 import org.apache.jetspeed.portlet.PortletHeaderRequest;
 import org.apache.jetspeed.portlet.PortletHeaderResponse;
 import org.apache.portals.gems.dojo.AbstractDojoVelocityPortlet;
@@ -54,10 +55,17 @@
     public void processAction(ActionRequest request, ActionResponse actionResponse)
     throws PortletException, IOException
     {
-	String location = request.getParameter("location");
-	PortletPreferences preferences = request.getPreferences();
-	preferences.setValue("Location",location);
-	preferences.store();
+        String location = request.getParameter( "location" );
+        String mapHeight = request.getParameter( "mapheight" );
+        String apiKey = request.getParameter( "apikey" );
+        PortletPreferences preferences = request.getPreferences();
+        if ( location != null )
+            preferences.setValue( "Location", location );
+        if ( mapHeight != null )
+            preferences.setValue( "MapHeight", mapHeight );
+        if ( apiKey != null )
+            preferences.setValue( "APIKey", apiKey );
+        preferences.store();
     }
     
     public void doHeader(PortletHeaderRequest request, PortletHeaderResponse response)
@@ -66,27 +74,25 @@
         StringBuffer headerInfoText = new StringBuffer();
         Map headerInfoMap = null;
         
-        // close DOJO if not already in use as desktop
-        if (!request.isDesktopEncoder()) 
-        {
-            // complete DoJo includes
-            headerInfoText.setLength(0);
-            headerInfoMap = new HashMap(8);
-            headerInfoMap.put("language", "JavaScript");            
-            headerInfoMap.put("src", "http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAisHr-hr7f_yfo_m3teTC5RQXGaCFRGWXJQavRKQcb1Ew_fwkKRQ26QnpXVIkxSMwwTECWDV23ZDaLQ");
-            headerInfoMap.put("type", "text/javascript");
-            response.getHeaderResource().addHeaderInfo("script", headerInfoMap, headerInfoText.toString());
-        }
+        // add google maps api script tag
+        headerInfoText.setLength(0);
+        headerInfoMap = new HashMap(8);
+        headerInfoMap.put("language", "JavaScript");
+        headerInfoMap.put("src", "http://maps.google.com/maps?file=api&v=2&key="
+ request.getPreferences().getValue("APIKey","") );
+        headerInfoMap.put("type", "text/javascript");
+        response.getHeaderResource().addHeaderInfo("script", headerInfoMap, headerInfoText.toString());
+
         super.doHeader(request, response);
     }
     
-    protected void includeDojoRequires(StringBuffer headerInfoText)
+    protected void includeHeaderContent( HeaderResource headerResource )
     {
-        appendHeaderText(headerInfoText, "dojo.lang.*");
-        appendHeaderText(headerInfoText, "dojo.event.*");
-        appendHeaderText(headerInfoText, "dojo.io.*");             
-    }    
-        
+        headerResource.dojoAddCoreLibraryRequire( "dojo.lang.*" );
+        headerResource.dojoAddCoreLibraryRequire( "dojo.event.*" );
+        headerResource.dojoAddCoreLibraryRequire( "dojo.io.*" );
+        headerResource.dojoAddCoreLibraryRequire( "dojo.widget.*" );
+        headerResource.dojoAddCoreLibraryRequire( "dojo.widget.Button" );
+    }
 }
 
 



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message