--- 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 [%<+ /\.#>])</p>
+ <p>{ minEncodeElement(minEncode) }Minimally encode IRI components (just encode [%<+ /\.#>])</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 + "'")