portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r412947 - 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 Fri, 09 Jun 2006 06:29:48 GMT
Author: taylor
Date: Thu Jun  8 23:29:47 2006
New Revision: 412947

URL: http://svn.apache.org/viewvc?rev=412947&view=rev
Log:
google map portlet should now be working with /desktop, although i dont like putting the required
javascript in the blue.jsp
getting closer with /portal...

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

Modified: portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/jetspeed-portlet.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/jetspeed-portlet.xml?rev=412947&r1=412946&r2=412947&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/jetspeed-portlet.xml (original)
+++ portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/jetspeed-portlet.xml Thu
Jun  8 23:29:47 2006
@@ -222,6 +222,7 @@
 
 	<js:services>
 	    <js:service name='SSO'/>
+        <js:service name='HeaderResource'/>           
 	</js:services>
 	
 </portlet-app>

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?rev=412947&r1=412946&r2=412947&view=diff
==============================================================================
--- 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
Thu Jun  8 23:29:47 2006
@@ -17,11 +17,11 @@
 <script language="JavaScript" type="text/javascript">
 	function mapit(la, ln) {
 		var map = new GMap2(document.getElementById("map"));
-		// map.addControl(new GSmallMapControl());
-		// map.addControl(new GMapTypeControl());
+map.addControl(new GSmallMapControl());
+		map.addControl(new GMapTypeControl());
 		map.setCenter(new GLatLng(la, ln), 13);
 	}
 </script>
-<div id="map" style="width: 500px; height: 300px"></div>
+<div id="map" style="width: 100%; height: 100%"></div>
 
 

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?rev=412947&r1=412946&r2=412947&view=diff
==============================================================================
--- 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
Thu Jun  8 23:29:47 2006
@@ -17,20 +17,30 @@
 
 
 import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
 
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
 import javax.portlet.PortletException;
 import javax.portlet.PortletPreferences;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
 
-import org.apache.portals.bridges.velocity.GenericVelocityPortlet;
+import org.apache.jetspeed.CommonPortletServices;
+import org.apache.jetspeed.PortalReservedParameters;
+import org.apache.jetspeed.headerresource.HeaderResource;
+import org.apache.jetspeed.headerresource.HeaderResourceFactory;
+import org.apache.jetspeed.request.RequestContext;
+import org.apache.portals.gems.dojo.AbstractDojoVelocityPortlet;
+import org.apache.velocity.context.Context;
 /**
  * This is a simple class used to override processAction
  * to save location form submission value to location preference
  *
  * @version $Id: GoogleMapsPortlet.java 393251 2006-04-22 15:50:52Z jdp $
  */
-public class GoogleMapsPortlet extends GenericVelocityPortlet
+public class GoogleMapsPortlet extends AbstractDojoVelocityPortlet
 {
     
     /**
@@ -40,7 +50,7 @@
     {
         super();
     }
-
+    
     /**
      * save submitted value
      *
@@ -55,6 +65,55 @@
 	preferences.setValue("Location",location);
 	preferences.store();
     }
+    
+    protected void doDispatch(RenderRequest request, RenderResponse response) throws PortletException,
IOException 
+    {
+        // include header content
+        includeHeaderContent(request,response);
+
+        // dispatch normally
+        super.doDispatch(request, response);
+    }
+
+    protected void includeHeaderContent(RenderRequest request, RenderResponse response) 
+    {
+        // get portal context path
+        RequestContext requestContext = (RequestContext) request.getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
+        String portalContextPath = requestContext.getRequest().getContextPath();
+
+        // use header resource component to ensure header logic is included only once
+        HeaderResource headerResource = headerResourceFactoryComponent.getHeaderResouce(request);
+        StringBuffer headerInfoText = new StringBuffer();
+        Map headerInfoMap = null;
+
+        // detect jetspeed-desktop
+        String requestEncoder = (String)requestContext.getRequest().getParameter("encoder");
+
+        boolean isJetspeedDesktop = ((requestEncoder == null) || !requestEncoder.equals("desktop"))
? false : true;
+        Context velocityContext = getContext(request);
+        velocityContext.put("isJetspeedDesktop", new Boolean( isJetspeedDesktop ) );
+        
+        // close DOJO if not already in use as desktop
+        if (!isJetspeedDesktop) 
+        {
+            // 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");
+            headerResource.addHeaderInfo("script", headerInfoMap, headerInfoText.toString());
+        }
+        super.includeHeaderContent(request, response);
+    }
+    
+    protected void includeDojoRequires(StringBuffer headerInfoText)
+    {
+        appendHeaderText(headerInfoText, "dojo.lang.*");
+        appendHeaderText(headerInfoText, "dojo.event.*");
+        appendHeaderText(headerInfoText, "dojo.io");             
+    }    
+        
 }
 
 

Modified: portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/googlemaps/YahooGeocodeProxyServlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/googlemaps/YahooGeocodeProxyServlet.java?rev=412947&r1=412946&r2=412947&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/googlemaps/YahooGeocodeProxyServlet.java
(original)
+++ portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/googlemaps/YahooGeocodeProxyServlet.java
Thu Jun  8 23:29:47 2006
@@ -12,7 +12,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jetspeed.portlets.googlemaps;
+package org.apache.portals.gems.googlemaps;
 
 import java.io.IOException;
 import java.io.PrintWriter;



---------------------------------------------------------------------
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