Author: dolander
Date: Thu Jan 13 13:54:30 2005
New Revision: 125107

URL: http://svn.apache.org/viewcvs?view=rev&rev=125107
Log:
Add a simple test of the lookupScopeId method in JavaScript



Added:
   incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/idmap/lookupScope/
   
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/idmap/lookupScope/Controller.jpf
   
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/idmap/lookupScope/index.jsp
   
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/IdMapLookupScope.xml
Modified:
   
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml

Added: 
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/idmap/lookupScope/Controller.jpf
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/idmap/lookupScope/Controller.jpf?view=auto&rev=125107
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/idmap/lookupScope/Controller.jpf
     Thu Jan 13 13:54:30 2005
@@ -0,0 +1,139 @@
+package idmap.lookupScope;
+
+import javax.servlet.http.HttpSession;
+import org.apache.beehive.netui.pageflow.FormData;
+import org.apache.beehive.netui.pageflow.PageFlowController;
+import org.apache.beehive.netui.pageflow.Forward;
+import org.apache.beehive.netui.pageflow.annotations.Jpf;
+
+/**
+ * This is the default controller for a blank web application.
+ */
[EMAIL PROTECTED]
+public class Controller extends PageFlowController
+{
+    private String[] _selectOptions = {"Option 1", "Option 2", "Option 3", 
"Option 4"};
+    private Bean _bean = new Bean();
+
+    public Bean getBean() {
+        return _bean;
+    }
+
+    public String[] getSelectOptions() {
+        return _selectOptions;
+    }
+    
+    @Jpf.Action(
+        forwards={
+           @Jpf.Forward(name="index", path="index.jsp")
+        }
+    )
+    protected Forward begin()
+    {
+        return new Forward("index");
+    }
+
+
+    /**
+     * Callback that is invoked when this controller instance is created.
+     */
+    protected void onCreate()
+    {
+    }
+
+    /**
+     * Callback that is invoked when this controller instance is destroyed.
+     */
+    protected void onDestroy(HttpSession session)
+    {
+    }
+
+
+    @Jpf.Action(forwards = {
+        @Jpf.Forward(name = "success",
+                     path = "index.jsp")
+    })
+    protected Forward postForm(Bean form)
+    {
+        _bean = form;
+        Forward forward = new Forward("success");
+        return forward;
+    }
+
+    public static class Bean extends FormData
+    {
+        private String text1;
+
+        private String text2;
+
+        private String text3;
+
+        private boolean check1;
+
+        private boolean check2;
+
+        public String getText1()
+        {
+            return text1;
+        }
+
+        public void setText1(String value)
+        {
+            text1 = value;
+        }
+
+        public String getText2()
+        {
+            return text2;
+        }
+
+        public void setText2(String value)
+        {
+            text2 = value;
+        }
+
+        public String getText3()
+        {
+            return text3;
+        }
+
+        public void setText3(String value)
+        {
+            text3 = value;
+        }
+
+        public boolean isCheck1()
+        {
+            return check1;
+        }
+
+        public void setCheck1(boolean value)
+        {
+            check1 = value;
+        }
+
+        public boolean isCheck2()
+        {
+            return check2;
+        }
+
+        public void setCheck2(boolean value)
+        {
+            check2 = value;
+        }
+    }
+}
+
[EMAIL PROTECTED](value= {"<!-- This data is auto-generated. Hand-editing this 
section is not recommended. -->",
+"<view-properties>",
+"<pageflow-object id='pageflow:/idmap/simple/Controller.jpf'/>",
+"<pageflow-object id='page:index.jsp'><property value='220' 
name='x'/><property value='100' name='y'/></pageflow-object>",
+"<pageflow-object id='formbean:Bean'/>",
+"<pageflow-object 
id='action:postForm.do#idmap.simple.Controller.Bean'><property name='x' 
value='340'/><property name='y' value='100'/></pageflow-object>",
+"<pageflow-object id='forward:[EMAIL 
PROTECTED]:postForm.do#idmap.simple.Controller.Bean@'/>",
+"<pageflow-object id='action-call:@page:[EMAIL 
PROTECTED]@action:postForm.do#idmap.simple.Controller.Bean@'><property 
name='elbowsX' value='256,280,280,304'/><property name='elbowsY' 
value='92,92,92,92'/><property name='fromPort' value='East_1'/><property 
name='toPort' value='West_1'/></pageflow-object>",
+"<pageflow-object id='action:begin.do'><property value='80' 
name='x'/><property value='100' name='y'/></pageflow-object>",
+"<pageflow-object id='forward:[EMAIL PROTECTED]:begin.do@'><property 
value='116,140,140,164' name='elbowsX'/><property value='92,92,92,92' 
name='elbowsY'/><property value='East_1' name='fromPort'/><property 
value='West_1' name='toPort'/><property value='index' 
name='label'/></pageflow-object>",
+"</view-properties>"
+})
+interface VIEW_PROPERTIES { }

