Author: dolander Date: Fri Jan 14 20:08:13 2005 New Revision: 125250 URL: http://svn.apache.org/viewcvs?view=rev&rev=125250 Log: Fix for Jira Bug 173. The Body tag was not fully qualifying the generated id value. Added a test verifying the correct behavior.
Added: incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/idmap/nonCtrlsNested/ incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/idmap/nonCtrlsNested/Controller.jpf incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/idmap/nonCtrlsNested/alien.gif (contents, props changed) incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/idmap/nonCtrlsNested/index.jsp incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/IdMapNonCtrlsNested.xml Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Body.java incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/IdMapNonCtrls.xml Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Body.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Body.java?view=diff&rev=125250&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Body.java&r1=125249&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Body.java&r2=125250 ============================================================================== --- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Body.java (original) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Body.java Fri Jan 14 20:08:13 2005 @@ -39,6 +39,7 @@ private BodyTag.State _state = new BodyTag.State(); private TagRenderingBase _br; private WriteRenderAppender _writer; + private String _idScript; /** * Return the name of the Tag. @@ -184,6 +185,11 @@ */ public int doStartTag() throws JspException { + // we assume that tagId will over have override id if both are defined. + if (_state.id != null) { + _idScript = renderNameAndId(_state, null); + } + // render the header... _writer = new WriteRenderAppender(pageContext); _br = TagRenderingBase.Factory.getRendering(TagRenderingBase.BODY_TAG, pageContext.getRequest()); @@ -203,12 +209,6 @@ reportErrors(); } - // we assume that tagId will over have override id if both are defined. - String scriptId = null; - if (_state.id != null) { - scriptId = renderNameAndId(_state, null); - } - IScriptReporter sr = getScriptReporter(); if (sr != null) { if (!sr.isInitScriptWritten()) { @@ -225,8 +225,8 @@ } } - if (scriptId != null) - write(scriptId); + if (_idScript != null) + write(_idScript); _br.doEndTag(_writer); Added: incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/idmap/nonCtrlsNested/Controller.jpf Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/idmap/nonCtrlsNested/Controller.jpf?view=auto&rev=125250 ============================================================================== --- (empty file) +++ incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/idmap/nonCtrlsNested/Controller.jpf Fri Jan 14 20:08:13 2005 @@ -0,0 +1,39 @@ +package idmap.nonCtrlsNested; + +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 +{ + @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) + { + } +} Added: incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/idmap/nonCtrlsNested/alien.gif Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/idmap/nonCtrlsNested/alien.gif?view=auto&rev=125250 ============================================================================== Binary file. No diff available. Added: incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/idmap/nonCtrlsNested/index.jsp Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/idmap/nonCtrlsNested/index.jsp?view=auto&rev=125250 ============================================================================== --- (empty file) +++ incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/idmap/nonCtrlsNested/index.jsp Fri Jan 14 20:08:13 2005 @@ -0,0 +1,67 @@ +<%@ 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 tagId="body"> + <span id="scopeSpan" /> + <p style="color: green">This test sets the tagId on all of the + non-HTML Controls. This we lookup each and verify that we find + them based upon the tagId. + </p> + <netui:anchor tagId="anchor" action="begin">Begin</netui:anchor><br> + <netui:area tagId="area" action="begin"/><br> + <netui:span tagId="span" value="span" /><br> + <netui:image tagId="image" src="alien.gif" /><br> + <netui:imageButton tagId="imageButton" src="alien.gif" /><br> + <netui:imageAnchor tagId="imageAnchor" action="begin" src="alien.gif" /><br> + <hr> + <p style="color: green">Below we sure for each of the non-HTML Controls + using the tagId. All should be false. <b>Note:</b> under FireFox + the area tag will be reported as true. This does work under IE. After + the lookups we will dump the IdMap. + </p> + <p id="javaOut"></p> + </netui:body> + <script language="JavaScript" type="text/JavaScript"> + + var p = document.getElementById("javaOut"); + var s = document.getElementById("scopeSpan"); + + var val = "<b>Document Access</b><br>"; + + val = val + "Body by id is null: <b>" + + (document.getElementById(lookupIdByTagId("body",s)) == null) + "</b><br>"; + val = val + "Anchor by id is null: <b>" + + (document.getElementById(lookupIdByTagId("anchor",s)) == null) + "</b><br>"; + val = val + "Area by id is null: <b>" + + (document.getElementById(lookupIdByTagId("area",s)) == null) + "</b><br>"; + val = val + "Span by id is null: <b>" + + (document.getElementById(lookupIdByTagId("span",s)) == null) + "</b><br>"; + val = val + "Image by id is null: <b>" + + (document.getElementById(lookupIdByTagId("image",s)) == null) + "</b><br>"; + val = val + "ImageButton by id is null: <b>" + + (document.getElementById(lookupIdByTagId("imageButton",s)) == null) + "</b><br>"; + val = val + "ImageAnchor by id is null: <b>" + + (document.getElementById(lookupIdByTagId("imageAnchor",s)) == null) + "</b><br>"; + + val = val + "<br>"; + if (typeof(netui_tagIdMap) != "undefined") { + val = val + "<b>tagIdMap:</b><br>"; + for (var x in netui_tagIdMap) { + val = val + "Name '" + x + "' value '" + netui_tagIdMap[x] + "'<br>"; + } + val = val + "<br>"; + } + else { + val = val + "tagIdMap 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=125250&p1=incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml&r1=125249&p2=incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml&r2=125250 ============================================================================== --- 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 Fri Jan 14 20:08:13 2005 @@ -3207,6 +3207,19 @@ </features> </test> <test> + <name>IdMapNonCtrlsNested</name> + <description>Verify the non-HTML controls produce tagId lookup in a nested ScriptContainer</description> + <webapp>coreWeb</webapp> + <categories> + <category>bvt</category> + <category>tags</category> + </categories> + <features> + <feature>JavaScript</feature> + <feature>tagid</feature> + </features> + </test> + <test> <name>IdMapScopeId</name> <description>Test of the getScopeId call.</description> <webapp>coreWeb</webapp> Modified: incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/IdMapNonCtrls.xml Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/IdMapNonCtrls.xml?view=diff&rev=125250&p1=incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/IdMapNonCtrls.xml&r1=125249&p2=incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/IdMapNonCtrls.xml&r2=125250 ============================================================================== --- incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/IdMapNonCtrls.xml (original) +++ incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/IdMapNonCtrls.xml Fri Jan 14 20:08:13 2005 @@ -2,7 +2,7 @@ <ses:recorderSession xmlns:ses="http://beehive.apache.org/netui/tools/testrecorder/2004/session"> <ses:sessionName>IdMapNonCtrls</ses:sessionName> <ses:tester>Daryl</ses:tester> - <ses:startDate>13 Jan 2005, 09:01:52.376 AM MST</ses:startDate> + <ses:startDate>14 Jan 2005, 08:54:40.684 PM MST</ses:startDate> <ses:description>Daryl</ses:description> <ses:tests> <ses:test> @@ -18,7 +18,7 @@ <ses:cookies> <ses:cookie> <ses:name>JSESSIONID</ses:name> - <ses:value>919809676555E106B8773D06B639EEE3</ses:value> + <ses:value>228B8B3835EBC169DDDADFAEF28089AE</ses:value> </ses:cookie> </ses:cookies> <ses:headers> @@ -44,7 +44,7 @@ </ses:header> <ses:header> <ses:name>cookie</ses:name> - <ses:value>$Version=0; JSESSIONID=919809676555E106B8773D06B639EEE3; $Path=/coreWeb</ses:value> + <ses:value>$Version=0; JSESSIONID=228B8B3835EBC169DDDADFAEF28089AE; $Path=/coreWeb</ses:value> </ses:header> <ses:header> <ses:name>host</ses:name> @@ -56,7 +56,7 @@ </ses:header> <ses:header> <ses:name>testrecorder.playback.testid</ses:name> - <ses:value>1db1d115:1016ccb50cb:-7cdb</ses:value> + <ses:value>38ada972:101747830e7:-7cd7</ses:value> </ses:header> <ses:header> <ses:name>user-agent</ses:name> @@ -108,8 +108,8 @@ netui_names.image="image" netui_names.imageAnchor="imageAnchor" netui_names.area="area" -netui_names.body="body" netui_names.span="span" +netui_names.body="body" netui_names.anchor="anchor" @@ -207,7 +207,7 @@ </ses:testResults> </ses:test> </ses:tests> - <ses:endDate>13 Jan 2005, 09:01:53.027 AM MST</ses:endDate> + <ses:endDate>14 Jan 2005, 08:54:42.076 PM MST</ses:endDate> <ses:sessionStatus>fail</ses:sessionStatus> <ses:testCount>1</ses:testCount> <ses:passedCount>0</ses:passedCount> Added: incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/IdMapNonCtrlsNested.xml Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/IdMapNonCtrlsNested.xml?view=auto&rev=125250 ============================================================================== --- (empty file) +++ incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/IdMapNonCtrlsNested.xml Fri Jan 14 20:08:13 2005 @@ -0,0 +1,207 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ses:recorderSession xmlns:ses="http://beehive.apache.org/netui/tools/testrecorder/2004/session"> + <ses:sessionName>IdMapNonCtrlsNested</ses:sessionName> + <ses:tester>Daryl</ses:tester> + <ses:startDate>14 Jan 2005, 08:29:08.371 PM MST</ses:startDate> + <ses:description>Test of the non-Ctrls in a nested situation</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/nonCtrlsNested/Controller.jpf</ses:uri> + <ses:method>GET</ses:method> + <ses:parameters/> + <ses:cookies> + <ses:cookie> + <ses:name>JSESSIONID</ses:name> + <ses:value>7DB5F879C1CD105FAFBD91CC2AEF8767</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=7DB5F879C1CD105FAFBD91CC2AEF8767</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><!DOCTYPE HTML PUBLIC "//W3C//DTD HTML 4.01 Transitional//EN" + "http://www.w3.org/TR/html4/loose.dtd"> +<html lang="en" netui:scopeId="html"> + + <head> + <base href="http://localhost:8080/coreWeb/idmap/nonCtrlsNested/index.jsp"> + </head> + <body id="html.body"> + <span id="scopeSpan" /> + <p style="color: green">This test sets the tagId on all of the + non-HTML Controls. This we lookup each and verify that we find + them based upon the tagId. + </p> + <a id="html.anchor" href="/coreWeb/idmap/nonCtrlsNested/begin.do">Begin</a><br> + <area id="html.area" href="/coreWeb/idmap/nonCtrlsNested/begin.do"><br> + <span id="html.span">span</span><br> + <img src="/coreWeb/idmap/nonCtrlsNested/alien.gif" id="html.image"><br> + <input type="image" id="html.imageButton" src="/coreWeb/idmap/nonCtrlsNested/alien.gif"><br> + <a id="html.imageAnchor" href="/coreWeb/idmap/nonCtrlsNested/begin.do"><img src="/coreWeb/idmap/nonCtrlsNested/alien.gif"></a><br> + <hr> + <p style="color: green">Below we sure for each of the non-HTML Controls + using the tagId. All should be false. <b>Note:</b> under FireFox + the area tag will be reported as true. This does work under IE. After + the lookups we will dump the IdMap. + </p> + <p id="javaOut"></p> + + +<script language="JavaScript" type="text/JavaScript"> +<!-- + +// **** 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.html__imageButton="html.imageButton" +netui_names.html__image="html.image" +netui_names.html__imageAnchor="html.imageAnchor" +netui_names.html__area="html.area" +netui_names.html__span="html.span" +netui_names.html__body="html.body" +netui_names.html__anchor="html.anchor" + + +// **** 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 && tag.getAttribute != null) { + var attrVal = tag.getAttribute("netui:scopeId"); + if (attrVal != null) + val = attrVal + sep + val; + tag = tag.parentNode; + } + return val; +} +--> +</script> + +</body> + <script language="JavaScript" type="text/JavaScript"> + + var p = document.getElementById("javaOut"); + var s = document.getElementById("scopeSpan"); + + var val = "<b>Document Access</b><br>"; + + val = val + "Body by id is null: <b>" + + (document.getElementById(lookupIdByTagId("body",s)) == null) + "</b><br>"; + val = val + "Anchor by id is null: <b>" + + (document.getElementById(lookupIdByTagId("anchor",s)) == null) + "</b><br>"; + val = val + "Area by id is null: <b>" + + (document.getElementById(lookupIdByTagId("area",s)) == null) + "</b><br>"; + val = val + "Span by id is null: <b>" + + (document.getElementById(lookupIdByTagId("span",s)) == null) + "</b><br>"; + val = val + "Image by id is null: <b>" + + (document.getElementById(lookupIdByTagId("image",s)) == null) + "</b><br>"; + val = val + "ImageButton by id is null: <b>" + + (document.getElementById(lookupIdByTagId("imageButton",s)) == null) + "</b><br>"; + val = val + "ImageAnchor by id is null: <b>" + + (document.getElementById(lookupIdByTagId("imageAnchor",s)) == null) + "</b><br>"; + + val = val + "<br>"; + if (typeof(netui_tagIdMap) != "undefined") { + val = val + "<b>tagIdMap:</b><br>"; + for (var x in netui_tagIdMap) { + val = val + "Name '" + x + "' value '" + netui_tagIdMap[x] + "'<br>"; + } + val = val + "<br>"; + } + else { + val = val + "tagIdMap is <b>undefined</b><br>"; + } + + p.innerHTML = val; + + </script> +</div> +</html></ses:responseBody> + </ses:response> + </ses:test> + </ses:tests> + <ses:endDate>14 Jan 2005, 08:29:21.570 PM MST</ses:endDate> + <ses:testCount>1</ses:testCount> +</ses:recorderSession> \ No newline at end of file
