You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by jk...@apache.org on 2007/06/15 22:33:40 UTC
svn commit: r547777 - in /tapestry/tapestry4/trunk:
src/site/xdoc/components/form/
tapestry-framework/src/java/org/apache/tapestry/form/
tapestry-framework/src/js/tapestry/ tapestry-framework/src/js/tests/
tapestry-framework/src/js/tests/form/
Author: jkuhnert
Date: Fri Jun 15 13:33:39 2007
New Revision: 547777
URL: http://svn.apache.org/viewvc?view=rev&rev=547777
Log:
Fixes TAPESTRY-1577. Missing documentation on new optionRenderer parameter to PropertySelection component.
Various formatting cleanup/documentation on js.
Modified:
tapestry/tapestry4/trunk/src/site/xdoc/components/form/propertyselection.xml
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/PropertySelection.jwc
tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js
tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/form.js
tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/form/test_datetime.js
tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_debug.js
tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_event.js
tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_form.js
tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_form_validation.js
tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_fx.js
tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_html.js
Modified: tapestry/tapestry4/trunk/src/site/xdoc/components/form/propertyselection.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/src/site/xdoc/components/form/propertyselection.xml?view=diff&rev=547777&r1=547776&r2=547777
==============================================================================
--- tapestry/tapestry4/trunk/src/site/xdoc/components/form/propertyselection.xml (original)
+++ tapestry/tapestry4/trunk/src/site/xdoc/components/form/propertyselection.xml Fri Jun 15 13:33:39 2007
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- Copyright 2004, 2005 The Apache Software Foundation
+ Copyright 2007 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.
@@ -28,47 +28,32 @@
</p>
<p>
Uses a
- <a
- href="../../apidocs/org/apache/tapestry/form/IPropertySelectionModel.html">
- IPropertySelectionModel
- </a>
+ <a href="../../apidocs/org/apache/tapestry/form/IPropertySelectionModel.html">IPropertySelectionModel</a>
to map between Java values that will be assigned, and textual labels that will
appear in the HTML response.
</p>
<p>
A useful property selection model is available (
- <a
- href="../../apidocs/org/apache/tapestry/form/StringPropertySelectionModel.html">
- StringPropertySelectionModel
- </a> , or
- <a
- href="../../apidocs/org/apache/tapestry/form/BeanPropertySelectionModel.html">
- BeanPropertySelectionModel
- </a>
- ). You can also create your own model, as illustrated in the examples below.
+ <a href="../../apidocs/org/apache/tapestry/form/StringPropertySelectionModel.html">StringPropertySelectionModel</a>
+ , or
+ <a href="../../apidocs/org/apache/tapestry/form/BeanPropertySelectionModel.html">BeanPropertySelectionModel</a>).
+ You can also create your own model, as illustrated in the examples below.
</p>
<p>
- Note that complex value Objects need to properly implement the
- <code>Object.equals()</code>
+ Note that complex value Objects need to properly implement the <code>Object.equals()</code>
method if the correct initial item is to be displayed.
</p>
<p>
Informal parameters are applied to the <code><select></code> tag. To have greater control
- over the <code><option></code> tags, you must use the
- <a href="select.html">Select</a>
- and
- <a href="option.html">Option</a>
- components.
+ over the <code><option></code> tags, you must use the <a href="select.html">Select</a> and
+ <a href="option.html">Option</a> components.
</p>
<p>
<strong>
See also:
- <a
- href="../../apidocs/org/apache/tapestry/form/PropertySelection.html">
- org.apache.tapestry.form.PropertySelection
- </a>
+ <a href="../../apidocs/org/apache/tapestry/form/PropertySelection.html">org.apache.tapestry.form.PropertySelection</a>
,
<a href="select.html">Select</a>
,
@@ -98,7 +83,7 @@
<td>value</td>
<td>Object</td>
<td>yes</td>
- <td></td>
+ <td> </td>
<td>
The property to set. During rendering, this property is read, and sets
the default value of the selection (if it is null, no element is
@@ -107,16 +92,14 @@
</td>
</tr>
<tr>
-
<td>model</td>
<td>
- <a
- href="../../apidocs/org/apache/tapestry/form/IPropertySelectionModel.html">
+ <a href="../../apidocs/org/apache/tapestry/form/IPropertySelectionModel.html">
IPropertySelectionModel
</a>
</td>
<td>yes</td>
- <td></td>
+ <td> </td>
<td>
The model provides a list of possible labels, and matches those labels
against possible values that can be assigned back to the property.
@@ -124,35 +107,51 @@
</tr>
<tr>
- <td>disabled</td>
- <td>boolean</td>
- <td>no</td>
- <td>false</td>
+ <td>optionRenderer</td>
<td>
- Controls whether the <code><select></code> is active or not. A disabled
- PropertySelection does not update its value parameter. Corresponds to
- the "disabled" HTML attribute.
+ <a href="../../apidocs/org/apache/tapestry/form/IOptionRenderer.html">
+ IOptionRenderer
+ </a>
</td>
+ <td>yes</td>
+ <td>
+ <a href="../../apidocs/org/apache/tapestry/form/DefaultOptionRenderer.html">
+ DefaultOptionRenderer
+ </a>
+ </td>
+ <td>
+ Object used to render the <code><option>Label</option></code> elements
+ within the enclosing <code><select></code> tags. The default implementation currently
+ handles only writing out the <code>disabled/selected</code> attributes corresponding the methods
+ implemented by
+ <a href="../../apidocs/org/apache/tapestry/form/IPropertySelectionModel.html">
+ IPropertySelectionModel
+ </a>.
+ <br /><br />
+ It is possible to implement more advanced display semantics of your options list by implementing a custom
+ <a href="../../apidocs/org/apache/tapestry/form/IOptionRenderer.html">
+ IOptionRenderer
+ </a> of your own. Things like <code>optgroup</code> and various indentation strategies are typically good
+ candidates for implementing custom renderers.
+ </td>
+
</tr>
<tr>
- <td>submitOnChange (deprecated)</td>
+ <td>disabled</td>
<td>boolean</td>
<td>no</td>
<td>false</td>
<td>
- If true, then additional JavaScript is added to submit the containing
- form when select is changed. Equivalent to specifying a JavaScript event
- handler of
- <code>this.form.submit()</code>
- .
+ Controls whether the <code><select></code> is active or not. A disabled
+ PropertySelection does not update its value parameter. Corresponds to
+ the "disabled" HTML attribute.
</td>
</tr>
-
<tr>
<td>displayName</td>
<td>String</td>
<td>no</td>
- <td></td>
+ <td> </td>
<td>
The user-presentable name for the component, which will be used by a
@@ -164,48 +163,19 @@
<td>validators</td>
<td>
Array or collection of
- <a
- href="../../apidocs/org/apache/tapestry/form/validator/Validator.html">
+ <a href="../../apidocs/org/apache/tapestry/form/validator/Validator.html">
Validator
</a>
</td>
<td>no</td>
- <td></td>
+ <td> </td>
<td>
The validators to apply to the component. Something along the lines of:
<code>validators:required</code> .<br/><br/>
-
- <strong>See also:</strong> <a href="../../usersguide/validation.html">Validation</a>
- </td>
- </tr>
- <tr>
- <td>translator</td>
- <td>
- <a
- href="../../tapestry/apidocs/org/apache/tapestry/form/translator/Translator.html">
- Translator
- </a>
- </td>
- <td>no</td>
- <td></td>
- <td>
- The translator to use when displaying and parsing the date.
- <br/><br/>
<strong>See also:</strong> <a href="../../usersguide/validation.html">Validation</a>
</td>
</tr>
- <tr>
- <td>id</td>
- <td>String</td>
- <td>no</td>
- <td></td>
- <td>
- The value of the id attribute in the generated
- <code><select></code>
- tag.
- </td>
- </tr>
</table>
<p>
@@ -230,8 +200,7 @@
<p>
The PropertySelection component provides Gender selection drop down list
using a
- <a
- href="../../apidocs/org/apache/tapestry/form/StringPropertySelectionModel.html">
+ <a href="../../apidocs/org/apache/tapestry/form/StringPropertySelectionModel.html">
StringPropertySelectionModel
</a>
</p>
@@ -257,10 +226,102 @@
}
}
</source>
+ </subsection>
+
+ <subsection name="Example 2 : Custom IOptionRenderer">
+ <p>
+ The <code>optionRenderer</code> parameter allows you complete control over the display of your options list with custom
+ renderer implementations. The following example shows a sample custom renderer implementation for generating a google style
+ drop down actions list. <em>(similar to the gmail drop down actions list)</em>
+ </p>
+
+ <p>
+ The resulting option list would look something like:
+ </p>
+
+ <select name="sampleOptions">
+ <option value="-1" style="color: rgb(119, 119, 119);">choose..</option>
+ <option value="0" style="padding-left:1em;">Dogs</option>
+ <option value="1" style="padding-left:1em;">Elephants</option>
+ <option value="2" style="padding-left:1em;">Mongoose</option>
+ <option value="3" style="padding-left:1em;">Angry Chipmunks</option>
+ </select>
+
+ <source xml:space="preserve"><![CDATA[
+/**
+ * Implementation of {@link IOptionRenderer} that pretty prints options
+ * that aren't disabled with padded whitespace at the beginning.
+ */
+public class FormattedOptionRenderer implements IOptionRenderer {
+
+ // Provided for efficiency / convenience
+ public static final IOptionRenderer DEFAULT_INSTANCE = new FormattedOptionRenderer();
+
+ /**
+ * {@inheritDoc}
+ */
+ public void renderOptions(IMarkupWriter writer, IRequestCycle cycle, IPropertySelectionModel model, Object selected) {
+ int count = model.getOptionCount();
+
+ for (int i = 0; i < count; i++)
+ {
+ Object option = model.getOption(i);
+ writer.begin("option");
+ writer.attribute("value", model.getValue(i));
+
+ if (isEqual(option, selected, model))
+ writer.attribute("selected", "selected");
+
+ if (model.isDisabled(i))
+ writer.attribute("style", "color: rgb(119, 119, 119);");
+
+ if (i > 0)
+ writer.printRaw(" ");
+
+ writer.print(model.getLabel(i));
+
+ writer.end();
+ writer.println();
+ }
+ }
+
+ protected boolean isEqual(Object left, Object right, IPropertySelectionModel model) {
+
+ if (List.class.isInstance(right) && IPrimaryKeyConverter.class.isInstance(model))
+ {
+ List values = (List) right;
+ IPrimaryKeyConverter converter = (IPrimaryKeyConverter) model;
+
+ if (left == null)
+ return false;
+
+ for (Object option : values)
+ if (converter.getPrimaryKey(option).equals(converter.getPrimaryKey(left)))
+ return true;
+
+ return false;
+ }
+
+ // Both null, or same object, then are equal
+
+ if (left == right)
+ return true;
+
+ // If one is null, the other isn't, then not equal.
+
+ if (left == null || right == null)
+ return false;
+
+ // Both non-null; use standard comparison.
+
+ return left.equals(right);
+ }
+}
+]]></source>
</subsection>
- <subsection name="Example 2">
+ <subsection name="Example 3">
<p>
Provides list of clothing items for the user to select. When the user
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/PropertySelection.jwc
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/PropertySelection.jwc?view=diff&rev=547777&r1=547776&r2=547777
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/PropertySelection.jwc (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/PropertySelection.jwc Fri Jun 15 13:33:39 2007
@@ -15,32 +15,32 @@
limitations under the License.
-->
-<!DOCTYPE component-specification PUBLIC
- "-//Apache Software Foundation//Tapestry Specification 4.0//EN"
- "http://tapestry.apache.org/dtd/Tapestry_4_0.dtd">
-
-<component-specification class="org.apache.tapestry.form.PropertySelection"
- allow-body="no"
- allow-informal-parameters="yes">
-
- <description>
- Creates an HTML select to choose a single property from a list of options.
- </description>
-
- <parameter name="value" required="yes"/>
-
- <parameter name="model" required="yes"/>
-
- <parameter name="disabled"/>
-
- <parameter name="displayName"/>
-
- <parameter name="validators" />
-
- <parameter name="optionRenderer" default-value="ognl:@org.apache.tapestry.form.DefaultOptionRenderer@DEFAULT_INSTANCE" cache="no" />
-
- <reserved-parameter name="name"/>
-
- <inject property="validatableFieldSupport" object="service:tapestry.form.ValidatableFieldSupport"/>
-
+<!DOCTYPE component-specification PUBLIC
+ "-//Apache Software Foundation//Tapestry Specification 4.0//EN"
+ "http://tapestry.apache.org/dtd/Tapestry_4_0.dtd">
+
+<component-specification class="org.apache.tapestry.form.PropertySelection"
+ allow-body="no"
+ allow-informal-parameters="yes">
+
+ <description>
+ Creates an HTML select to choose a single property from a list of options.
+ </description>
+
+ <parameter name="value" required="yes"/>
+
+ <parameter name="model" required="yes"/>
+
+ <parameter name="disabled"/>
+
+ <parameter name="displayName"/>
+
+ <parameter name="validators" />
+
+ <parameter name="optionRenderer" default-value="ognl:@org.apache.tapestry.form.DefaultOptionRenderer@DEFAULT_INSTANCE" cache="no" />
+
+ <reserved-parameter name="name"/>
+
+ <inject property="validatableFieldSupport" object="service:tapestry.form.ValidatableFieldSupport"/>
+
</component-specification>
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js?view=diff&rev=547777&r1=547776&r2=547777
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js Fri Jun 15 13:33:39 2007
@@ -37,8 +37,8 @@
* requests.
*/
var tapestry={
-
- // property: version
+
+ // property: version
// The current client side library version, usually matching the current java library version. (ie 4.1, etc..)
version:"4.1.2",
scriptInFlight:false, // whether or not javascript is currently being eval'd, default false
@@ -46,19 +46,19 @@
GlobalScriptFragment:new RegExp('(?:<script.*?>)((\n|.|\r)*?)(?:<\/script>)', 'img'), // regexp for global script fragments
requestsInFlight:0, // how many ajax requests are currently in progress
isIE:dojo.render.html.ie,
-
+
/**
* Function: bind
- *
- * Core XHR bind function for tapestry internals. The
+ *
+ * Core XHR bind function for tapestry internals. The
* <error>/<load> functions defined in this package are used to handle
* load/error of dojo.io.bind.
- *
- * Parameters:
- *
+ *
+ * Parameters:
+ *
* url - The url to bind the request to.
* content - A properties map of optional extra content to send.
- * json - Boolean, optional parameter specifying whether or not to create a
+ * json - Boolean, optional parameter specifying whether or not to create a
* json request. If not specified the default is to use XHR.
*/
bind:function(url, content, json){
@@ -69,7 +69,7 @@
preventCache:true,
error: (function(){tapestry.error.apply(this, arguments);})
};
-
+
// setup content type
if (typeof json != "undefined" && json) {
parms.mimetype = "text/json";
@@ -85,37 +85,37 @@
tapestry.requestsInFlight++;
dojo.io.queueBind(parms);
},
-
+
/**
* Function: error
- *
- * Global error handling function for dojo.io.bind requests. This function is mapped
- * as the "error:functionName" part of a request in the dojo.io.bind arguments
+ *
+ * Global error handling function for dojo.io.bind requests. This function is mapped
+ * as the "error:functionName" part of a request in the dojo.io.bind arguments
* in <tapestry.bind> calls.
- *
+ *
* See Also:
- * <tapestry.bind>
+ * <tapestry.bind>, <tapestry.load>
*/
error:function(type, exception, http, kwArgs){
tapestry.requestsInFlight--;
dojo.log.exception("Error received in IO response.", exception);
},
-
+
/**
* Function: load
- *
+ *
* Global load handling function for dojo.io.bind requests. This isn't typically
- * called directly by anything, but passed in as the "load" argument to
- * dojo.io.bind when making IO requests as the function that will handle the
+ * called directly by anything, but passed in as the "load" argument to
+ * dojo.io.bind when making IO requests as the function that will handle the
* return response.
- *
+ *
* Parameters:
* type - Type of request.
- * data - The data returned, depending on the request type might be an xml document /
+ * data - The data returned, depending on the request type might be an xml document /
* plaintext / json / etc.
* http - The http object used in request, like XmlHttpRequest.
* kwArgs - The original set of arguments passed into dojo.io.bind({arg:val,arg1:val2}).
- *
+ *
*/
load:function(type, data, http, kwArgs){
dojo.log.debug("tapestry.load() Response received.", data);
@@ -124,13 +124,13 @@
dojo.log.warn("No data received in response.");
return;
}
-
+
var resp=data.getElementsByTagName("ajax-response");
if (!resp || resp.length < 1 || !resp[0].childNodes) {
dojo.log.warn("No ajax-response elements received.");
- return;
+ return;
}
-
+
var elms=resp[0].childNodes;
var bodyScripts=[];
var initScripts=[];
@@ -138,7 +138,7 @@
for (var i=0; i<elms.length; i++) {
var elmType=elms[i].getAttribute("type");
var id=elms[i].getAttribute("id");
-
+
if (elmType == "exception") {
dojo.log.err("Remote server exception received.");
tapestry.presentException(elms[i], kwArgs);
@@ -150,10 +150,10 @@
dojo.event.topic.publish(id, {message: tapestry.html.getContentAsString(elms[i])});
continue;
}
-
+
// handle javascript evaluations
if (elmType == "script") {
-
+
if (id == "initializationscript") {
initScripts.push(elms[i]);
continue;
@@ -172,52 +172,65 @@
} else {
rawData.push(elms[i]);
}
-
+
if (!id){
dojo.log.warn("No element id found in ajax-response node.");
continue;
}
-
+
var node=dojo.byId(id);
if (!node) {
dojo.log.warn("No node could be found to update content in with id " + id);
continue;
}
-
+
tapestry.loadContent(id, node, elms[i]);
}
-
+
// load body scripts before initialization
for (var i=0; i<bodyScripts.length; i++) {
tapestry.loadScriptContent(bodyScripts[i], true);
}
-
+
for (var i=0; i<rawData.length; i++) {
tapestry.loadScriptContent(rawData[i], true);
}
-
+
for (var i=0; i<initScripts.length; i++) {
tapestry.loadScriptContent(initScripts[i], true);
}
},
-
- loadJson:function(type, data, http, kwArgs){
- dojo.log.debug("tapestry.loadJson() Response received.", data);
- tapestry.requestsInFlight--;
- },
-
+
+ /**
+ * Function: loadJson
+ *
+ * Executed by default during JSON requests - default implementation does nothing but decrement
+ * the <tapestry.requestsInFlight> global variable.
+ *
+ * Parameters:
+ * type - Type of request.
+ * data - The data returned, depending on the request type might be an xml document /
+ * plaintext / json / etc.
+ * http - The http object used in request, like XmlHttpRequest.
+ * kwArgs - The original set of arguments passed into dojo.io.bind({arg:val,arg1:val2}).
+ */
+ loadJson:function(type, data, http, kwArgs) {
+ dojo.log.debug("tapestry.loadJson() Response received.", data);
+ tapestry.requestsInFlight--;
+ },
+
/**
* Function: loadContent
- *
- * Used by <tapestry.load> when handling xml responses to iterate over the tapestry
- * specific xml response and appropriately load all content types / perform animations /
+ *
+ * Used by <tapestry.load> when handling xml responses to iterate over the tapestry
+ * specific xml response and appropriately load all content types / perform animations /
* execute scripts in the proper order / etc..
- *
- * Parameters:
+ *
+ * Parameters:
* id - The element id that this content should be applied to in the existing document.
- * node - The node that this new content will be applied to.
+ * node - The node that this new content will be applied to.
* element - The incoming xml node containing rules/content to apply to this node.
- *
+ *
*/
loadContent:function(id, node, element){
if (typeof element.childNodes != "undefined" && element.childNodes.length > 0) {
@@ -231,9 +244,9 @@
}
}
}
-
+
dojo.event.browser.clean(node); // prevent mem leaks in ie
-
+
var content=tapestry.html.getContentAsString(element);
if (djConfig["isDebug"]) {
dojo.log.debug("Received element content for id <" + id + "> of: " + content);
@@ -262,11 +275,11 @@
continue;
}
}
-
+
var nn = attnode.nodeName;
var nv = attnode.nodeValue;
if (nn == "id" || nn == "type" || nn == "name"){continue;}
-
+
if (nn == "style") {
dojo.html.setStyleText(node, nv);
} else if (nn == "class") {
@@ -275,21 +288,21 @@
node.setAttribute(nn, nv);
}
}
-
+
// apply disabled/not disabled
var disabled = element.getAttribute("disabled");
- if (!disabled && node["disabled"]) {
+ if (!disabled && node["disabled"]) {
node.disabled = false;
} else if (disabled) {
node.disabled = true;
}
},
-
+
/**
* Function: loadScriptContent
- *
+ *
* Manages loading javascript content for a specific incoming xml element.
- *
+ *
* Parameters:
* element - The element to parse javascript statements from and execute.
* async - Whether or not to process the script content asynchronously, meaning
@@ -305,25 +318,25 @@
setTimeout(function() { tapestry.loadScriptContent(element, async);}, 5);
return;
}
-
- var text=tapestry.html.getContentAsString(element);
+
+ var text=tapestry.html.getContentAsString(element);
var response = text.replace(this.GlobalScriptFragment, '');
var scripts = text.match(this.GlobalScriptFragment);
-
+
if (!scripts) { return; }
-
+
if (async) {
- setTimeout(function() {
+ setTimeout(function() {
tapestry.evaluateScripts(scripts);
}, 60);
} else {
tapestry.evaluateScripts(scripts);
}
},
-
+
evaluateScripts:function(scripts){
tapestry.scriptInFlight = true;
-
+
for (var i=0; i<scripts.length; i++) {
var scr = scripts[i].match(this.ScriptFragment)[1];
if(!scr || scr.length <= 0){continue;}
@@ -335,18 +348,18 @@
dojo.log.exception("Error evaluating script: " + scr, e, false);
}
}
-
+
tapestry.scriptInFlight = false;
},
-
+
/**
* Function: loadScriptFromUrl
- *
- * Takes a url string and loads the javascript it points to as a normal
+ *
+ * Takes a url string and loads the javascript it points to as a normal
* document head script include section. ie:
- *
+ *
* : <script type="text/javascript" src="http://localhost/js/foo.js"></script>
- *
+ *
* Parameters:
* url - The url to the script to load into this documents head.
*/
@@ -360,45 +373,45 @@
}
}
}
-
+
if (djConfig.isDebug) {
dojo.log.debug("loadScriptFromUrl: " + url + " success?: " + dojo.hostenv.loadUri(url));
} else {
dojo.hostenv.loadUri(url);
}
},
-
+
/**
* Function: presentException
- *
- * When remote exceptions are caught on the server special xml blocks are returned to
+ *
+ * When remote exceptions are caught on the server special xml blocks are returned to
* the client when the requests are initiated via async IO. This function takes the incoming
* Tapestry exception page content and dumps it into a modal dialog that is presented to the user.
- *
- * Parameters:
+ *
+ * Parameters:
* node - The incoming xml exception node.
* kwArgs - The kwArgs used to initiate the original IO request.
*/
presentException:function(node, kwArgs) {
dojo.require("dojo.widget.*");
dojo.require("dojo.widget.Dialog");
-
+
var excnode=document.createElement("div");
excnode.setAttribute("id", "exceptiondialog");
document.body.appendChild(excnode);
-
+
var contentnode=document.createElement("div");
contentnode.innerHTML=tapestry.html.getContentAsString(node);
dojo.html.setClass(contentnode, "exceptionDialog");
-
+
var navnode=document.createElement("div");
navnode.setAttribute("id", "exceptionDialogHandle");
dojo.html.setClass(navnode, "exceptionCloseLink");
navnode.appendChild(document.createTextNode("Close"));
-
+
excnode.appendChild(navnode);
excnode.appendChild(contentnode);
-
+
var dialog=dojo.widget.createWidget("Dialog", {widgetId:"exception"}, excnode);
dojo.event.connect(navnode, "onclick", dialog, "hide");
dojo.event.connect(dialog, "hide", dialog, "destroy");
@@ -407,13 +420,13 @@
dialog.show();
}, 100);
},
-
+
/**
* Function: cleanConnect
- *
+ *
* Utility used to disconnect a previously connected event/function.
- *
- * This assumes that the incoming function name is being attached to
+ *
+ * This assumes that the incoming function name is being attached to
* the global namespace "tapestry".
*/
cleanConnect:function(target, event, funcName){
@@ -421,11 +434,11 @@
dojo.event.disconnect(target, event, tapestry, funcName);
}
},
-
+
linkOnClick:function(url, id, isJson){
var content={beventname:"onClick"};
content["beventtarget.id"]=id;
-
+
tapestry.bind(url, content, isJson);
return false;
},
@@ -448,27 +461,27 @@
CompactElementRegexp:/<([a-zA-Z](?!nput)[a-zA-Z]*)([^>]*?)\/>/g, // regexp for compact html elements
CompactElementReplacer:'<$1$2></$1>', // replace pattern for compact html elements
-
+
/**
* Function: getContentAsString
- *
+ *
* Takes a dom node and returns its contents rendered in a string.
*
* The resulting string does NOT contain any markup (or attributes) of
* the given node - only child nodes are rendered and returned.Content
*
- * Implementation Note: This function tries to make use of browser
+ * Implementation Note: This function tries to make use of browser
* specific features (the xml attribute of nodes in IE and the XMLSerializer
* object in Mozilla derivatives) - if those fails, a generic implementation
* is used that is guaranteed to work in all platforms.
- *
- * Parameters:
- *
+ *
+ * Parameters:
+ *
* node - The dom node.
* Returns:
- *
+ *
* The string representation of the given node's contents.
- */
+ */
getContentAsString:function(node){
if (typeof node.xml != "undefined") {
return this._getContentAsStringIE(node);
@@ -477,31 +490,31 @@
} else {
return this._getContentAsStringGeneric(node);
}
- },
-
+ },
+
/**
* Function: getElementAsString
- *
+ *
* Takes a dom node and returns itself and its contents rendered in a string.
*
* Implementation Note: This function uses a generic implementation in order
* to generate the returned string.
- *
- * Parameters:
- *
+ *
+ * Parameters:
+ *
* node - The dom node.
* Returns:
- *
+ *
* The string representation of the given node.
- */
+ */
getElementAsString:function(node){
if (!node) { return ""; }
-
+
var s='<' + node.nodeName;
// add attributes
if (node.attributes && node.attributes.length > 0) {
for (var i=0; i < node.attributes.length; i++) {
- s += " " + node.attributes[i].name + "=\"" + node.attributes[i].value + "\"";
+ s += " " + node.attributes[i].name + "=\"" + node.attributes[i].value + "\"";
}
}
// close start tag
@@ -511,7 +524,7 @@
// end tag
s += '</' + node.nodeName + '>';
return s;
- },
+ },
_getContentAsStringIE:function(node){
var s="";
@@ -520,10 +533,10 @@
}
return s;
},
-
+
_getContentAsStringMozilla:function(node){
if (!this.xmlSerializer){ this.xmlSerializer = new XMLSerializer();}
-
+
var s = "";
for (var i = 0; i < node.childNodes.length; i++) {
s += this.xmlSerializer.serializeToString(node.childNodes[i]);
@@ -533,7 +546,7 @@
return this._processCompactElements(s);
},
-
+
_getContentAsStringGeneric:function(node){
var s="";
if (node == null) { return s; }
@@ -552,12 +565,12 @@
break;
}
}
- return s;
+ return s;
},
_processCompactElements:function(htmlData)
{
- return htmlData.replace(this.CompactElementRegexp, this.CompactElementReplacer);
+ return htmlData.replace(this.CompactElementRegexp, this.CompactElementReplacer);
}
}
@@ -568,28 +581,28 @@
* a name/value pair format that can be sent to the remote server.
*/
tapestry.event={
-
+
/**
* Function: buildEventProperties
- *
+ *
* Takes an incoming browser generated event (like key/mouse events) and
- * creates a js object holding the basic values of the event in order for
+ * creates a js object holding the basic values of the event in order for
* it to be submitted to the server.
- *
- * Parameters:
- *
+ *
+ * Parameters:
+ *
* event - The javascript event method is based on, if it isn't a valid
* browser event it will be ignored.
* props - The existing property object to set the values on, if it doesn't
* exist one will be created.
* Returns:
- *
+ *
* The desired event properties bound to an object. Ie obj.target,obj.charCode, etc..
*/
buildEventProperties:function(event, props){
if (!dojo.event.browser.isEvent(event)) return {};
if (!props) props={};
-
+
if(event["type"]) props.beventtype=event.type;
if(event["keys"]) props.beventkeys=event.keys;
if(event["charCode"]) props.beventcharCode=event.charCode;
@@ -597,42 +610,42 @@
if(event["pageY"]) props.beventpageY=event.pageY;
if(event["layerX"]) props.beventlayerX=event.layerX;
if(event["layerY"]) props.beventlayerY=event.layerY;
-
+
if (event["target"]) this.buildTargetProperties(props, event.target);
-
+
return props;
},
-
+
/**
* Function: buildTargetProperties
- *
+ *
* Generic function to build a properties object populated with
* relevent target data.
- *
+ *
* Parameters:
- *
+ *
* props - The object that event properties are being set on to return to
* the server.
* target - The javscript Event.target object that the original event was targeted for.
- *
+ *
* Returns:
* The original props object passed in, populated with any data found.
*/
buildTargetProperties:function(props, target){
if(!target) { return; }
-
+
if (dojo.dom.isNode(target)) {
return this.buildNodeProperties(props, target);
} else {
dojo.raise("buildTargetProperties() Unknown target type:" + target);
}
},
-
+
/**
* Function: buildNodeProperties
- *
+ *
* Builds needed target node properties, like the node's id.
- *
+ *
* Parameters:
* props - The object that event properties are being set on to return to
* the server.
@@ -648,21 +661,21 @@
tapestry.lang = {
/**
- * Searches the specified list for an object with a matching propertyName/value pair.
+ * Searches the specified list for an object with a matching propertyName/value pair.
* @param list The array of objects to search.
- * @param properyName The object property key to match on. (ie object[propertyName])
+ * @param properyName The object property key to match on. (ie object[propertyName])
* Can also be a template object to match in the form of {key:{key:value}} nested
- * as deeply as you like.
+ * as deeply as you like.
* @param value The value to be matched against
* @return The matching array object found, or null.
*/
find:function(list, property, value){
if (!list || !property || list.length < 1) return null;
-
+
// if not propMatch then template object was passed in
var propMatch=dojo.lang.isString(property);
if (propMatch && !value) return null; //if doing string/other non template match and no value
-
+
for (var i=0; i < list.length; i++) {
if (!list[i]) continue;
if (propMatch) {
@@ -673,13 +686,13 @@
}
return null;
},
-
+
// called recursively to match object properties
// partially stolen logic from dojo.widget.html.SortableTable.sort
matchProperty:function(template, object){
if(!dojo.lang.isObject(template) || !dojo.lang.isObject(object))
return template.valueOf() == object.valueOf();
-
+
for(var p in template){
if(!(p in object)) return false; // boolean
if (!this.matchProperty(template[p], object[p])) return false;
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/form.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/form.js?view=diff&rev=547777&r1=547776&r2=547777
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/form.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/form.js Fri Jun 15 13:33:39 2007
@@ -19,8 +19,7 @@
/**
* Function: focusField
- * If possible, brings keyboard input focus
- * to the specified field.
+ * If possible, brings keyboard input focus to the specified field.
*
* Parameters:
* field - The field(field id) of the field to focus.
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/form/test_datetime.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/form/test_datetime.js?view=diff&rev=547777&r1=547776&r2=547777
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/form/test_datetime.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/form/test_datetime.js Fri Jun 15 13:33:39 2007
@@ -11,9 +11,9 @@
function test_datetime_validDate(){
var value = "08/15/1999";
// jum.assertFalse(value, tapestry.form.datetime.isValidDate(value, {}));
- jum.assertTrue(value, tapestry.form.datetime.isValidDate(value,
+ jum.assertTrue(value, tapestry.form.datetime.isValidDate(value,
{datePattern:"MM/dd/yyyy",selector:"dateOnly"}));
-
+
// value = "12112/12/23434"; "08 Sep 2006"
// jum.assertFalse(value, tapestry.form.datetime.isValidDate(value));
// jum.assertFalse("null value", tapestry.form.datetime.isValidDate());
@@ -23,18 +23,18 @@
function test_datetime_maxDate(){
var maxValue = "09/28/2020";
-
+
var value = "08/15/2021";
- jum.assertFalse(value, tapestry.form.datetime.isValidDate(value,
+ jum.assertFalse(value, tapestry.form.datetime.isValidDate(value,
{strict:true,max:maxValue,datePattern:"MM/dd/yyyy",selector:"dateOnly"}));
-
- jum.assertTrue("08/15/2020", tapestry.form.datetime.isValidDate("08/15/2020",
+
+ jum.assertTrue("08/15/2020", tapestry.form.datetime.isValidDate("08/15/2020",
{strict:true, max:maxValue, datePattern:"MM/dd/yyyy",selector:"dateOnly"}));
-
+
value = "08/15/2020";
- jum.assertTrue(value, tapestry.form.datetime.isValidDate(value,
+ jum.assertTrue(value, tapestry.form.datetime.isValidDate(value,
{strict:true, max:maxValue, datePattern:"MM/dd/yyyy",selector:"dateOnly"}));
-
+
jum.assertTrue("09/28/2020", tapestry.form.datetime.isValidDate(
"09/28/2020",
{strict:true, max:maxValue, datePattern:"MM/dd/yyyy",selector:"dateOnly"})
@@ -43,30 +43,30 @@
function test_datetime_minDate(){
var minValue = "09/28/2000";
-
+
var value = "09/27/2000";
- jum.assertFalse(value, tapestry.form.datetime.isValidDate(value,
+ jum.assertFalse(value, tapestry.form.datetime.isValidDate(value,
{strict:true, min:minValue,selector:"dateOnly",datePattern:"MM/dd/yyyy"}));
-
- jum.assertTrue("11/27/2000", tapestry.form.datetime.isValidDate("11/27/2000",
+
+ jum.assertTrue("11/27/2000", tapestry.form.datetime.isValidDate("11/27/2000",
{strict:true,min:minValue, datePattern:"MM/dd/yyyy",selector:"dateOnly"}));
-
+
value = "09/28/2000";
- jum.assertTrue(value, tapestry.form.datetime.isValidDate(value,
+ jum.assertTrue(value, tapestry.form.datetime.isValidDate(value,
{strict:true,min:minValue, datePattern:"MM/dd/yyyy",selector:"dateOnly"}));
}
function test_datetime_LongFormat(){
var value = "18 Aug 2006";
-
- jum.assertFalse(value, tapestry.form.datetime.isValidDate(value,
+
+ jum.assertFalse(value, tapestry.form.datetime.isValidDate(value,
{strict:true,max:"06 Aug 2006",datePattern:"dd MMM yyyy",selector:"dateOnly"}));
-
- jum.assertTrue(value, tapestry.form.datetime.isValidDate(value,
+
+ jum.assertTrue(value, tapestry.form.datetime.isValidDate(value,
{strict:true,max:"19 Aug 2006",datePattern:"dd MMM yyyy",selector:"dateOnly"}));
-
+
value = "4 Nov 2006";
- jum.assertTrue(value, tapestry.form.datetime.isValidDate(value,
+ jum.assertTrue(value, tapestry.form.datetime.isValidDate(value,
{max:"04 Nov 2006",datePattern:"dd MMM yyyy"}));
}
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_debug.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_debug.js?view=diff&rev=547777&r1=547776&r2=547777
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_debug.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_debug.js Fri Jun 15 13:33:39 2007
@@ -11,15 +11,15 @@
function test_debug_logLevel(){
dojo.log.info("info msg");
-
+
dojo.log.setLevel(dojo.log.getLevel("WARNING"));
dojo.log.info("SHOULD NOT SEE THIS");
var last = dojo.logging.logQueueHandler.data.pop();
jum.assertEquals("info msg", last.message);
-
+
var currLength = dojo.logging.logQueueHandler.data.length;
dojo.log.debug("DEFINITELY SHOULDNT see this");
jum.assertEquals("logmsglength", currLength, dojo.logging.logQueueHandler.data.length);
-
+
dojo.log.setLevel(dojo.log.getLevel("DEBUG"));
}
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_event.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_event.js?view=diff&rev=547777&r1=547776&r2=547777
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_event.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_event.js Fri Jun 15 13:33:39 2007
@@ -7,13 +7,13 @@
function test_eventCapture_props(){
var fevent=document.createEvent('UIEvents');
fevent.type="testType";
-
+
var tnode = document.createElement("div");
tnode.setAttribute("id", "testid");
fevent.target=tnode;
-
+
var props = tapestry.event.buildEventProperties(fevent);
-
+
jum.assertTrue("evType", dojo.event.browser.isEvent(fevent));
jum.assertTrue("testNullProp", tapestry.event.buildEventProperties({}));
jum.assertTrue("type", props.beventtype != "undefined");
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_form.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_form.js?view=diff&rev=547777&r1=547776&r2=547777
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_form.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_form.js Fri Jun 15 13:33:39 2007
@@ -10,7 +10,7 @@
function test_form_find(){
var node = document.createElement("div");
node.setAttribute("id", "testid");
-
+
jum.assertTrue(Tapestry.find(node));
jum.assertTrue(Tapestry.find("testid"));
}
@@ -24,6 +24,7 @@
Tapestry.register_form();
throw new JUMAssertFailure("Previous test should have failed.");
} catch (e) { jum.assertTrue("testFormDepre", e instanceof Error); return; }
+
jum.assertTrue("deprecated", lastMsgContains("deprecated"));
Tapestry.onpresubmit();
jum.assertTrue("deprecated", lastMsgContains("deprecated"));
@@ -45,23 +46,23 @@
function test_form_requireTextField(){
Tapestry.require_field(null, "bs", "invalid");
-
+
var node = document.createElement("input");
node.setAttribute("id", "testid");
node.type="text";
node.value="";
-
+
var mockInvalid=new mock(node, "must have value");
dojo.event.connect(Tapestry, "default_invalid_field_handler", mockInvalid, "intercept");
-
+
Tapestry.require_field(null, "testid", "must have value");
-
+
jum.assertTrue("invalidCalled", mockInvalid.called);
dojo.event.disconnect(Tapestry, "default_invalid_field_handler", mockInvalid, "intercept");
}
function test_form_submit(){
-
+
var submitCalled=false;
var node = document.createElement("form");
node.setAttribute("id", "form1");
@@ -70,10 +71,10 @@
}
node.submitname={value:""};
node.elements=[];
-
+
Tapestry.register_form("form1");
Tapestry.submit_form("form1", "testSubmit");
-
+
jum.assertTrue("submitCalled", submitCalled);
jum.assertEquals("submitName", node.submitname.value, "testSubmit");
}
@@ -90,14 +91,14 @@
node.submitname={value:""};
node.elements=[];
document.body.appendChild(node);
-
+
dojo.event.connect(dojo.io, "queueBind", this, checkSubmitParms);
-
+
tapestry.form.registerForm("formparmtest");
tapestry.form.submit("formparmtest", null, {async:true,url:"/a/url"});
-
+
jum.assertTrue("bindCalled", bindCalled);
-
+
dojo.event.disconnect(dojo.io, "queueBind", this, checkSubmitParms);
}
@@ -116,14 +117,14 @@
node.submitname={value:""};
node.elements=[];
document.body.appendChild(node);
-
+
dojo.event.connect(dojo.io, "queueBind", this, checkDefaultParms);
-
+
tapestry.form.registerForm("formasynctest", true);
tapestry.form.submit("formasynctest");
-
+
jum.assertTrue("bindCalled", bindCalled);
-
+
dojo.event.disconnect(dojo.io, "queueBind", this, checkDefaultParms);
}
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_form_validation.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_form_validation.js?view=diff&rev=547777&r1=547776&r2=547777
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_form_validation.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_form_validation.js Fri Jun 15 13:33:39 2007
@@ -11,8 +11,8 @@
try {
tapestry.form.registerForm("bsid");
throw new JUMAssertFailure("Previous test should have failed.");
- } catch (e) {
- jum.assertTrue("testFormRegisterInvalid", e instanceof Error);
+ } catch (e) {
+ jum.assertTrue("testFormRegisterInvalid", e instanceof Error);
}
}
@@ -23,7 +23,7 @@
form.submitCalled=true;
}
form.submitname={value:""};
-
+
tapestry.form.registerForm("regform");
jum.assertTrue("formregForm", dojo.lang.isObject(tapestry.form.forms["regform"]));
jum.assertTrue("formregProfiles", dojo.lang.isArray(tapestry.form.forms["regform"].profiles));
@@ -38,29 +38,29 @@
function test_validate_decimals(){
var input = "1,124.12";
jum.assertTrue(dojo.validate.isRealNumber(input, {decimal:".",separator:","}));
- jum.assertTrue(dojo.validate.isInRange(input, {min:2.0,decimal:".",separator:",",symbol:"¤"}));
- jum.assertTrue(dojo.validate.isInRange(input, {max:1000000001,decimal:".",separator:",",symbol:"¤"}));
+ jum.assertTrue(dojo.validate.isInRange(input, {min:2.0,decimal:".",separator:",",symbol:"�"}));
+ jum.assertTrue(dojo.validate.isInRange(input, {max:1000000001,decimal:".",separator:",",symbol:"�"}));
}
function test_validate_required(){
// A generic form
var f = {
-
+
tx1: {type: "text", value: " 1001 ", name: "tx1"},
tx2: {type: "text", value: " ", name: "tx2"},
tx3: {type: "text", value: "10/19/2005", name: "tx3"},
-
+
};
// Profile for form input
var profile = {
- // required fields
+ // required fields
required: ["tx2"]
};
-
+
// results object
var results = dojo.validate.check(f, profile);
-
+
jum.assertTrue("missing_tx2", results.isMissing("tx2"));
}
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_fx.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_fx.js?view=diff&rev=547777&r1=547776&r2=547777
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_fx.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_fx.js Fri Jun 15 13:33:39 2007
@@ -4,28 +4,28 @@
dojo.require("dojo.lfx.html");
function test_preEffects(){
-
- tapestry.fx.removeAll();
-
- jum.assertTrue(dojo.lang.isEmpty(tapestry.fx.preEffects));
-
- var animation = dojo.lfx.html.wipeIn();
-
- tapestry.fx.attachPreEffect("div1", animation);
-
- jum.assertFalse(dojo.lang.isEmpty(tapestry.fx.preEffects));
-
- jum.assertEquals(animation, tapestry.fx.preEffects["div1"].animation);
-
+
+ tapestry.fx.removeAll();
+
+ jum.assertTrue(dojo.lang.isEmpty(tapestry.fx.preEffects));
+
+ var animation = dojo.lfx.html.wipeIn();
+
+ tapestry.fx.attachPreEffect("div1", animation);
+
+ jum.assertFalse(dojo.lang.isEmpty(tapestry.fx.preEffects));
+
+ jum.assertEquals(animation, tapestry.fx.preEffects["div1"].animation);
+
}
function test_postEffects(){
-
- tapestry.fx.removeAll();
-
- jum.assertTrue(dojo.lang.isEmpty(tapestry.fx.postEffects));
-
- tapestry.fx.attachPostEffect("div1", dojo.lfx.html.wipeIn());
-
- jum.assertFalse(dojo.lang.isEmpty(tapestry.fx.postEffects));
+
+ tapestry.fx.removeAll();
+
+ jum.assertTrue(dojo.lang.isEmpty(tapestry.fx.postEffects));
+
+ tapestry.fx.attachPostEffect("div1", dojo.lfx.html.wipeIn());
+
+ jum.assertFalse(dojo.lang.isEmpty(tapestry.fx.postEffects));
}
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_html.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_html.js?view=diff&rev=547777&r1=547776&r2=547777
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_html.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_html.js Fri Jun 15 13:33:39 2007
@@ -6,85 +6,85 @@
function test_html_getContentAsString(){
-
- var node = _createTestNode();
-
- var data = tapestry.html.getContentAsString(node).toLowerCase();
- jum.assertEquals("<div id=\"testid2\">content</div>", data);
+
+ var node = _createTestNode();
+
+ var data = tapestry.html.getContentAsString(node).toLowerCase();
+ jum.assertEquals("<div id=\"testid2\">content</div>", data);
}
function test_html_textarea(){
-
- var node = _createTestNode("textarea", true);
-
- var data = tapestry.html.getContentAsString(node).toLowerCase();
- jum.assertEquals("<textarea id=\"testid2\"></textarea>", data);
- // cannot test Mozilla's getContentAsString from here...
- // only browser based tests will show if this is working
+
+ var node = _createTestNode("textarea", true);
+
+ var data = tapestry.html.getContentAsString(node).toLowerCase();
+ jum.assertEquals("<textarea id=\"testid2\"></textarea>", data);
+ // cannot test Mozilla's getContentAsString from here...
+ // only browser based tests will show if this is working
}
function test_html_getElementAsString(){
-
- var node = _createTestNode();
-
- var data = tapestry.html.getElementAsString(node).toLowerCase();
- jum.assertEquals("<div id=\"testid\"><div id=\"testid2\">content</div></div>", data);
+
+ var node = _createTestNode();
+
+ var data = tapestry.html.getElementAsString(node).toLowerCase();
+ jum.assertEquals("<div id=\"testid\"><div id=\"testid2\">content</div></div>", data);
}
function test_html_processTextareas(){
- var initial = "start<textarea id='2' rows=4/>22<input type='text'/><textarea/><div id=1/>";
- var expected = "start<textarea id='2' rows=4></textarea>22<input type='text'/><textarea></textarea><div id=1></div>";
-
- jum.assertEquals(expected, tapestry.html._processCompactElements(initial));
- jum.assertEquals(expected + expected,
- tapestry.html._processCompactElements(initial+initial));
+ var initial = "start<textarea id='2' rows=4/>22<input type='text'/><textarea/><div id=1/>";
+ var expected = "start<textarea id='2' rows=4></textarea>22<input type='text'/><textarea></textarea><div id=1></div>";
+
+ jum.assertEquals(expected, tapestry.html._processCompactElements(initial));
+ jum.assertEquals(expected + expected,
+ tapestry.html._processCompactElements(initial+initial));
}
function test_html_processResponse(){
- var initial = '<div id="editTopic"><form method="post" action="Topics,topicList.$Form.sdirect" id="Form"> '
- +'<div style="display:none;" id="Formhidden"><input type="hidden" name="formids" value="topicName,shortDescriptiveText,descriptiveText,If,If_0,updateTopic" /> '
- +'<input type="hidden" name="updateParts" value="list" /> <input type="hidden" name="updateParts" value="edit" /> <input type="hidden" name="reservedids" '
- +'value="updateParts" /> <input type="hidden" name="submitmode" value="" /> <input type="hidden" name="submitname" value="" /> <input type="hidden" name="If" value="T" /> '
- +'<input type="hidden" name="If_0" value="F" /> </div> Make the desired changes to this topic. <fieldset> <div> <label for="topicName" class="required">Topic Name</label> '
- +'<input type="text" name="name" value="Uncategorized" id="tName" /> </div> <div> <label for="shortDescriptiveText" class="required">Short Description</label> '
- +'<textarea name="shortDescriptiveText" id="shortDescriptiveText" cols="40" rows="4">Information</textarea> </div> <div> <label for="descriptiveText">Additional '
- +'Description</label> <textarea name="descriptiveText" id="descriptiveText" cols="40" rows="4"/> </div> <div> <label for="pUrlField" class="required">Home '
- +'Url</label> <input type="text" name="pUrlField" value="ba.org" id="pUrlField" size="40" /> Verified </div> <div></div> </fieldset> <div> '
- +'<input type="submit" name="uTopic" id="uTopic" value="Save Changes"/> <!--input type="submit" jwcid="cancelTopic@Submit" '
- +'listener="listener:doCancel" value="message:label.cancel-changes" async="true"/--></div> </form> </div>';
- var expected = '<div id="editTopic"><form method="post" action="Topics,topicList.$Form.sdirect" id="Form"> '
- +'<div style="display:none;" id="Formhidden"><input type="hidden" name="formids" value="topicName,shortDescriptiveText,descriptiveText,If,If_0,updateTopic" /> '
- +'<input type="hidden" name="updateParts" value="list" /> <input type="hidden" name="updateParts" value="edit" /> <input type="hidden" name="reservedids" '
- +'value="updateParts" /> <input type="hidden" name="submitmode" value="" /> <input type="hidden" name="submitname" value="" /> <input type="hidden" name="If" value="T" /> '
- +'<input type="hidden" name="If_0" value="F" /> </div> Make the desired changes to this topic. <fieldset> <div> <label for="topicName" class="required">Topic Name</label> '
- +'<input type="text" name="name" value="Uncategorized" id="tName" /> </div> <div> <label for="shortDescriptiveText" class="required">Short Description</label> '
- +'<textarea name="shortDescriptiveText" id="shortDescriptiveText" cols="40" rows="4">Information</textarea> </div> <div> <label for="descriptiveText">Additional '
- +'Description</label> <textarea name="descriptiveText" id="descriptiveText" cols="40" rows="4"></textarea> </div> <div> <label for="pUrlField" class="required">Home '
- +'Url</label> <input type="text" name="pUrlField" value="ba.org" id="pUrlField" size="40" /> Verified </div> <div></div> </fieldset> <div> '
- +'<input type="submit" name="uTopic" id="uTopic" value="Save Changes"/> <!--input type="submit" jwcid="cancelTopic@Submit" '
- +'listener="listener:doCancel" value="message:label.cancel-changes" async="true"/--></div> </form> </div>';
-
- jum.assertEquals(expected, tapestry.html._processCompactElements(initial));
- jum.assertEquals(expected + expected,
- tapestry.html._processCompactElements(initial+initial));
+ var initial = '<div id="editTopic"><form method="post" action="Topics,topicList.$Form.sdirect" id="Form"> '
+ +'<div style="display:none;" id="Formhidden"><input type="hidden" name="formids" value="topicName,shortDescriptiveText,descriptiveText,If,If_0,updateTopic" /> '
+ +'<input type="hidden" name="updateParts" value="list" /> <input type="hidden" name="updateParts" value="edit" /> <input type="hidden" name="reservedids" '
+ +'value="updateParts" /> <input type="hidden" name="submitmode" value="" /> <input type="hidden" name="submitname" value="" /> <input type="hidden" name="If" value="T" /> '
+ +'<input type="hidden" name="If_0" value="F" /> </div> Make the desired changes to this topic. <fieldset> <div> <label for="topicName" class="required">Topic Name</label> '
+ +'<input type="text" name="name" value="Uncategorized" id="tName" /> </div> <div> <label for="shortDescriptiveText" class="required">Short Description</label> '
+ +'<textarea name="shortDescriptiveText" id="shortDescriptiveText" cols="40" rows="4">Information</textarea> </div> <div> <label for="descriptiveText">Additional '
+ +'Description</label> <textarea name="descriptiveText" id="descriptiveText" cols="40" rows="4"/> </div> <div> <label for="pUrlField" class="required">Home '
+ +'Url</label> <input type="text" name="pUrlField" value="ba.org" id="pUrlField" size="40" /> Verified </div> <div></div> </fieldset> <div> '
+ +'<input type="submit" name="uTopic" id="uTopic" value="Save Changes"/> <!--input type="submit" jwcid="cancelTopic@Submit" '
+ +'listener="listener:doCancel" value="message:label.cancel-changes" async="true"/--></div> </form> </div>';
+ var expected = '<div id="editTopic"><form method="post" action="Topics,topicList.$Form.sdirect" id="Form"> '
+ +'<div style="display:none;" id="Formhidden"><input type="hidden" name="formids" value="topicName,shortDescriptiveText,descriptiveText,If,If_0,updateTopic" /> '
+ +'<input type="hidden" name="updateParts" value="list" /> <input type="hidden" name="updateParts" value="edit" /> <input type="hidden" name="reservedids" '
+ +'value="updateParts" /> <input type="hidden" name="submitmode" value="" /> <input type="hidden" name="submitname" value="" /> <input type="hidden" name="If" value="T" /> '
+ +'<input type="hidden" name="If_0" value="F" /> </div> Make the desired changes to this topic. <fieldset> <div> <label for="topicName" class="required">Topic Name</label> '
+ +'<input type="text" name="name" value="Uncategorized" id="tName" /> </div> <div> <label for="shortDescriptiveText" class="required">Short Description</label> '
+ +'<textarea name="shortDescriptiveText" id="shortDescriptiveText" cols="40" rows="4">Information</textarea> </div> <div> <label for="descriptiveText">Additional '
+ +'Description</label> <textarea name="descriptiveText" id="descriptiveText" cols="40" rows="4"></textarea> </div> <div> <label for="pUrlField" class="required">Home '
+ +'Url</label> <input type="text" name="pUrlField" value="ba.org" id="pUrlField" size="40" /> Verified </div> <div></div> </fieldset> <div> '
+ +'<input type="submit" name="uTopic" id="uTopic" value="Save Changes"/> <!--input type="submit" jwcid="cancelTopic@Submit" '
+ +'listener="listener:doCancel" value="message:label.cancel-changes" async="true"/--></div> </form> </div>';
+
+ jum.assertEquals(expected, tapestry.html._processCompactElements(initial));
+ jum.assertEquals(expected + expected,
+ tapestry.html._processCompactElements(initial+initial));
}
function _createTestNode(element, empty){
var node = document.createElement("div");
node.setAttribute("id", "testid");
-
- if (!element)
- element="div";
-
+
+ if (!element)
+ element="div";
+
var node2 = document.createElement(element);
node2.setAttribute("id", "testid2");
-
- if (!empty){
- var content = document.createTextNode("content");
- node2.appendChild(content);
- }
-
- node.appendChild(node2);
-
- return node;
+
+ if (!empty){
+ var content = document.createTextNode("content");
+ node2.appendChild(content);
+ }
+
+ node.appendChild(node2);
+
+ return node;
}