Added: 
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/idmap/lookupScope/index.jsp
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/idmap/lookupScope/index.jsp?view=auto&rev=125107
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/idmap/lookupScope/index.jsp
  Thu Jan 13 13:54:30 2005
@@ -0,0 +1,49 @@
+<%@ page language="java" contentType="text/html;charset=UTF-8"%>
+<%@ taglib prefix="netui" uri="http://beehive.apache.org/netui/tags-html-1.0"%>
+
+<netui:html scopeId="html">
+    <head>
+        <netui:base/>
+    </head>
+    <netui:body>
+        <p style="color: green">
+        </p>
+       <netui:scriptContainer scopeId="scope1">
+           <netui:scriptContainer scopeId="scope2">
+               <span id="scopeOneSpan" />
+               <netui:span tagId="span" value="span[1] inside scopeOneSpan" />
+           </netui:scriptContainer>
+       </netui:scriptContainer>
+        <hr>
+        <p style="color: green">
+        </p>
+        <p id="javaOut"></p>
+    </netui:body>
+    <script language="JavaScript" type="text/JavaScript">
+
+    var p = document.getElementById("javaOut");
+    var s1 = document.getElementById("scopeOneSpan");
+
+    var val = "<b>Document Access</b><br>";
+    val = val + "<b>ScopeId</b>: " + lookupScopeId(s1,".") + "<br>";
+
+    val = val + "Span by name is null: <b>" +
+        (document.getElementById(lookupIdByTagId("span",s1)) == null) + 
"</b><br>";
+
+    if (typeof(netui_names) != "undefined") {
+       val = val + "<b>netui_names (Legacy):</b><br>";
+       for (var x in netui_names) {
+           val = val + "Name '" + x + "' value '" + netui_names[x] + "'";
+       }
+       val = val + "<br>";
+    }
+    else {
+       val = val + "netui_name (Legacy) is <b>undefined</b><br>";
+    }
+
+    p.innerHTML = val;
+
+    </script>
+</netui:html>
+
+  
\ No newline at end of file

Modified: 
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml?view=diff&rev=125107&p1=incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml&r1=125106&p2=incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml&r2=125107
==============================================================================
--- 
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml
   (original)
+++ 
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml
   Thu Jan 13 13:54:30 2005
@@ -3164,6 +3164,19 @@
          </features>
       </test>
       <test>
+         <name>IdMapLookupScope</name>
+         <description>Simple test of the lookupScopeId call</description>
+         <webapp>coreWeb</webapp>
+         <categories>
+            <category>bvt</category>
+            <category>tags</category>
+         </categories>
+         <features>
+            <feature>JavaScript</feature>
+            <feature>lookupScopeId</feature>
+         </features>
+      </test>
+      <test>
          <name>IdMapNesting</name>
          <description>Verify tagId lookups in a nested situation with 
duplicate scope ids</description>
          <webapp>coreWeb</webapp>

Added: 
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/IdMapLookupScope.xml
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/IdMapLookupScope.xml?view=auto&rev=125107
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/IdMapLookupScope.xml
      Thu Jan 13 13:54:30 2005
