You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xap-commits@incubator.apache.org by jm...@apache.org on 2007/04/05 00:42:59 UTC
svn commit: r525661 - in /incubator/xap/trunk:
codebase/src/xap/bridges/basic/ codebase/src/xap/bridges/ext/
codebase/src/xap/taghandling/ unittests/testsrc/
unittests/testsrc/xap/bridges/basic/
Author: jmargaris
Date: Wed Apr 4 17:42:58 2007
New Revision: 525661
URL: http://svn.apache.org/viewvc?view=rev&rev=525661
Log:
Html pane/view changes along with tests
Added:
incubator/xap/trunk/unittests/testsrc/XapConfig-Min.js (with props)
incubator/xap/trunk/unittests/testsrc/xap/bridges/basic/_TestHtmlViewBridge.html (with props)
incubator/xap/trunk/unittests/testsrc/xap/bridges/basic/_TestHtmlViewBridge.js (with props)
incubator/xap/trunk/unittests/testsrc/xap/bridges/basic/page.xal (with props)
incubator/xap/trunk/unittests/testsrc/xap/bridges/basic/sometext.txt (with props)
incubator/xap/trunk/unittests/testsrc/xap/bridges/basic/somexal.txt (with props)
Removed:
incubator/xap/trunk/codebase/src/xap/bridges/ext/HtmlPaneBridge.js
Modified:
incubator/xap/trunk/codebase/src/xap/bridges/basic/HtmlViewBridge.js
incubator/xap/trunk/codebase/src/xap/taghandling/plugin.xml
incubator/xap/trunk/unittests/testsrc/XapUnitTestSuite.html
Modified: incubator/xap/trunk/codebase/src/xap/bridges/basic/HtmlViewBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/bridges/basic/HtmlViewBridge.js?view=diff&rev=525661&r1=525660&r2=525661
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/bridges/basic/HtmlViewBridge.js (original)
+++ incubator/xap/trunk/codebase/src/xap/bridges/basic/HtmlViewBridge.js Wed Apr 4 17:42:58 2007
@@ -24,8 +24,11 @@
/**
* @fileoverview
- *
- * A bridge class that controls a blob of html.
+ * A bridge class that allows to embed HTML fragment into XAL file.
+ * Using XInclude tag will result in href content being inserted.
+ * For all other XAL tags result is undefined.
+ *
+ *
*/
/**
@@ -39,25 +42,26 @@
*
* @author bbuffone
*/
-xap.bridges.basic.HtmlViewBridge = function() {
- xap.bridges.basic.AbstractWidgetBridge.call( this );
-}
+xap.bridges.basic.HtmlViewBridge = function() {};
+
+Xap.setupClassAsSubclassOf("xap.bridges.basic.HtmlViewBridge", "xap.bridges.basic.AbstractWidgetBridge");
-xap.bridges.basic.HtmlViewBridge.prototype = new xap.bridges.basic.AbstractWidgetBridge;
+/**
+ * Instantiates a node.
+ *
+ *
+ */
xap.bridges.basic.HtmlViewBridge.prototype.init = function() {
+
xap.bridges.basic.AbstractWidgetBridge.prototype.init.call( this );
//parse initial children has the children add themselves to the parent
- //but that doesn't work well for plain old text/html children without any
- //handlers, so look for a child here
- if (!xap.taghandling.AbstractTagImpl.TAIL_RECURSION){
- for (var i = 0; i<this.getElement().childNodes.length;i++){
- this.childAdded(new xap.xml.dom.events.StructureChangeEvent(
- this.getElement(),this.getElement().childNodes[i], -1 ));
- }
- }
-}
+ this.updatePeer(this.getPeer());
+
+};
+
+
/**
* Creates the peer component that this bridge controls.
*/
@@ -65,32 +69,83 @@
var myDiv = document.createElement("div");
myDiv.style.overflow = "auto";
this.setPeer(myDiv);
-}
+};
+
+
+/**
+ * Sets the inner HTML of the peer.
+ * @param peer Peer node (HTML <div> node)
+ *
+ */
+xap.bridges.basic.HtmlViewBridge.prototype.updatePeer = function(peer) {
-xap.bridges.basic.HtmlViewBridge.prototype.childAdded = function( e ) {
+ var nodeText = '';
+ var children = this.getElement().childNodes;
- var peer = this.getPeer();
- var childElement = e.getChange();
+ // collect values from all text node children and all HTML children
+ for(var n = 0; n < children.length; n++) {
- //this only handles the first child particularly well
- if (childElement.nodeType==google.DOM_TEXT_NODE){
- peer.innerHTML += childElement.nodeValue;
+ var childElement = children[n];
+
+ //this only handles the first child particularly well
+ if (childElement.nodeType == google.DOM_TEXT_NODE){
+ nodeText += childElement.nodeValue;
+ } else if(childElement.nodeType == google.DOM_ELEMENT_NODE) {
+ //if the element does not have a handler just convert it to xml/html
+ // right now we only test for xinclude
+ if( ! this.getUiContentHandler().getHandlerForElement( childElement ) ) {
+ nodeText += childElement.toXmlWithoutAutoAssignedIds();
+ }
+ }
}
- if (childElement.nodeType==google.DOM_ELEMENT_NODE){
- peer.innerHTML += childElement.toXml();
+
+ // update HTML node
+ peer.innerHTML = nodeText;
+};
+
+
+
+/**
+ * Updates peer when child node is added.
+ * We don't expect this to happen often.
+ * @param e Event
+ *
+ */
+xap.bridges.basic.HtmlViewBridge.prototype.onChildAdded = function (e) {
+
+ // call superclass
+ xap.bridges.basic.AbstractWidgetBridge.prototype.onChildAdded.call(this, e);
+
+ // refresh peer, skip if XAL node
+ var childElement = e.getChange();
+ if(this.getUiContentHandler().getHandlerForElement( childElement )) {
+ return;
}
-}
+ this.updatePeer(this.getPeer());
+
+};
+
+
+
+/**
+ * Updates peer when child node is removed.
+ * We don't expect this to happen often.
+ * @param e Event
+ *
+ */
xap.bridges.basic.HtmlViewBridge.prototype.onChildRemoved = function (e) {
+
+ // call superclass
+ xap.bridges.basic.AbstractWidgetBridge.prototype.onChildRemoved.call(this, e);
+
+ // refresh peer, skip if XAL node
var childElement = e.getChange();
-
- //if they remove the first child blank out the text
- if (this.getElement().firstChild==childElement){
- this.getPeer().innerHTML = "";
- }
- //cleanup stuff
- xap.taghandling.AbstractTagImpl.prototype.onChildRemoved.call( this, e );
-}
+ if(this.getUiContentHandler().getHandlerForElement( childElement )) {
+ return;
+ }
+ this.updatePeer(this.getPeer());
+};
@@ -101,4 +156,4 @@
*/
xap.bridges.basic.HtmlViewBridge.prototype.getRootDomNode = function(){
return this.getPeer();
-}
+};
Modified: incubator/xap/trunk/codebase/src/xap/taghandling/plugin.xml
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/taghandling/plugin.xml?view=diff&rev=525661&r1=525660&r2=525661
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/taghandling/plugin.xml (original)
+++ incubator/xap/trunk/codebase/src/xap/taghandling/plugin.xml Wed Apr 4 17:42:58 2007
@@ -170,7 +170,6 @@
<tag-mappings namespace="http://openxal.org/ext" document="ui">
<mapping class="xap.bridges.ext.HelloWorldBridge" name="helloWorld"/>
- <mapping class="xap.bridges.ext.HtmlPaneBridge" name="htmlPane"/>
<mapping class="xap.bridges.ext.EffectsBridge" name="effectsPane"/>
</tag-mappings>
</plugin>
Added: incubator/xap/trunk/unittests/testsrc/XapConfig-Min.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/unittests/testsrc/XapConfig-Min.js?view=auto&rev=525661
==============================================================================
--- incubator/xap/trunk/unittests/testsrc/XapConfig-Min.js (added)
+++ incubator/xap/trunk/unittests/testsrc/XapConfig-Min.js Wed Apr 4 17:42:58 2007
@@ -0,0 +1,101 @@
+/**
+ * This is the default Xap configuration file that will be used to specified
+ * different runtime settings of the Xap application. Xap application provide
+ * for paramenter overriding in the following way.
+ *
+ * The default values for an application come from this file. When an application is loaded
+ * the developer can specify a configuration object to the Xap.createApplication method.
+ * any value in that object will override these parameters (Array parameters will NOT be merged).
+ * If the developer has specified page scaning then the Xap attributes on the HTML element
+ * will then override the values supplied to the Xap.createApplication. Each HTML element that is
+ * found is treated as a seperate XAP application.
+ *
+ * Parameter Override workflow:
+ * 1) This configuration file.
+ * 2a) The config object specified to the Xap.createApplication method.
+ * 2b) Any xap parameters embeded in a html element found during page scanning.
+ *
+ * For more information on using the JSON format go to www.json.org.
+ */
+{
+ /**
+ * This is the default name for the application. Users can access this
+ * application by using the Xap.applications["myApplicationName"]
+ *
+ * Accepted Values: can be null, undefined, or any String.
+ */
+ applicationName: "Application",
+ /**
+ * This is the default starting page for the application. When the application is
+ * started it will load this page to create the applications user interface.
+ *
+ * Accepted Values: can be null, undefined, or any url the is an acceptable Xal document.
+ */
+ startPage: null,
+ /**
+ * This is the default context for the application. When resources are loaded either by
+ * using the request service or as a event handler.
+ *
+ * Accepted Values: The root of the application as compared to the start web page.
+ */
+ context: "/jsunit/",
+ /**
+ * This is the default srcPath for the application. When resources are loaded either by
+ * using the request service or as a event handler.
+ *
+ * Accepted Values: The location of the xap src as compared to the start web page.
+ */
+ srcPath: "/jsunit/src/",
+ /**
+ * This is the default toolkit type.
+ *
+ * Accepted Values: any defined toolkit.
+ */
+ toolkitType: "dojo",
+ /**
+ * This is the default list of plugin classes that will be loaded. Place any class that needs
+ * to be loaded into during initialization.
+ *
+ * Accepted Values: can be null, undefined, or any Array of class names.
+ */
+ pluginClasses: [
+ //"xap.mco.McoNamespaceHandler",
+ "xap.xml.xmodify.XmodifyNamespaceHandler",
+ //"xap.macro.MacroNamespaceHandler",
+ "xap.xml.XalNamespaceHandler"
+ //"xap.data.DataNamespaceHandler",
+ //"xap.datarequest.DataRequestPlugin",
+ //"xap.protocol.CspPlugin"
+ ],
+
+ /**
+ * This is the default list of plugin classes that will be loaded. Place any class that needs
+ * to be loaded into during initialization. Plugin classes need to implement the "pluginLoaded"
+ * method.
+ *
+ * Accepted Values: can be null, undefined, or any Array of class names.
+ */
+ pluginFiles: [
+ "src/xap/taghandling/plugin.xml"
+ //"src/xap/datarequest/plugin.xml"
+ ],
+ /**
+ * This is the default id of the html element that will host the Xap application.
+ * If the element is null or undefined then the root is assumed to be the body.
+ *
+ * Accepted Values: can be null, undefined, or id of the element that will be the
+ * root of the application.
+ */
+ element: null,
+ /**
+ * The logLevel controls the logging level.
+ * Accepted Values: TRACE, DEBUG, INFO, WARN, ERROR, FATAL, NONE
+ */
+ logLevel: 'WARN',
+
+ /**
+ * Array of appender names, eitehr built in or custom.
+ * TODO make configuration more like log4j
+ */
+ logAppenders: ['xap.log.ConsoleAppender', 'xap.log.AlertAppender']
+}
Propchange: incubator/xap/trunk/unittests/testsrc/XapConfig-Min.js
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/xap/trunk/unittests/testsrc/XapUnitTestSuite.html
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/unittests/testsrc/XapUnitTestSuite.html?view=diff&rev=525661&r1=525660&r2=525661
==============================================================================
--- incubator/xap/trunk/unittests/testsrc/XapUnitTestSuite.html (original)
+++ incubator/xap/trunk/unittests/testsrc/XapUnitTestSuite.html Wed Apr 4 17:42:58 2007
@@ -93,7 +93,13 @@
var result = new top.jsUnitTestSuite();
result.addTestPage( webappContext + "/testsrc/xap/mco/_TestDeclarativeArgumentParser.html" );
return result;
- }
+ }
+
+ function bridgesSuite( webappContext ) {
+ var result = new top.jsUnitTestSuite();
+ result.addTestPage( webappContext + "/testsrc/xap/bridges/basic/_TestHtmlViewBridge.html" );
+ return result;
+ }
function suite() {
@@ -109,6 +115,7 @@
suite.addTestSuite( sessionSuite( webappContext ) );
suite.addTestSuite( xModifySuite( webappContext ) );
suite.addTestSuite( xModifyHTMLSuite( webappContext ) );
+ suite.addTestSuite( bridgesSuite( webappContext ) );
return suite;
Added: incubator/xap/trunk/unittests/testsrc/xap/bridges/basic/_TestHtmlViewBridge.html
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/unittests/testsrc/xap/bridges/basic/_TestHtmlViewBridge.html?view=auto&rev=525661
==============================================================================
--- incubator/xap/trunk/unittests/testsrc/xap/bridges/basic/_TestHtmlViewBridge.html (added)
+++ incubator/xap/trunk/unittests/testsrc/xap/bridges/basic/_TestHtmlViewBridge.html Wed Apr 4 17:42:58 2007
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <title>Unit Test</title>
+ <link rel="stylesheet" type="text/css" href="/jsunit/jsunit/css/jsUnitStyle.css" />
+ <script language="JavaScript" type="text/javascript" src="/jsunit/jsunit/app/jsUnitCore.js"></script>
+ <script language="JavaScript" type="text/javascript" src="/jsunit/src/dojo/dojo.js"></script>
+ <script language="JavaScript" type="text/javascript" src="/jsunit/src/xap/Xap.js"></script>
+ <script language="JavaScript" type="text/javascript" src="/jsunit/src/xap/util/Utils.js"></script>
+ <script language="JavaScript" type="text/javascript" src="_TestHtmlViewBridge.js"></script>
+ <script type="text/javascript">
+
+ </script>
+</head>
+<body>
+<div id='Application' applicationName='Application'/>
+</body>
+</html>
+
\ No newline at end of file
Propchange: incubator/xap/trunk/unittests/testsrc/xap/bridges/basic/_TestHtmlViewBridge.html
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/xap/trunk/unittests/testsrc/xap/bridges/basic/_TestHtmlViewBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/unittests/testsrc/xap/bridges/basic/_TestHtmlViewBridge.js?view=auto&rev=525661
==============================================================================
--- incubator/xap/trunk/unittests/testsrc/xap/bridges/basic/_TestHtmlViewBridge.js (added)
+++ incubator/xap/trunk/unittests/testsrc/xap/bridges/basic/_TestHtmlViewBridge.js Wed Apr 4 17:42:58 2007
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+function exposeTestFunctionNames() {
+ return ['testHtmlViewBridge'];
+}
+
+function setUpPage() {
+ var applicationConfig = {
+ applicationName: 'Application',
+ startPage: '/jsunit/testsrc/xap/bridges/basic/page.xal',
+ context: '/jsunit/',
+ srcPath: '/jsunit/src/',
+ scanPage: false,
+ element: document.getElementById('Application'),
+ configFilePath: '/jsunit/testsrc/XapConfig-Min.js' };
+
+ var app = Xap.createApplication(applicationConfig);
+
+ setUpPageStatus = 'complete';
+}
+
+/**********************************************************/
+
+function testHtmlViewBridge () {
+
+ var element1 = document.getElementById('testId1');
+ assertFalse('element1 should not be null', element1 === null);
+ assertEquals('ab <b>cd</b> ef', element1.innerHTML.toLowerCase());
+
+ var element2 = document.getElementById('testId2');
+ assertFalse('element2 should not be null', element2 === null);
+ assertEquals('<label></label>', element2.innerHTML.toLowerCase());
+
+ var element3 = document.getElementById('testId3');
+ assertFalse('testId3 should not be null',element3 === null);
+ assertEquals('One Two Three ... ', element3.innerHTML);
+
+ var element4 = document.getElementById('testId4');
+ assertFalse('element4 should not be null',element4 === null);
+ assertEquals('<label></label>', element4.innerHTML.toLowerCase());
+
+ var element5 = document.getElementById('testId5');
+ assertFalse('element5 should not be null',element5 === null);
+ assertEquals('<span>hello, world!</span>', element5.innerHTML.toLowerCase());
+
+
+}
+
+
Propchange: incubator/xap/trunk/unittests/testsrc/xap/bridges/basic/_TestHtmlViewBridge.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/xap/trunk/unittests/testsrc/xap/bridges/basic/page.xal
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/unittests/testsrc/xap/bridges/basic/page.xal?view=auto&rev=525661
==============================================================================
--- incubator/xap/trunk/unittests/testsrc/xap/bridges/basic/page.xal (added)
+++ incubator/xap/trunk/unittests/testsrc/xap/bridges/basic/page.xal Wed Apr 4 17:42:58 2007
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xal xmlns="http://openxal.org/ui/html"
+ xmlns:xi="http://openxal.org/core/xinclude"
+ xmlns:xm="http://openxal.org/core/xmodify" >
+ <rootPane>
+ <htmlView id='testId1'>ab <b>cd</b> ef</htmlView>
+ <htmlView id='testId2'><![CDATA[<label />]]></htmlView>
+ <htmlView id='testId3'><xi:include parse="text" href="/jsunit/testsrc/xap/bridges/basic/sometext.txt"/></htmlView>
+ <htmlView id='testId4'><xi:include parse="text" href="/jsunit/testsrc/xap/bridges/basic/somexal.txt"/></htmlView>
+ <htmlView id='testId5'/>
+ </rootPane>
+ <xm:modifications>
+ <xm:append select="id('testId5')">
+ <span>Hello, world!</span>
+ </xm:append>
+ </xm:modifications>
+</xal>
\ No newline at end of file
Propchange: incubator/xap/trunk/unittests/testsrc/xap/bridges/basic/page.xal
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/xap/trunk/unittests/testsrc/xap/bridges/basic/sometext.txt
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/unittests/testsrc/xap/bridges/basic/sometext.txt?view=auto&rev=525661
==============================================================================
--- incubator/xap/trunk/unittests/testsrc/xap/bridges/basic/sometext.txt (added)
+++ incubator/xap/trunk/unittests/testsrc/xap/bridges/basic/sometext.txt Wed Apr 4 17:42:58 2007
@@ -0,0 +1 @@
+One Two Three ...
\ No newline at end of file
Propchange: incubator/xap/trunk/unittests/testsrc/xap/bridges/basic/sometext.txt
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/xap/trunk/unittests/testsrc/xap/bridges/basic/somexal.txt
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/unittests/testsrc/xap/bridges/basic/somexal.txt?view=auto&rev=525661
==============================================================================
--- incubator/xap/trunk/unittests/testsrc/xap/bridges/basic/somexal.txt (added)
+++ incubator/xap/trunk/unittests/testsrc/xap/bridges/basic/somexal.txt Wed Apr 4 17:42:58 2007
@@ -0,0 +1 @@
+<label />
\ No newline at end of file
Propchange: incubator/xap/trunk/unittests/testsrc/xap/bridges/basic/somexal.txt
------------------------------------------------------------------------------
svn:eol-style = native