Author: simoneg
Date: Thu Dec 17 23:54:05 2009
New Revision: 892014

URL: http://svn.apache.org/viewvc?rev=892014&view=rev
Log:
LABS-503 : Don't try to handle null values, use id in forms

Modified:
    
labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/htmlpieces/MapBeanHtmlFormPiece.java
    
labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/htmlpieces/MapBeanHtmlOutputPiece.java

Modified: 
labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/htmlpieces/MapBeanHtmlFormPiece.java
URL: 
http://svn.apache.org/viewvc/labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/htmlpieces/MapBeanHtmlFormPiece.java?rev=892014&r1=892013&r2=892014&view=diff
==============================================================================
--- 
labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/htmlpieces/MapBeanHtmlFormPiece.java
 (original)
+++ 
labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/htmlpieces/MapBeanHtmlFormPiece.java
 Thu Dec 17 23:54:05 2009
@@ -13,17 +13,14 @@
 
        public String createFormInput(MagMapBean value, String id) {
                StringBuilder ret = new StringBuilder();
-               String val = "null";
                String md = "";
                if (value != null) {
-                       val = "map" + value.hashCode();
-                       val = val.replace('-', '_');
                        md = value.getValue();
                }
                ret.append("<input type=\"hidden\" id=\"" + id + "\" name=\"" + 
id + "\" value=\"" + StringEscapeUtils.escapeXml(md) + "\"/>");
-               ret.append("<div class=\"MagmaMapEdit\" id=\"edit" + val + 
"\"></div>");
+               ret.append("<div class=\"MagmaMapEdit\" id=\"" + id + 
"edit\"></div>");
                ret.append("<div class=\"MagmaMapListContainer\">");
-               ret.append("<table class=\"MagmaMapList\" id=\"edit" + val + 
"list\"></table>");
+               ret.append("<table class=\"MagmaMapList\" id=\"" + id + 
"editlist\"></table>");
                ret.append("</div>");   
                return ret.toString();
        }
@@ -40,11 +37,6 @@
                head.addExternalScript("magma:/common/maps/mapDisplay.js");
                head.addExternalScript("magma:/common/maps/mapEditor.js");
                head.addCss("magma:/common/maps/mapEditor.css");
-               String val = "null";
-               if (value != null) {
-                       val = "map" + value.hashCode();
-                       val = val.replace('-', '_');
-               }
                PropertyInfo property = getProperty();
                String options = null;
                MapBeanValidator validator = null;
@@ -62,7 +54,10 @@
                        }
                }
 
-               head.addRawScript("init-edit-" + val, "function initedit" + val 
+ "() { new MapEditor('edit" + val + "','edit" + val + "list','" + id + "'" + 
(options == null ? "" : (",'" + options+ "'")) + "); }");
+               String val = id;
+               val = val.replace('.', '_');
+               val = val.replace('-', '_');
+               head.addRawScript("init-edit-" + val, "function initedit" + val 
+ "() { new MapEditor('" + id + "edit','" + id + "editlist','" + id + "'" + 
(options == null ? "" : (",'" + options+ "'")) + "); }");
                head.addDoOnload("initedit" + val);             
        }
 

Modified: 
labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/htmlpieces/MapBeanHtmlOutputPiece.java
URL: 
http://svn.apache.org/viewvc/labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/htmlpieces/MapBeanHtmlOutputPiece.java?rev=892014&r1=892013&r2=892014&view=diff
==============================================================================
--- 
labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/htmlpieces/MapBeanHtmlOutputPiece.java
 (original)
+++ 
labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/htmlpieces/MapBeanHtmlOutputPiece.java
 Thu Dec 17 23:54:05 2009
@@ -18,28 +18,22 @@
        }
 
        public void head(MagMapBean value, Head head) {
+               if (value == null) return;
                head.addJQuery();
                
head.addExternalScript("http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=";
 + Settings.get("google.maps.key"));             
                head.addExternalScript("magma:/common/maps/mapDisplay.js");
                head.addCss("magma:/common/maps/mapDisplay.css");
-               String val = "null";
-               String md = "";
-               if (value != null) {
-                       val = "map" + value.hashCode();
-                       val = val.replace('-', '_');
-                       md = value.getValue();
-               }
+               String val = "map" + value.hashCode();
+               val = val.replace('-', '_');
+               String md = value.getValue();
                head.addRawScript("init-" + val, "function init" + val + "() { 
new MagMap().init('" + val + "','" + StringEscapeUtils.escapeJavaScript(md) + 
"'); }");
                head.addDoOnload("init" + val);
        }
 
        public String output(MagMapBean value) {
-               // TODO support static maps here
-               String val = "null";
-               if (value != null) {
-                       val = "map" + value.hashCode();
-                       val = val.replace('-', '_');
-               }
+               if (value == null) return "";
+               String val = "map" + value.hashCode();
+               val = val.replace('-', '_');
                return "<div class=\"MagmaMap\" id=\"" + val + "\"/>";
        }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to