@@ -0,0 +1,183 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ses:recorderSession 
xmlns:ses="http://beehive.apache.org/netui/tools/testrecorder/2004/session";>
+   <ses:sessionName>IdMapLookupScope</ses:sessionName>
+   <ses:tester>Daryl</ses:tester>
+   <ses:startDate>13 Jan 2005, 02:37:40.627 PM MST</ses:startDate>
+   <ses:description>Test of the lookupScopeId method in 
JavaScript.</ses:description>
+   <ses:tests>
+      <ses:test>
+         <ses:testNumber>1</ses:testNumber>
+         <ses:request>
+            <ses:protocol>HTTP</ses:protocol>
+            <ses:protocolVersion>1.1</ses:protocolVersion>
+            <ses:host>localhost</ses:host>
+            <ses:port>8080</ses:port>
+            <ses:uri>/coreWeb/idmap/lookupScope/Controller.jpf</ses:uri>
+            <ses:method>GET</ses:method>
+            <ses:parameters/>
+            <ses:cookies>
+               <ses:cookie>
+                  <ses:name>JSESSIONID</ses:name>
+                  <ses:value>6C2841E45F1ACA2E1523E041BF3BD4F2</ses:value>
+               </ses:cookie>
+            </ses:cookies>
+            <ses:headers>
+               <ses:header>
+                  <ses:name>accept</ses:name>
+                  
<ses:value>text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>accept-charset</ses:name>
+                  <ses:value>ISO-8859-1,utf-8;q=0.7,*;q=0.7</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>accept-encoding</ses:name>
+                  <ses:value>gzip,deflate</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>accept-language</ses:name>
+                  <ses:value>en-us,en;q=0.5</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>connection</ses:name>
+                  <ses:value>keep-alive</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>cookie</ses:name>
+                  
<ses:value>JSESSIONID=6C2841E45F1ACA2E1523E041BF3BD4F2</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>host</ses:name>
+                  <ses:value>localhost:8080</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>keep-alive</ses:name>
+                  <ses:value>300</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>user-agent</ses:name>
+                  <ses:value>Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; 
rv:1.7.5) Gecko/20041107 Firefox/1.0</ses:value>
+               </ses:header>
+            </ses:headers>
+         </ses:request>
+         <ses:response>
+            <ses:statusCode>200</ses:statusCode>
+            <ses:reason/>
+            <ses:responseBody>&lt;!DOCTYPE HTML PUBLIC "//W3C//DTD HTML 4.01 
Transitional//EN"
+       "http://www.w3.org/TR/html4/loose.dtd";>
+&lt;html lang="en" netui:scopeId="html">
+
+    &lt;head>
+        &lt;base 
href="http://localhost:8080/coreWeb/idmap/lookupScope/index.jsp";>
+    &lt;/head>
+    &lt;body>
+        &lt;p style="color: green">
+        &lt;/p>
+       &lt;div netui:scopeId="scope1" >
+           &lt;div netui:scopeId="scope2" >
+               &lt;span id="scopeOneSpan" />
+               &lt;span id="html.scope1.scope2.span">span[1] inside 
scopeOneSpan&lt;/span>
+           &lt;/div>
+
+&lt;script language="JavaScript" type="text/JavaScript">
+&lt;!--
+
+// **** This section contains code that will run when the page is loaded ****
+
+
+// Build the netui_names table to map the tagId attributes
+// to the real id written into the HTML
+if (netui_names == null)
+   var netui_names = new Object();
+netui_names.scope2__span="html.scope1.scope2.span"
+
+
+// **** This section contains functions typically run as events ****
+
+
+// method which will return a real id for a tagId,
+// the tag parameter will be used to find the scopeId for
+// containers that may scope their ids
+function getNetuiTagName(id, tag)
+{
+   var scopeId = getScopeId(tag);
+   if (scopeId == "")
+      return netui_names[id];
+   else
+      return netui_names[scopeId  + "__" + id];
+}
+
+// This method will walk the hierarchy from the pass element looking for a 
scopeId.
+// The first scopeId found will be returned or the empty string if a scopeId 
is not found.
+function getScopeId(tag)
+{
+   if (tag == null || tag.getAttribute == null)
+      return "";
+   var attrVal = tag.getAttribute("netui:scopeId");
+   if (attrVal != null)
+      return attrVal;
+   return getScopeId(tag.parentNode);
+}
+
+// lookup by tagId to "real id"
+function lookupIdByTagId(id, tag)
+{
+   var scopeId = lookupScopeId(tag,".");
+   return (scopeId == "") ? id : scopeId + id;
+}
+
+//Non-Legacy lookup method creating a fully qualified scope id
+function lookupScopeId(tag,sep)
+{
+   var val = "";
+   while (tag != null &amp;&amp; tag.getAttribute != null) {
+      var attrVal = tag.getAttribute("netui:scopeId");
+      if (attrVal != null)
+         val = attrVal + sep + val;
+      tag = tag.parentNode;
+   }
+   return val;
+}
+-->
+&lt;/script>
+
+
+       &lt;/div>
+        &lt;hr>
+        &lt;p style="color: green">
+        &lt;/p>
+        &lt;p id="javaOut">&lt;/p>
+    &lt;/body>
+    &lt;script language="JavaScript" type="text/JavaScript">
+
+    var p = document.getElementById("javaOut");
+    var s1 = document.getElementById("scopeOneSpan");
+
+    var val = "&lt;b>Document Access&lt;/b>&lt;br>";
+    val = val + "&lt;b>ScopeId&lt;/b>: " + lookupScopeId(s1,".") + "&lt;br>";
+
+    val = val + "Span by name is null: &lt;b>" +
+        (document.getElementById(lookupIdByTagId("span",s1)) == null) + 
"&lt;/b>&lt;br>";
+
+    if (typeof(netui_names) != "undefined") {
+       val = val + "&lt;b>netui_names (Legacy):&lt;/b>&lt;br>";
+       for (var x in netui_names) {
+           val = val + "Name '" + x + "' value '" + netui_names[x] + "'";
+       }
+       val = val + "&lt;br>";
+    }
+    else {
+       val = val + "netui_name (Legacy) is &lt;b>undefined&lt;/b>&lt;br>";
+    }
+
+    p.innerHTML = val;
+
+    &lt;/script>
+&lt;/div>
+&lt;/html></ses:responseBody>
+         </ses:response>
+      </ses:test>
+   </ses:tests>
+   <ses:endDate>13 Jan 2005, 02:37:51.944 PM MST</ses:endDate>
+   <ses:testCount>1</ses:testCount>
+</ses:recorderSession>
\ No newline at end of file

Reply via email to