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 2006/11/09 01:15:36 UTC
svn commit: r472731 - in /incubator/xap/trunk:
WebContent/examples/urlResolution/ WebContent/examples/urlResolution/images/
WebContent/examples/urlResolution/xmodify/ src/google/ src/xap/bridges/xap/
src/xap/requestservice/ src/xap/session/ src/xap/tag...
Author: jmargaris
Date: Wed Nov 8 17:15:35 2006
New Revision: 472731
URL: http://svn.apache.org/viewvc?view=rev&rev=472731
Log:
url resolution fixes along with sample illustrating them
Added:
incubator/xap/trunk/WebContent/examples/urlResolution/images/background.JPG (with props)
incubator/xap/trunk/WebContent/examples/urlResolution/images/foreground.JPG (with props)
incubator/xap/trunk/WebContent/examples/urlResolution/label.html (with props)
incubator/xap/trunk/WebContent/examples/urlResolution/label.xal (with props)
incubator/xap/trunk/WebContent/examples/urlResolution/xmodify/xmodify.xm (with props)
incubator/xap/trunk/WebContent/examples/urlResolution/xmodify/xmodify2.xm (with props)
incubator/xap/trunk/testsrc/xap/requestservice/_TestRequestService.html (with props)
incubator/xap/trunk/testsrc/xap/requestservice/_TestRequestService.js (with props)
Modified:
incubator/xap/trunk/src/google/dom.js
incubator/xap/trunk/src/xap/bridges/xap/LabelBridge.js
incubator/xap/trunk/src/xap/requestservice/RequestService.js
incubator/xap/trunk/src/xap/session/EventHandler.js
incubator/xap/trunk/src/xap/taghandling/AbstractTagImpl.js
incubator/xap/trunk/src/xap/xml/dom/XapElement.js
incubator/xap/trunk/src/xap/xml/ie/Parser.js
incubator/xap/trunk/src/xap/xml/sax/SaxContentHandler.js
incubator/xap/trunk/src/xap/xml/sax/SaxParser.js
incubator/xap/trunk/src/xap/xml/xmodify/CommandDirective.js
incubator/xap/trunk/src/xap/xml/xmodify/DirectiveSet.js
incubator/xap/trunk/src/xap/xml/xmodify/Xmodify.js
incubator/xap/trunk/testsrc/XapUnitTestSuite.html
Added: incubator/xap/trunk/WebContent/examples/urlResolution/images/background.JPG
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/urlResolution/images/background.JPG?view=auto&rev=472731
==============================================================================
Binary file - no diff available.
Propchange: incubator/xap/trunk/WebContent/examples/urlResolution/images/background.JPG
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/xap/trunk/WebContent/examples/urlResolution/images/foreground.JPG
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/urlResolution/images/foreground.JPG?view=auto&rev=472731
==============================================================================
Binary file - no diff available.
Propchange: incubator/xap/trunk/WebContent/examples/urlResolution/images/foreground.JPG
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/xap/trunk/WebContent/examples/urlResolution/label.html
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/urlResolution/label.html?view=auto&rev=472731
==============================================================================
--- incubator/xap/trunk/WebContent/examples/urlResolution/label.html (added)
+++ incubator/xap/trunk/WebContent/examples/urlResolution/label.html Wed Nov 8 17:15:35 2006
@@ -0,0 +1,28 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Simple XAP Widget Example</title>
+
+ <style type="text/css">
+ <!--
+ @import url(../../css/xapDefault.css);
+ -->
+ </style>
+
+ <!-- Keep dojo from trying to scan this whole page for dojoType'd tags: -->
+ <script type="text/javascript">
+ djConfig = {
+ parseWidgets: false
+ };
+ </script>
+
+ <script language="JavaScript" type="text/javascript" src="../../xapcore.js"></script>
+ </head>
+
+ <body onload="Xap.createEmbeddedApplications();">
+ <div startPage="label.xal"></div>
+ </body>
+</html>
+
Propchange: incubator/xap/trunk/WebContent/examples/urlResolution/label.html
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/xap/trunk/WebContent/examples/urlResolution/label.xal
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/urlResolution/label.xal?view=auto&rev=472731
==============================================================================
--- incubator/xap/trunk/WebContent/examples/urlResolution/label.xal (added)
+++ incubator/xap/trunk/WebContent/examples/urlResolution/label.xal Wed Nov 8 17:15:35 2006
@@ -0,0 +1,15 @@
+<xal xmlns="http://www.openxal.org/xal" xmlns:xal="http://www.openxal.org/xal">
+ <xm:modifications xmlns:xm="http://www.openxal.org/xmodify">
+ <xm:append select="/xal">
+ <verticalPanel id="panel">
+ <label richText="true" width="400px" text="When you press the button,
+ you should see the label change images and also a new label with
+ the same changed image, along with another button to re-call that same page"/>
+ <label id="testComponent" width="400px" height="100px" alignHorizontal="center" alignVertical="top"
+ text="MY PRECIOUS LABEL" img="images/foreground.JPG"/>
+
+ <button text="Press this first" onCommand="xmodify/xmodify.xm"/>
+ </verticalPanel>
+ </xm:append>
+ </xm:modifications>
+</xal>
\ No newline at end of file
Propchange: incubator/xap/trunk/WebContent/examples/urlResolution/label.xal
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/xap/trunk/WebContent/examples/urlResolution/xmodify/xmodify.xm
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/urlResolution/xmodify/xmodify.xm?view=auto&rev=472731
==============================================================================
--- incubator/xap/trunk/WebContent/examples/urlResolution/xmodify/xmodify.xm (added)
+++ incubator/xap/trunk/WebContent/examples/urlResolution/xmodify/xmodify.xm Wed Nov 8 17:15:35 2006
@@ -0,0 +1,14 @@
+<xal xmlns="http://www.openxal.org/xal" xmlns:xal="http://www.openxal.org/xal">
+ <xm:modifications xmlns:xm="http://www.openxal.org/xmodify">
+ <xm:append select="id('panel')">
+ <label img="../images/background.JPG" />
+ <button text="Press this second" onCommand="xmodify2.xm"/>
+ </xm:append>
+ </xm:modifications>
+
+ <xm:modifications xmlns:xm="http://www.openxal.org/xmodify">
+ <xm:set-attribute select="id('testComponent')">
+ <attribute name="img" value="../images/background.JPG"/>
+ </xm:set-attribute>
+ </xm:modifications>
+</xal>
\ No newline at end of file
Propchange: incubator/xap/trunk/WebContent/examples/urlResolution/xmodify/xmodify.xm
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/xap/trunk/WebContent/examples/urlResolution/xmodify/xmodify2.xm
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/urlResolution/xmodify/xmodify2.xm?view=auto&rev=472731
==============================================================================
--- incubator/xap/trunk/WebContent/examples/urlResolution/xmodify/xmodify2.xm (added)
+++ incubator/xap/trunk/WebContent/examples/urlResolution/xmodify/xmodify2.xm Wed Nov 8 17:15:35 2006
@@ -0,0 +1,14 @@
+<xal xmlns="http://www.openxal.org/xal" xmlns:xal="http://www.openxal.org/xal">
+ <xm:modifications xmlns:xm="http://www.openxal.org/xmodify">
+ <xm:append select="id('panel')">
+ <label img="../images/foreground.JPG" />
+ <button text="Press to call xmodify statement" onCommand="xmodify.xm"/>
+ </xm:append>
+ </xm:modifications>
+
+ <xm:modifications xmlns:xm="http://www.openxal.org/xmodify">
+ <xm:set-attribute select="id('testComponent')">
+ <attribute name="img" value="../images/foreground.JPG"/>
+ </xm:set-attribute>
+ </xm:modifications>
+</xal>
\ No newline at end of file
Propchange: incubator/xap/trunk/WebContent/examples/urlResolution/xmodify/xmodify2.xm
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/xap/trunk/src/google/dom.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/google/dom.js?view=diff&rev=472731&r1=472730&r2=472731
==============================================================================
--- incubator/xap/trunk/src/google/dom.js (original)
+++ incubator/xap/trunk/src/google/dom.js Wed Nov 8 17:15:35 2006
@@ -222,14 +222,32 @@
}
- XNode.prototype.setAttribute = function(name, value) {
- for (var i = 0; i < this.attributes.length; ++i) {
- if (this.attributes[i].nodeName == name) {
- this.attributes[i].nodeValue = '' + value;
- return;
- }
- }
- this.attributes.push(new XNode(DOM_ATTRIBUTE_NODE, name, value));
+ XNode.prototype.setAttribute = function(name, value, baseUrl) {
+ for (var i = 0; i < this.attributes.length; ++i) {
+ if (this.attributes[i].nodeName == name) {
+ this.attributes[i].nodeValue = '' + value;
+
+ //stick on a new baseUrl if appropriate
+ if (baseUrl){
+ this.attributes[i].baseUrl = baseUrl;
+ }
+
+ //if we are changing an existing attribute without any base url
+ // (for example from code ) remove an existing baseUrl we may have
+ else if (this.attributes[i].baseUrl){
+ delete this.attributes[i].baseUrl;
+ }
+ return;
+ }
+ }
+
+ var xnode = new XNode(DOM_ATTRIBUTE_NODE, name, value);
+
+ //stick on a new baseUrl if appropriate
+ if (baseUrl){
+ xnode.baseUrl = baseUrl;
+ }
+ this.attributes.push(xnode);
}
Modified: incubator/xap/trunk/src/xap/bridges/xap/LabelBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/xap/LabelBridge.js?view=diff&rev=472731&r1=472730&r2=472731
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/xap/LabelBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/xap/LabelBridge.js Wed Nov 8 17:15:35 2006
@@ -56,7 +56,8 @@
}
xap.bridges.xap.LabelBridge.prototype.setImgAttribute = function(imgURL) {
- this.getPeer().setImg(imgURL);
+ var newUrl = this.getElement().getAttributeAsUrl("img");
+ this.getPeer().setImg(newUrl);
}
xap.bridges.xap.LabelBridge.prototype.setImgBackgroundAttribute = function(imgURL) {
Modified: incubator/xap/trunk/src/xap/requestservice/RequestService.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/requestservice/RequestService.js?view=diff&rev=472731&r1=472730&r2=472731
==============================================================================
--- incubator/xap/trunk/src/xap/requestservice/RequestService.js (original)
+++ incubator/xap/trunk/src/xap/requestservice/RequestService.js Wed Nov 8 17:15:35 2006
@@ -58,7 +58,7 @@
*/
xap.requestservice.RequestService.prototype.retrieveAndProcess = function(url) {
var content = this.retrieve(url);
- this._processXmlString(content.responseText);
+ this._processXmlString(content.responseText, url);
return content;
}
@@ -90,7 +90,7 @@
if (listener){
if (response.status == xap.util.HttpUtils.OK) {
try{
- self._processXmlString(response.responseText);
+ self._processXmlString(response.responseText, url);
listener.requestCompleted(url, response);
}
catch(e){
@@ -148,7 +148,37 @@
* Parses the xml string into a Document and then walks the resulting Document
* dispatching elements to appropriate NamespaceHandlers.
*/
-xap.requestservice.RequestService.prototype._processXmlString = function( xmlString ) {
+xap.requestservice.RequestService.prototype._processXmlString = function( xmlString, uri ) {
+
+ //need this as "uri" can be an HttpRequest object
+ if (uri.getUri){
+ uri = uri.getUri();
+ }
var parser = xap.xml.ParserFactory.getParser();
- this._clientSession.processDocument( parser.parse( xmlString ) );
-}
\ No newline at end of file
+ this._clientSession.processDocument( parser.parse( xmlString , xap.requestservice.RequestService.urlToPath(uri)) );
+}
+
+/**
+ * Given a url like:
+ * /a/b?c=d
+ *
+ * Turn it into a path ending in slash like /a/
+ */
+xap.requestservice.RequestService.urlToPath = function( url ){
+
+ var lastIndex = url.indexOf("?");
+ if (lastIndex>0){
+ url=url.substring(0,lastIndex);
+ }
+
+ var lastIndex = url.lastIndexOf("/");
+ if (lastIndex>0){
+ url=url.substring(0,lastIndex+1); //include /
+ }
+ else{
+ url = null;
+ }
+
+ return url;
+}
+
\ No newline at end of file
Modified: incubator/xap/trunk/src/xap/session/EventHandler.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/session/EventHandler.js?view=diff&rev=472731&r1=472730&r2=472731
==============================================================================
--- incubator/xap/trunk/src/xap/session/EventHandler.js (original)
+++ incubator/xap/trunk/src/xap/session/EventHandler.js Wed Nov 8 17:15:35 2006
@@ -49,12 +49,11 @@
eventElement, clientEvent ) {
- var isObjectEvent = this._isObjectEvent(eventValue);
//if it's a generic CONTAINER_NAME:OBJECT.METHOD(...) type of event
//then fire that
- if (isObjectEvent){
+ if (this.isObjectEvent(eventValue)){
try{
return this._handleObjectEvent(eventValue,eventElement, clientEvent);
}
@@ -63,9 +62,8 @@
}
}
- //if it's javascript:XXXX then do something with that
- //TODO make this better and think about it more
- else if (eventValue.indexOf("javascript:")==0){
+ //IMPORTANT test the changes here to isJavascriptEvent()
+ else if (this.isJavascriptEvent(eventValue)){
try{
eventValue = eventValue.substr(11);
var o = eval(eventValue);
@@ -86,6 +84,7 @@
//so just send this there
//TODO do we want to automatically append some information
//to the query string that was contained in the client event?
+ //we assume the event value is already qualified!
else{
try{
this._session.getRequestService().retrieveAndProcess(eventValue);
@@ -122,7 +121,7 @@
* is string that begins with CONTAINER_NAME:, where container name
* is the name of a container in the client session.
*/
-xap.session.EventHandler.prototype._isObjectEvent = function( eventString ) {
+xap.session.EventHandler.prototype.isObjectEvent = function( eventString ) {
var colonIndex = eventString.indexOf(":");
if (colonIndex==-1){
return false;
@@ -130,4 +129,20 @@
var containerName = eventString.substring(0,colonIndex);
return (this._session.getContainer(containerName)!=null);
+}
+
+/**
+ * Return true if the event string is a javascript event like:
+ * javascript:alert('hello');
+ */
+xap.session.EventHandler.prototype.isJavascriptEvent = function( eventString ) {
+ return eventString.indexOf("javascript:")==0;
+}
+
+/**
+ * Return true if the event string is a server-side event like:
+ * ../myPage.jsp
+ */
+xap.session.EventHandler.prototype.isUrlEvent = function( eventString ) {
+ return !this.isJavascriptEvent(eventString) && !this.isObjectEvent(eventString);
}
Modified: incubator/xap/trunk/src/xap/taghandling/AbstractTagImpl.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/taghandling/AbstractTagImpl.js?view=diff&rev=472731&r1=472730&r2=472731
==============================================================================
--- incubator/xap/trunk/src/xap/taghandling/AbstractTagImpl.js (original)
+++ incubator/xap/trunk/src/xap/taghandling/AbstractTagImpl.js Wed Nov 8 17:15:35 2006
@@ -379,6 +379,12 @@
//onCommand="myPage" use "myPage" as the event value
if ( eventValue == null ) {
eventValue = eventElement.getAttribute( eventName );
+
+ //if we looked it up and it looked like a url,
+ //look it up as a qualified url!
+ if (eventValue && session.getEventHandler().isUrlEvent(eventValue)){
+ eventValue = eventElement.getAttributeAsUrl( eventName );
+ }
}
//if there was no event value we have noone listening
@@ -393,6 +399,8 @@
clientEvent.id = eventElement.getAttribute( "id" );
clientEvent.event = eventName;
+
+
//addInvokerInfo(clientEvent,eventElement);
return session.getEventHandler().fireEvent( eventName, eventValue,
Modified: incubator/xap/trunk/src/xap/xml/dom/XapElement.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/xml/dom/XapElement.js?view=diff&rev=472731&r1=472730&r2=472731
==============================================================================
--- incubator/xap/trunk/src/xap/xml/dom/XapElement.js (original)
+++ incubator/xap/trunk/src/xap/xml/dom/XapElement.js Wed Nov 8 17:15:35 2006
@@ -191,11 +191,38 @@
//-----------------------------------------------------------------------
/**
+ * Returns the attribute interpreted as a url. That url will be properly
+ * qualified based on information stored within this element and attribute.
+ */
+xap.xml.dom.XapElement.prototype.getAttributeAsUrl = function( name ) {
+ var att = null;
+
+ for (var i = 0; i < this.attributes.length; ++i) {
+ if (this.attributes[i].nodeName == name) {
+ att = this.attributes[i];
+ }
+ }
+
+ if (att==null){
+ return null;
+ }
+
+ var attValue = att.nodeValue;
+
+
+ var baseUrl = att.baseUrl;
+
+ baseUrl = baseUrl || this.baseUrl;
+ baseUrl = baseUrl || "";
+ return (baseUrl + attValue);
+}
+
+/**
* Sets an attribute with the given name to the given value.
* @param{String} name The name of the attribute to set
* @param{String} value The value of the attribute to set
*/
-xap.xml.dom.XapElement.prototype.setAttribute = function(name, value){
+xap.xml.dom.XapElement.prototype.setAttribute = function(name, value, baseUrl){
var doc = this.getOwnerDocument();
@@ -229,7 +256,7 @@
event.setNewValue( value );
}
- google.XNode.prototype.setAttribute.call(this, name, value);
+ google.XNode.prototype.setAttribute.call(this, name, value, baseUrl);
if ( attributeChangeListenersExist ) {
this._fireAttributeChangeEvent( doc, event, xap.xml.dom.XapElement.ON_ATTRIBUTE_SET);
@@ -1068,6 +1095,8 @@
+
+
//-----------------------------------------------------------------------
// Array Helpers.
//-----------------------------------------------------------------------
@@ -1082,8 +1111,12 @@
e._setPrefix( this._prefix );
for (var i = 0; i<this.attributes.length; i++){
- e.setAttribute(this.attributes[i].nodeName, this.attributes[i].nodeValue);
+ e.setAttribute(this.attributes[i].nodeName, this.attributes[i].nodeValue,this.attributes[i].baseUrl);
}
+
+ if (this.baseUrl){
+ e.baseUrl = this.baseUrl;
+ }
if ( withIds == false ) {
var id = e.getAttribute( "id" );
Modified: incubator/xap/trunk/src/xap/xml/ie/Parser.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/xml/ie/Parser.js?view=diff&rev=472731&r1=472730&r2=472731
==============================================================================
--- incubator/xap/trunk/src/xap/xml/ie/Parser.js (original)
+++ incubator/xap/trunk/src/xap/xml/ie/Parser.js Wed Nov 8 17:15:35 2006
@@ -26,12 +26,12 @@
* Called to get a XML parser. Will determine how which parser to
* use either the Native IE parser or the Sax Parser for the rest of the browsers
*/
-xap.xml.ie.Parser.prototype.parse = function(xmlContent){
+xap.xml.ie.Parser.prototype.parse = function(xmlContent, baseUrl){
var nativeDoc=new ActiveXObject("Microsoft.XMLDOM");
nativeDoc.async="false";
nativeDoc.loadXML(xmlContent);
- return this._parse(nativeDoc);
+ return this._parse(nativeDoc, baseUrl);
}
@@ -39,7 +39,7 @@
* Called to get a XML parser. Will determine how which parser to
* use either the Native IE parser or the Sax Parser for the rest of the browsers
*/
-xap.xml.ie.Parser.prototype._parse = function(nativeDoc){
+xap.xml.ie.Parser.prototype._parse = function(nativeDoc, baseUrl){
//check to see if there was an error parsing the document.
if (nativeDoc.parseError.errorCode != 0){
@@ -56,7 +56,7 @@
var xapDocument = new xap.xml.dom.Document( null );
//replicate the complete Native Document into a XAP document.
- this._importNativeDocument(xapDocument, nativeDoc);
+ this._importNativeDocument(xapDocument, nativeDoc, baseUrl);
return xapDocument;
}
}
@@ -66,13 +66,13 @@
* XAP document will the same information. This method will normalize
* for any difference between the document.
*/
-xap.xml.ie.Parser.prototype._importNativeDocument = function(xapDocument, nativeDoc){
+xap.xml.ie.Parser.prototype._importNativeDocument = function(xapDocument, nativeDoc, baseUrl){
//create the root element.
var xapElement = this._createElement(nativeDoc.documentElement, xapDocument);
//copy over the document.
- this._importNativeElement(xapElement, nativeDoc.documentElement, xapDocument);
+ this._importNativeElement(xapElement, nativeDoc.documentElement, xapDocument, baseUrl);
//store the root element.
xapDocument.setRootElement(xapElement);
@@ -83,7 +83,7 @@
* XAP document will the same information. This method will normalize
* for any difference between the document.
*/
-xap.xml.ie.Parser.prototype._importNativeElement = function(xapParentElement, nativeElement, xapDocument){
+xap.xml.ie.Parser.prototype._importNativeElement = function(xapParentElement, nativeElement, xapDocument, baseUrl){
//create move over all the attributes.
var length = nativeElement.attributes.length;
for (var index = 0; index < length; index++){
@@ -94,6 +94,10 @@
}
}
+ if (baseUrl){
+ xapParentElement.baseUrl = baseUrl;
+ }
+
//replicate all the child elements for this native element.
length = nativeElement.childNodes.length;
for (var index = 0; index < length; index++){
@@ -102,7 +106,7 @@
var xapElement = this._createElement(childNativeElement, xapDocument);
//add the new element to the parent.
- this._importNativeElement(xapElement, childNativeElement, xapDocument);
+ this._importNativeElement(xapElement, childNativeElement, xapDocument, baseUrl);
xapParentElement.appendChild(xapElement);
}else if (childNativeElement.nodeType == google.DOM_TEXT_NODE ||
childNativeElement.nodeType == google.DOM_CDATA_SECTION_NODE){
Modified: incubator/xap/trunk/src/xap/xml/sax/SaxContentHandler.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/xml/sax/SaxContentHandler.js?view=diff&rev=472731&r1=472730&r2=472731
==============================================================================
--- incubator/xap/trunk/src/xap/xml/sax/SaxContentHandler.js (original)
+++ incubator/xap/trunk/src/xap/xml/sax/SaxContentHandler.js Wed Nov 8 17:15:35 2006
@@ -63,7 +63,7 @@
}
-xap.xml.sax.SaxContentHandler.prototype.startElement = function( name, attributes ) {
+xap.xml.sax.SaxContentHandler.prototype.startElement = function( name, attributes, baseUrl ) {
var namespaceStackFrame = this._processNamespaceDeclarations( attributes );
@@ -89,6 +89,9 @@
namespace = this._getDefaultNamespace();
}
var el = this._document.createElement( name, namespace, prefix );
+ if (baseUrl){
+ el.baseUrl = baseUrl;
+ }
//if we have a new stack frame for namespaces then associate
Modified: incubator/xap/trunk/src/xap/xml/sax/SaxParser.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/xml/sax/SaxParser.js?view=diff&rev=472731&r1=472730&r2=472731
==============================================================================
--- incubator/xap/trunk/src/xap/xml/sax/SaxParser.js (original)
+++ incubator/xap/trunk/src/xap/xml/sax/SaxParser.js Wed Nov 8 17:15:35 2006
@@ -229,9 +229,9 @@
* @param attributeHolder---a JS <code>Object</code>
* instance holding attributes as name/value associations.
**/
-xap.xml.sax.SaxParser.prototype._startElement = function(tagName,attribs){
+xap.xml.sax.SaxParser.prototype._startElement = function(tagName,attribs, baseUrl){
- this.handler.startElement(tagName,attribs) ;
+ this.handler.startElement(tagName,attribs, baseUrl) ;
}
@@ -301,7 +301,7 @@
* @throws xap.xml.sax.EmptyDocumentException
* return The document handler used, which should (having avoided all exceptions)
*/
-xap.xml.sax.SaxParser.prototype.parse = function(aString) {
+xap.xml.sax.SaxParser.prototype.parse = function(aString, baseUrl) {
this._data = aString ;
@@ -503,7 +503,7 @@
if(currentChar != '>'){
this._throwParserException(xap.xml.sax.ParserException.UNEXPECTED_END_TAG,[">",currentChar]);
}
- this._startElement(tagName,attributeHolder);
+ this._startElement(tagName,attributeHolder, baseUrl);
this._endElement(tagName);
if(depth==0) {
this._endDocument() ;
@@ -526,7 +526,7 @@
}
stringAccumulator = "";
depth++;
- this._startElement(tagName,attributeHolder);
+ this._startElement(tagName,attributeHolder, baseUrl);
tagName = null;
attributeHolder = new xap.util.Hashtable();
this._setParseMode( this._parseModeStack.pop() ) ;
@@ -609,7 +609,7 @@
}
if(currentChar == '>') {
this._setParseMode( this._parseModeStack.pop() ) ;
- this._startElement(tagName,attributeHolder);
+ this._startElement(tagName,attributeHolder, baseUrl);
depth++;
tagName = null;
attributeHolder = new Object();
Modified: incubator/xap/trunk/src/xap/xml/xmodify/CommandDirective.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/xml/xmodify/CommandDirective.js?view=diff&rev=472731&r1=472730&r2=472731
==============================================================================
--- incubator/xap/trunk/src/xap/xml/xmodify/CommandDirective.js (original)
+++ incubator/xap/trunk/src/xap/xml/xmodify/CommandDirective.js Wed Nov 8 17:15:35 2006
@@ -89,7 +89,7 @@
* will be selected to be the object of the directive.
* @throws xap.xml.xmodify.XmodifyException
*/
-xap.xml.xmodify.CommandDirective.prototype.execute = function (uiDocumentNode)
+xap.xml.xmodify.CommandDirective.prototype.execute = function (uiDocumentNode, baseUrl)
{
this._commandTargets
= this._selectMatchingNodes(uiDocumentNode,this._selectAttr ) ;
@@ -114,7 +114,7 @@
this._handleAppend(uiDocumentNode);
break;
case xap.xml.xmodify.UpdateDirective.DIRECTIVE_SET_ATTRIBUTE:
- this._handleSetAttribute(uiDocumentNode);
+ this._handleSetAttribute(uiDocumentNode, baseUrl);
break;
case xap.xml.xmodify.UpdateDirective.DIRECTIVE_REMOVE_ELEMENT:
this._handleRemoveElement(uiDocumentNode);
@@ -290,7 +290,7 @@
* <code>this._commandTargets</code>, e.g. <xm:set-attribute name="width" value="30px"/>
* @throws xap.xml.xmodify.XmodifyException
**/
-xap.xml.xmodify.CommandDirective.prototype._handleSetAttribute = function(uiDocumentNode)
+xap.xml.xmodify.CommandDirective.prototype._handleSetAttribute = function(uiDocumentNode, baseUrl)
{
/* @TODO: Validity checks */
@@ -315,7 +315,7 @@
){
var name = attrToSet.getAttribute('name');
var val = attrToSet.getAttribute('value');
- currentNode.setAttribute(name, val);
+ currentNode.setAttribute(name, val, baseUrl);
} else {
throw new xap.xml.xmodify.XmodifyException(
xap.xml.xmodify.XmodifyException.ATTRIBUTE_ARGUMENT_NOT_ATTRIB_DIRECTIVE,
Modified: incubator/xap/trunk/src/xap/xml/xmodify/DirectiveSet.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/xml/xmodify/DirectiveSet.js?view=diff&rev=472731&r1=472730&r2=472731
==============================================================================
--- incubator/xap/trunk/src/xap/xml/xmodify/DirectiveSet.js (original)
+++ incubator/xap/trunk/src/xap/xml/xmodify/DirectiveSet.js Wed Nov 8 17:15:35 2006
@@ -24,13 +24,13 @@
this._directives = this._createDirectives(modificationsElement.childNodes, session);
}
-xap.xml.xmodify.DirectiveSet.prototype.execute = function(uiDocument)
+xap.xml.xmodify.DirectiveSet.prototype.execute = function(uiDocument, baseUrl)
{
for (var i = 0;
i < this._directives.length;
i++)
{ // Seems to want the root element here:
- this._directives[i].execute(uiDocument);
+ this._directives[i].execute(uiDocument, baseUrl);
}
}
Modified: incubator/xap/trunk/src/xap/xml/xmodify/Xmodify.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/xml/xmodify/Xmodify.js?view=diff&rev=472731&r1=472730&r2=472731
==============================================================================
--- incubator/xap/trunk/src/xap/xml/xmodify/Xmodify.js (original)
+++ incubator/xap/trunk/src/xap/xml/xmodify/Xmodify.js Wed Nov 8 17:15:35 2006
@@ -125,7 +125,7 @@
/*
* Start the machinery put into place on creation:
*/
- this._directiveSet.execute(uiDoc);
+ this._directiveSet.execute(uiDoc, this._modificationsElement.baseUrl);
xap.xml.xmodify.Xmodify.s_log.debug(uiDoc);
} /* end execute */
Modified: incubator/xap/trunk/testsrc/XapUnitTestSuite.html
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/testsrc/XapUnitTestSuite.html?view=diff&rev=472731&r1=472730&r2=472731
==============================================================================
--- incubator/xap/trunk/testsrc/XapUnitTestSuite.html (original)
+++ incubator/xap/trunk/testsrc/XapUnitTestSuite.html Wed Nov 8 17:15:35 2006
@@ -33,6 +33,11 @@
return result;
}
+ function requestServiceSuite( webappContext ) {
+ var result = new top.jsUnitTestSuite();
+ result.addTestPage( webappContext + "/testsrc/xap/requestservice/_TestRequestService.html" );
+ return result;
+ }
function sessionSuite( webappContext ) {
var result = new top.jsUnitTestSuite();
@@ -70,6 +75,7 @@
var suite = new top.jsUnitTestSuite();
var webappContext = "/jsunit";
+ suite.addTestSuite (requestServiceSuite( webappContext ) );
suite.addTestSuite( taghandlingSuite( webappContext ) );
suite.addTestSuite( utilSuite( webappContext ) );
suite.addTestSuite( xmlSuite( webappContext ) );
Added: incubator/xap/trunk/testsrc/xap/requestservice/_TestRequestService.html
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/testsrc/xap/requestservice/_TestRequestService.html?view=auto&rev=472731
==============================================================================
--- incubator/xap/trunk/testsrc/xap/requestservice/_TestRequestService.html (added)
+++ incubator/xap/trunk/testsrc/xap/requestservice/_TestRequestService.html Wed Nov 8 17:15:35 2006
@@ -0,0 +1,20 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Element Unit Tests</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/util/Utils.js"></script>
+ <script language="JavaScript" type="text/javascript" src="/jsunit/src/xap/Xap.js"></script>
+
+ <script language="JavaScript" type="text/javascript" src="_TestRequestService.js"></script>
+</head>
+
+<body>
+
+</body>
+</html>
\ No newline at end of file
Propchange: incubator/xap/trunk/testsrc/xap/requestservice/_TestRequestService.html
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/xap/trunk/testsrc/xap/requestservice/_TestRequestService.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/testsrc/xap/requestservice/_TestRequestService.js?view=auto&rev=472731
==============================================================================
--- incubator/xap/trunk/testsrc/xap/requestservice/_TestRequestService.js (added)
+++ incubator/xap/trunk/testsrc/xap/requestservice/_TestRequestService.js Wed Nov 8 17:15:35 2006
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ *
+ */
+
+dojo.hostenv.setModulePrefix("dojo", "../dojo/src");
+dojo.hostenv.setModulePrefix("xap", "../xap");
+dojo.hostenv.setModulePrefix("google", "../google");
+
+function exposeTestFunctionNames(){
+ return ["testUrlToPath"];
+}
+
+Xap.require("xap.requestservice.RequestService");
+
+
+function testUrlToPath() {
+
+ var result = xap.requestservice.RequestService.urlToPath("/x/y/z/");
+ assertEquals("/x/y/z/",result);
+
+ result = xap.requestservice.RequestService.urlToPath("/a/b/c");
+ assertEquals("/a/b/",result);
+
+ result = xap.requestservice.RequestService.urlToPath("/q/w/e?a=b");
+ assertEquals("/q/w/",result);
+}
\ No newline at end of file
Propchange: incubator/xap/trunk/testsrc/xap/requestservice/_TestRequestService.js
------------------------------------------------------------------------------
svn:eol-style = native