Web 2.0 Patterns

August 16, 2009 by sunking2
  1. The Service-Oriented Architecture Pattern
  2. The Software as a Service (SaaS) Pattern
  3. The Participation-Collaboration Pattern
  4. The Asynchronous Particle Update Pattern
  5. The Mashup Pattern
  6. The Rich User Experience Pattern
  7. The Synchronized Web Pattern
  8. The Collaborative Tagging Pattern
  9. The Declarative Living and Tag Gardening Pattern
  10. The Semantic Web Grounding Pattern
  11. The Persistent Rights Management (PRM) Pattern
  12. The Structured Information Pattern

Read Web 2.0 Architectures, 1st Edition (O’Reilly May 2009, Duane Nickull et. al.) at Safari Books Online or look at the listing in Amazon.com

Add validation to any form in 2 easy steps:

August 5, 2009 by sunking2

1. Put “class=” on the fields that you want validated
2. Include this file as validate.js

window.onload = function() {
	prepare();
};
function prepare() {
	regx  = Array();
	// must start with a letter followed by zero or more characters
	regx["startsWithLetter"] = /^[a-z].{0,}$/i;
	regx["digitsOnly"] = /^\d+$/i;

	errMsg = Array();
	errMsg["startsWithLetter"] = "Doesn't start with a letter.";
	errMsg["digitsOnly"] = "Must contain only numbers.";

	var buts = document.getElementsByTagName("input");
	for (var i = 0; i < buts.length; i++) {
		if (buts[i].getAttribute("type") == "submit") {
			buts[i].onclick = function() {
				validate();
				return false;
				};
		}
	}
}
function validateOneField(contents, theClass,  nodeForErrorMessage) {
	var chk = regx[theClass];
	var bText =  chk.test(contents);
	var spans = nodeForErrorMessage.getElementsByTagName("span");
	try {
		for (var k = 0; k < spans.length; k++) {
			if (spans[k].getAttribute("error") == "temp") {
					nodeForErrorMessage.removeChild(spans[k]);
			}
		}
	} catch (e) {}  // not important enough
	if (!bText) {
		var span = document.createElement("span");
		span.setAttribute("error", "temp");
		var nodeText = document.createTextNode(errMsg[theClass]);
		span.appendChild(nodeText);
		nodeForErrorMessage.appendChild(span);
	}
	return bText;
}
function validate() {
	var bReturn = true;
	var inputs = document.getElementsByTagName("input");
	for (var i = 0; i < inputs.length; i++) {
		var type = inputs[i].getAttribute("type");
		if (type != "text") continue;
		var parentNode = inputs[i].parentNode;  // for err msg
		var value = inputs[i].value;  // field contents

		// validate each if it has a class name indicating so
		var className = inputs[i].className;

		if (className) var bValid =
			validateOneField(value, className, parentNode);
		// if it failed, let this whole function fail too
		if (!bValid) bReturn = false;
	}
	return bReturn;
}

And here is some of the HTML

<script type=”text/JavaScript” src=”validate.js”></script>

ID Number:
<input name=”id” type=”text” class=”digitsOnly” />
Name:
<input name=”name” type=”text” class=”startsWithLetter” />

A huge repository of Web Data – Wiki style

August 3, 2009 by sunking2

Imagine a site where anyone can enter data, edit previously entered data, and define new types of tables.   But why not take it further, Wikipedia style?  Ouseful has a few posts on collecting data that’s already out there, and mashing it up with pipes and Google Docs.

So data is already public.  But not accessible.  Want to make a semantic web?  Make the data easier to access.  Start by collecting it.

Collecting it is  a huge job.  Obviously get the entire Internet to help you by allowing anyone to edit the collected data.  And there will be audit trails (histories of changes), Wikipedia style.

View my ongoing work at http://data-everywhere.appspot.com

EL in JSP not working in Eclipse Google App Engine?

July 30, 2009 by sunking2

fear no more.  Simply update your web.xml so the tag below looks more like this:

<web-app xmlns=”http://java.sun.com/xml/ns/j2ee”
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=
“http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd”
version=”2.4″>

Ya I know it says 2.4 when Google App Engine and Eclipse said 2.5.  But this works, whereas the way it was makes JSP Expression Language Unavailable