changeset 354:ec859fb55933

~ make urlEncode button sticky
author Eric Prud'hommeaux <eric@w3.org>
date Thu, 17 Feb 2011 16:00:50 -0500
parents 883351632db8
children 3e2b6e638c12
files directmapping-webapp/src/main/scala/Servlet.scala
diffstat 1 files changed, 10 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/directmapping-webapp/src/main/scala/Servlet.scala	Wed Feb 16 20:15:27 2011 -0500
+++ b/directmapping-webapp/src/main/scala/Servlet.scala	Thu Feb 17 16:00:50 2011 -0500
@@ -231,10 +231,14 @@
 //     sb.toString
   }
 
+  def minEncodeElement (minEncode:Boolean):scala.xml.Elem =
+    if (minEncode) <input name="minEncode" checked="on" type="checkbox" />
+    else <input name="minEncode" type="checkbox" />
+
   override def doPost(request:HttpServletRequest, response:HttpServletResponse) = {
     val minEncode = request.getParameter("minEncode") == "on"
     request.getParameter("sql") match {
-      case null | "" => processIndex(request, response)
+      case null | "" => processIndex(request, response, minEncode)
       case sql       => processSQL(request, response, sql, minEncode)
     }
   }
@@ -246,7 +250,7 @@
                                       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"),
                              Nil)
 
-  def render(sql:String, result:Option[String]) =
+  def render(sql:String, minEncode:Boolean, result:Option[String]) =
     <html xmlns="http://www.w3.org/1999/xhtml">
       <head>
         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
@@ -270,7 +274,7 @@
             { List("1table0rows", "1table1row", "1table2columns1row", "1table3columns1row", "2duplicates0nulls", "varchar_varchar_1row", "1table1compositeprimarykey3columns1row", "1table1primarykey1column1row", "2tables1primarykey1foreingkey") map renderVar }
 	  </div>
 	  </div>
-	  <p><input name="minEncode" checked="checked" type="checkbox" />Minimally encode IRI components (just encode [%&lt;+ /\.#&gt;])</p>
+	  <p>{ minEncodeElement(minEncode) }Minimally encode IRI components (just encode [%&lt;+&nbsp;/\.#&gt;])</p>
 	  <p><input value="clear" type="button" onclick="document.getElementById('sql').value = '';" /></p>
 	  <p><input id="submit" value="submit SQL" type="submit" /></p>
         </form>
@@ -295,7 +299,7 @@
         case e => e.getMessage
       }
 
-    val html = render(sql, Some(result))
+    val html = render(sql, minEncode, Some(result))
 
     response.setContentType("application/xml; charset='" + encoding + "'")
 
@@ -303,9 +307,9 @@
 
   }
 
-  def processIndex(request:HttpServletRequest, response:HttpServletResponse) {
+  def processIndex(request:HttpServletRequest, response:HttpServletResponse, minEncode:Boolean) {
 
-    val index = render(defaultSQL, None)
+    val index = render(defaultSQL, minEncode, None)
 
     response.setContentType("application/xml; charset='" + encoding + "'")
 
Set up and maintained by W3C Systems Team, please report bugs to sysreq@w3.org.

W3C would like to thank Microsoft who donated the server that allows us to run this service.