<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Falling Dominos &#187; javascript</title>
	<atom:link href="http://codepress.net/b/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://codepress.net/b</link>
	<description>Let&#039;s keep Lotus Notes development relevant</description>
	<lastBuildDate>Fri, 19 Feb 2010 02:36:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Multiple Forms in Domino Web Applications</title>
		<link>http://codepress.net/b/2008/07/09/multiple-forms-in-domino-web-applications/</link>
		<comments>http://codepress.net/b/2008/07/09/multiple-forms-in-domino-web-applications/#comments</comments>
		<pubDate>Wed, 09 Jul 2008 10:56:04 +0000</pubDate>
		<dc:creator>Tom ONeil</dc:creator>
				<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://codepress.net/b/?p=190</guid>
		<description><![CDATA[UPDATE: A co-worker found some bugs in my standard javascript or &#8220;JSHeader&#8221; code that I had posted on this site. Most of the issues were related to how I was checking for &#8220;null&#8221; instead of checking to see if a variable was &#8220;undefined.&#8221; Also, the &#8220;getMyForm&#8221; function was not working if you sent a checkbox [...]]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE: </strong><em>A co-worker found some bugs in my standard javascript or &#8220;JSHeader&#8221; code that I had posted on this site. Most of the issues were related to how I was checking for &#8220;null&#8221; instead of checking to see if a variable was &#8220;undefined.&#8221; Also, the &#8220;getMyForm&#8221; function was not working if you sent a checkbox as the field. These issues have been fixed and the code has been posted below.</em></p>
<p>I&#8217;m having some fun in a legacy application at work. The Lotus Notes/Domino forms I am creating and maintaining are embedded into an ActiveX frame (like a portal).</p>
<p>Prior to this application, I think all of my development has been under the assumption that the Domino generated HTML form was the only form. Hence, document.forms[0] was my standard. Well, now that I&#8217;m working in this embedded application, that isn&#8217;t always true. I&#8217;ve had to rewrite some of my javascript to work with the current form.</p>
<p>The first thing I had to create was a function to get the current form.<br />
<br/></p>
<pre><code>
function getMyForm(field) {
// returns form element
	if (typeof(field) == "string") {
		for (var i = 0; i < document.forms.length;i++) {
			if (document.forms[i][field] != null) {
				return document.forms[i];
			}
		}
	} else {
		if (field.length >= 0) {
			var element = field[0];
		} else {
			var element = field;
		}
		while (element != null) {

			element = element.parentElement;
			if (element.tagName == "FORM") {
				return element;
				break;
			}

		}
	}

}
</code></pre>
<p><br/><br />
I am still debating how to implement the next function. I wasn&#8217;t sure if I should pass the form into the function, expect that I already have it (bad design), or get it using the function above. I actually do a mixture of the last two options.<br />
<br/></p>
<pre><code>
function getFieldValues(field) {
// Returns array of values. Depends on getMyForm.
	var value = new Array;
	if (typeof(form) == "undefined" || form == null || form.tagName != "FORM") {
		form = getMyForm(field);
	}
	if (typeof(field) == "object") {
		var theField = field;
	} else if (typeof(field) == "string") {
		var theField = form[field];
	} else {
		var theField = form[field.name];
	}

	if (theField == null) { // Exit quietly if field cannot be found.
		window.status = "Cannot get value for field:" + field.toString();
		return [''];

	}

	if (theField.length == null &#038;&#038; theField.options == null) {
		if (theField.type == "checkbox" &#038;&#038; theField.checked == false) {
			value =  [''];
		} else {
			value =  [theField.value];
		}
	} else if (theField.options != null) {
		for (var i = 0; i < theField.options.length;i++) {
			if (theField.options[i].selected == true) {
				if (theField.options[i].value === "") {
					value.push(theField.options[i].text);
				} else {
					value.push(theField.options[i].value);
				}
			}
		}
	} else if (theField.length >= 0) {
		for (var i = 0; i < theField.length;i++) {
			if (theField[i].checked == true) {
				value.push(theField[i].value);
			}
		}
	}
	if (value.length == 0) {
		value = [''];
	}
	return value;
}
</code></pre>
<p><br/><br />
I also have a function to set the value(s) of any field.<br />
<br/></p>
<pre><code>
function setFieldValue(field,values) {
// Sets array of values. Depends on getMyForm.
	if (typeof(form) == "undefined" || form == null || form.tagName != "FORM") {
		form = getMyForm(field);
	}
	if (typeof(field) == "object") {
		var theField = field;
	} else if (typeof(field) == "string") {
		var theField = form[field];
	} else {
		var theField = form[field.name];
	}
	if (typeof(values) == "object") {
	} else {
		values = [values];
	}
	if (theField == null) { // Exit quietly if field cannot be found.
		window.status = "Cannot set value for field:" + field.toString();
		return;

	}
	if (theField.length == null &#038;&#038; theField.options == null &#038;&#038; theField.type != "checkbox") {
		theField.value = values[0];
	} else if (theField.options != null) {
		for (var x = 0; x < values.length;x++) {
			for (var i = 0; i < theField.options.length;i++) {
				if (theField.options[i].value == values[x] || (theField.options[i].value == "" &#038;&#038;
				 theField.options[i].text == values[x])) {
					theField.options[i].selected = true;
				}
			}
		}
	} else if (theField.length >= 0) {
		for (var x = 0; x < values.length;x++) {
			for (var i = 0; i < theField.length;i++) {
				if (theField[i].value == values[x] || (theField[i].value == "" &#038;&#038;
				 theField.options[i].text == values[x])) {
					theField[i].checked = true;
				}
			}
		}
	} else if (theField.type == "checkbox" &#038;&#038; values[0] !== "") {
		theField.checked = true;
	}
}
</code></pre>
<p><br/><br />
Finally, a function to set the focus of a field (if it can find it).<br />
<br/></p>
<pre><code>
function setFocus(field) {
	if (typeof(field) == "undefined" || field == null) {
		return;
	}
	var value = new Array;
	if (typeof(form) == "undefined" || form == null || form.tagName != "FORM") {
		form = getMyForm(field);
	}
	if (typeof(field) == "string") {
		var theField = form[field];
	} else {
		var theField = form[field.name];
	}
	if (theField == null || theField.name === "") {
		window.status =  "Unable to set focus for field " + field;
		return;
	}
	if (theField.length == null || theField.options != null) {
		theField.focus();
	} else if (theField.length >= 0) {
		theField[0].focus();
	}
}
</code></pre>
<p><br/><br />
This is nothing new for a lot of developers and frameworks like jQuery and Prototype handle a lot of this. But in many instances, you're stuck in legacy code that doesn't allow you to throw in frameworks (or you really don't want to have to explain what you're doing to the other developers).</p>
]]></content:encoded>
			<wfw:commentRss>http://codepress.net/b/2008/07/09/multiple-forms-in-domino-web-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Small R8 bug (enhancement?) with Rendering HTML</title>
		<link>http://codepress.net/b/2008/06/20/small-r8-bug-enhancement-with-rendering-html/</link>
		<comments>http://codepress.net/b/2008/06/20/small-r8-bug-enhancement-with-rendering-html/#comments</comments>
		<pubDate>Fri, 20 Jun 2008 14:40:51 +0000</pubDate>
		<dc:creator>Tom ONeil</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[lotus]]></category>
		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://codepress.net/b/?p=183</guid>
		<description><![CDATA[A couple of disclaimers&#8230; 1) We&#8217;re in the middle of upgrading to R8. Some of our mail servers have been upgraded but none of our production application servers have the new version yet. 2) This is an old (2001) application that was written for the web. I had no part of the initial development.
I discovered [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of disclaimers&#8230; 1) We&#8217;re in the middle of upgrading to R8. Some of our mail servers have been upgraded but none of our production application servers have the new version yet. 2) This is an old (2001) application that was written for the web. I had no part of the initial development.</p>
<p>I discovered a small bug in the rendering of HTML in R8. It was discovered when a user was opening forms sent to a shared mailbox on an R8 server.</p>
<p><strong>The Problem</strong><br />
Lotus Notes R8 was overlapping fields when rendering a table in the browser.</p>
<p><em>Here is what the user saw on an R8 server:</em><br />
<img src="http://codepress.net/b/wp-content/uploads/2008/bg_1.gif" alt="R8.1"/><br />
<em>Here is what it looks like in R6:</em><br />
<img src="http://codepress.net/b/wp-content/uploads/2008/bg_2.gif" alt="R8.2"/></p>
<p><strong>The Cause</strong><br />
Spanned table cells/rows. In R8 (or possibly R7) Lotus decided it would help us out by rendering empty table rows (TR tags) with a style of &#8220;display:none.&#8221; Unfortunately, this affects rows that are being used by the ROWSPAN tag.</p>
<p><em>Here are the merged cells in the Notes Designer:</em><br />
<img src="http://codepress.net/b/wp-content/uploads/2008/bg_3.gif" alt="R8.3"/></p>
<p><em>Here are the split cells:</em><br />
<img src="http://codepress.net/b/wp-content/uploads/2008/bg_4.gif" alt="R8.4"/></p>
<p>In the browser (both versions) Notes tries to render the tables with a series of COLSPAN and ROWSPAN tags to render the table exactly the way it is displayed in the designer.</p>
<p><em>Here is the HTML from the R6 version:</em></p>
<pre><code>
<tr valign="top">
<td width="50%" rowspan="4" colspan="2"><b>2.</b><b><font color="#FF0000"> Company #: (3 digits)</font></b><b> </b> <font color="#0000ff">
<input name="CompanyNumber" value="" size=5></font></td>
<td width="50%" rowspan="4" colspan="2"><b><font color="#FF0000">Cost Center #: (7 digits)</font></b><font color="#0000ff">
<input name="CenterNumber" value="" size=10></font></td>
</tr>
<tr></tr>
<tr></tr>
<tr></tr>
<tr valign="top">
<td width="25%"><img src="/icons/ecblank.gif" border="0" height="1" width="1" alt=""></td>
<td width="75%" colspan="3">
<div align="right"><b><font color="#FF0000">Phone Number:</font></b><b>(</b><font color="#0000ff">
<input name="PhoneArea" value="" size=3 maxlength=3></font> <b>)</b> <font color="#0000ff">
<input name="PhonePrefix" value="" size=3 maxlength=3></font> -<font color="#0000ff">
<input name="PhoneSuffix" value="" size=4 maxlength=4></font></div>
</td>
</tr>
<tr valign="top">
<td width="25%"><img src="/icons/ecblank.gif" border="0" height="1" width="1" alt=""></td>
<td width="75%" colspan="3">
<div align="right"><b><font color="#FF0000">Fax Number:</font></b><b>(</b><font color="#0000ff">
<input name="FaxArea" value="" size=3 maxlength=3></font><b> )</b> <font color="#0000ff">
<input name="FaxPrefix" value="" size=3 maxlength=3></font><b> -</b><font color="#0000ff">
<input name="FaxSuffix" value="" size=4 maxlength=4></font></div>
</td>
</tr>

</code></pre>
<p>Here is the HTML from the R8 version:</p>
<pre><code>
<tr valign="top">
<td width="50%" rowspan="4" colspan="2"><b>2.</b><b><font color="#FF0000"> Company #: (3 digits)</font></b><b> </b> <font color="#0000ff">
<input name="CompanyNumber" value="" size=5></font></td>
<td width="50%" rowspan="4" colspan="2"><b><font color="#FF0000">Cost Center #: (7 digits)</font></b><font color="#0000ff">
<input name="CenterNumber" value="" size=10></font></td>
</tr>
<tr style="display: none"></tr>
<tr style="display: none"></tr>
<tr style="display: none"></tr>
<tr valign="top">
<td width="25%"><img width="1" height="1" src="/icons/ecblank.gif" border="0" alt=""></td>
<td width="75%" colspan="3">
<div align="right"><b><font color="#FF0000">Phone Number:</font></b><b>(</b><font color="#0000ff">
<input name="PhoneArea" value="" size=3 maxlength=3></font> <b>)</b> <font color="#0000ff">
<input name="PhonePrefix" value="" size=3 maxlength=3></font> -<font color="#0000ff">
<input name="PhoneSuffix" value="" size=4 maxlength=4></font></div>
</td>
</tr>
<tr valign="top">
<td width="25%"><img width="1" height="1" src="/icons/ecblank.gif" border="0" alt=""></td>
<td width="75%" colspan="3">
<div align="right"><b><font color="#FF0000">Fax Number:</font></b><b>(</b><font color="#0000ff">
<input name="FaxArea" value="" size=3 maxlength=3></font><b> )</b> <font color="#0000ff">
<input name="FaxPrefix" value="" size=3 maxlength=3></font><b> -</b><font color="#0000ff">
<input name="FaxSuffix" value="" size=4 maxlength=4></font></div>
</td>
</tr>

</code></pre>
<p>Notice the <code><br />
<tr style="display: none"></tr>
<p></code> tags? I am no HTML expert but it seems to cause issues with the ROWSPAN for cost center.</p>
<p><strong>The Solution</strong><br />
We&#8217;re screwed. Seriously. Only testing will discover these strange renderings. I fixed the problem above by deleting the three unnecessarily merged rows. Hopefully, this was a freak occurance but be aware of how R8 is rendering your HTML.</p>
]]></content:encoded>
			<wfw:commentRss>http://codepress.net/b/2008/06/20/small-r8-bug-enhancement-with-rendering-html/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Lotus Domino 8.5 Suggestion</title>
		<link>http://codepress.net/b/2008/05/25/lotus-domino-85-suggestion/</link>
		<comments>http://codepress.net/b/2008/05/25/lotus-domino-85-suggestion/#comments</comments>
		<pubDate>Mon, 26 May 2008 01:03:53 +0000</pubDate>
		<dc:creator>Tom ONeil</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[lotus]]></category>
		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://codepress.net/b/?p=176</guid>
		<description><![CDATA[I believe Mary Beth Raven was asking for suggestions for the 8.5 version of Lotus Domino. My suggestion is easy&#8230;
Make this (beware&#8230; it&#8217;s a Microsoft Link) the standard web view control for ASPX/Domino pages. It might be overkill but it has every feature you would want in a web table. Sorting AND filtering. Try the [...]]]></description>
			<content:encoded><![CDATA[<p>I believe <a href="http://www.ibm.com/developerworks/blogs/page/marybeth" target="_blank">Mary Beth Raven</a> was asking for suggestions for the 8.5 version of Lotus Domino. My suggestion is easy&#8230;</p>
<p>Make <a href="http://demos.devexpress.com/ASPxGridViewDemos/Filtering/HeaderFilter.aspx" target="_blank">this</a> (beware&#8230; it&#8217;s a Microsoft Link) the standard web view control for ASPX/Domino pages. It might be overkill but it has every feature you would want in a web table. Sorting AND filtering. Try the filter&#8230; it&#8217;s pretty sweet.</p>
]]></content:encoded>
			<wfw:commentRss>http://codepress.net/b/2008/05/25/lotus-domino-85-suggestion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Link: The State of JSON (by John Resig)</title>
		<link>http://codepress.net/b/2008/02/01/link-the-state-of-json-by-john-resig/</link>
		<comments>http://codepress.net/b/2008/02/01/link-the-state-of-json-by-john-resig/#comments</comments>
		<pubDate>Sat, 02 Feb 2008 03:50:18 +0000</pubDate>
		<dc:creator>Tom ONeil</dc:creator>
				<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://codepress.net/b/2008/02/01/link-the-state-of-json-by-john-resig/</guid>
		<description><![CDATA[John Resig posted a recap of recent events occurring around JSON. A lot of demos at Lotusphere used JSON and Domino&#8217;s ?ReadViewEntries&#038;Output=JSON so it&#8217;s good to pay attention to what is going on.
He also posted Douglas Crockford&#8217;s JSON API. It looks much more complete than the plain-old eval statements I was using.
]]></description>
			<content:encoded><![CDATA[<p>John Resig posted <a href="http://ajax.dzone.com/news/state-json">a recap</a> of recent events occurring around JSON. A lot of demos at Lotusphere used JSON and Domino&#8217;s ?ReadViewEntries&#038;Output=JSON so it&#8217;s good to pay attention to what is going on.</p>
<p>He also posted <a href="http://www.crockford.com">Douglas Crockford&#8217;s</a> <a href="http://www.json.org/json2.js">JSON API</a>. It looks much more complete than the plain-old eval statements I was using.</p>
]]></content:encoded>
			<wfw:commentRss>http://codepress.net/b/2008/02/01/link-the-state-of-json-by-john-resig/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
