changeset 572:3f7bbc6dc751

Sourced JavaScript script tags for loading and rendering an OpenLayers client out to an own jsp page. gnv/trunk@701 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 23 Feb 2010 15:26:50 +0000
parents f2ba58011a2d
children bd67164cf28b
files gnv/ChangeLog gnv/src/main/webapp/WEB-INF/config/struts-config.xml gnv/src/main/webapp/WEB-INF/jsp/mainlayout.jsp gnv/src/main/webapp/WEB-INF/jsp/wmslayout.jsp
diffstat 4 files changed, 96 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
--- a/gnv/ChangeLog	Tue Feb 23 10:36:02 2010 +0000
+++ b/gnv/ChangeLog	Tue Feb 23 15:26:50 2010 +0000
@@ -1,3 +1,16 @@
+2010-02-23  Ingo Weinzierl <ingo.weinzierl@intevation.de>
+
+	* src/main/webapp/WEB-INF/config/struts-config.xml: Foward to wmslayout.jsp
+	  instead of mainlayout.jsp if the user selected wms target.
+
+	* src/main/webapp/WEB-INF/jsp/wmslayout.jsp: New page for rendering a wms
+	  client (OpenLayers). JavaScript loading take place in this page. If the
+	  user select the wms target, a forward to this page will be done.
+
+	* src/main/webapp/WEB-INF/jsp/mainlayout.jsp: Removed OpenLayers JavaScript
+	  library and function to initialize OpenLayers. This reduces traffic while
+	  parameterization.
+
 2010-02-23  Ingo Weinzierl <ingo.weinzierl@intevation.de>
 
 	* src/main/java/de/intevation/gnv/action/CreateChartAction.java: Class to
--- a/gnv/src/main/webapp/WEB-INF/config/struts-config.xml	Tue Feb 23 10:36:02 2010 +0000
+++ b/gnv/src/main/webapp/WEB-INF/config/struts-config.xml	Tue Feb 23 15:26:50 2010 +0000
@@ -99,7 +99,7 @@
                 validate="false">
             <forward
                 name="success"
-                path="/WEB-INF/jsp/mainlayout.jsp"/>
+                path="/WEB-INF/jsp/wmslayout.jsp"/>
             <forward
                 name="back"
                 path="/gnv/back.do"/>
--- a/gnv/src/main/webapp/WEB-INF/jsp/mainlayout.jsp	Tue Feb 23 10:36:02 2010 +0000
+++ b/gnv/src/main/webapp/WEB-INF/jsp/mainlayout.jsp	Tue Feb 23 15:26:50 2010 +0000
@@ -43,55 +43,9 @@
 "-1.5763 58.3616))";
             }
         </script>
-        <script src="http://www.openlayers.org/api/OpenLayers.js"></script>
-        <script type="text/javascript">
-            var lon  = 5;
-            var lat  = 55;
-            var zoom = 5;
-            var map, layer;
-
-            function init() {
-                if (getURLParam("target") == "wms") {
-                    map   = new OpenLayers.Map('map');
-                    layer = new OpenLayers.Layer.WMS(
-                        "MyWMS",
-                        "http://denmark.atlas/cgi-bin/mapserv-gp?MAP=/opt/artifacts/mapfiles/mapfile.map",
-                        {
-                            layers: getURLParam("layer")
-                        },
-                        {
-                            singleTile: 'true'
-                        }
-                    );
-
-                    map.addLayer(layer);
-                    map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
-                }
-            }
-
-            function getURLParam(strParamName){
-                var strReturn = "";
-                var strHref = window.location.href;
-
-                if ( strHref.indexOf("?") > -1 ){
-                    var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
-                    var aQueryString = strQueryString.split("&");
-
-                    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
-                        if (aQueryString[iParam].indexOf(strParamName + "=") > -1 ) {
-                            var aParam = aQueryString[iParam].split("=");
-                            strReturn = aParam[1];
-                            break;
-                        }
-                    }
-                }
-
-                return strReturn;
-            }
-        </script>
     </head>
 
-    <body id="gnviewerbody" onLoad="init()">
+    <body id="gnviewerbody">
     <div id="overlay"></div>
     <div style="width:100%;left:0;top:0;width:100%;height:100%;position:absolute">
         <div id="overlayContent">
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gnv/src/main/webapp/WEB-INF/jsp/wmslayout.jsp	Tue Feb 23 15:26:50 2010 +0000
@@ -0,0 +1,81 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
+<html xmlns="http://www.w3.org/1999/xhtml">
+    <head>
+        <title>
+            <bean:message key="gnviewer.app.title"/>
+        </title>
+        <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
+        <meta http-equiv="Content-Script-Type" content="text/javascript"/>
+        <meta http-equiv="Content-Style-Type" content="text/css"/>
+        <meta http-equiv="Expires" content="Mon, 01 Jan 1990 00:00:01 GMT"/>
+        <meta http-equiv="pragma" content="no-cache"/>
+        <meta http-equiv="cache-control" content="no-cache"/>
+        <meta name="robots" content="noindex"/>
+        <link href="styles/default.css" rel="stylesheet" type="text/css"/>
+        <script type="text/javascript" src="scripts/gnviewer.js"></script>
+        <script src="http://www.openlayers.org/api/OpenLayers.js"></script>
+        <script type="text/javascript">
+            var lon  = 5;
+            var lat  = 55;
+            var zoom = 5;
+            var map, layer;
+
+            function init() {
+                if (getURLParam("target") == "wms") {
+                    map   = new OpenLayers.Map('map');
+                    layer = new OpenLayers.Layer.WMS(
+                        "MyWMS",
+                        "http://denmark.atlas/cgi-bin/mapserv-gp?MAP=/opt/artifacts/mapfiles/mapfile.map",
+                        {
+                            layers: getURLParam("layer")
+                        },
+                        {
+                            singleTile: 'true'
+                        }
+                    );
+
+                    map.addLayer(layer);
+                    map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
+                }
+            }
+
+            function getURLParam(strParamName){
+                var strReturn = "";
+                var strHref = window.location.href;
+
+                if ( strHref.indexOf("?") > -1 ){
+                    var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
+                    var aQueryString = strQueryString.split("&");
+
+                    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
+                        if (aQueryString[iParam].indexOf(strParamName + "=") > -1 ) {
+                            var aParam = aQueryString[iParam].split("=");
+                            strReturn = aParam[1];
+                            break;
+                        }
+                    }
+                }
+
+                return strReturn;
+            }
+        </script>
+    </head>
+
+    <body id="gnviewerbody" onLoad="init()">
+    <div id="overlay"></div>
+    <div style="width:100%;left:0;top:0;width:100%;height:100%;position:absolute">
+        <div id="overlayContent">
+            <p>
+                <bean:message key="gnviewer.productselection.overlay.title"/>
+            </p>
+        </div>
+    </div>
+    <div id="page">
+        <jsp:include page="header.jsp" />
+         <jsp:include page="index.jsp" />
+        <jsp:include page="footer.jsp" />
+    </div>
+    </body>
+</html>

http://dive4elements.wald.intevation.org