r8855@llin: dpavlin | 2005-11-14 01:49:57 +0100
[webpac2] / web / iwf / docs / overview.xml
1 <response>\r
2         <action type='html'>\r
3                 <a name='overview' />\r
4                 <h2>Overview</h2>\r
5                 <p>\r
6                 <a href='http://iwf.sourceforge.net'>Interactive Website Framework</a>, or IWF, is essentially a set of javascripts which encapsulate a large\r
7                 portion of the "grunt work" required when making highly interactive websites.  A highly interactive\r
8                 website can be defined as a site which performs background http requests (Ajax), permits smooth\r
9                 transitioning of elements' visibility and location (Animation), and immediate form validation.\r
10                 </p>\r
11                 <h3>Intuitive API</h3>\r
12                 <p>\r
13                 IWF has been designed from the ground up to allow for a "typical" web developer to be able to\r
14                 harness its power without changing his or her methodologies drastically.\r
15                 </p>\r
16                 <p>\r
17                 All IWF-related javascript and HTML has '<code>iwf</code>' as the prefix -- <code>iwfRequest()</code>, <code>iwfGetById()</code>, <code>iwfOnRequestError()</code>, etc.\r
18                 The only exception to this are 'private' functions which should be used internally by IWF itself -- these have a '<code>_iwf</code>' prefix.\r
19                 This '<code>iwf</code>' prefixing minimizes name clashing and makes it very obvious when calling into IWF.  \r
20                 </p>\r
21                 <p>\r
22                 The primary limitation IWF imposes is that all HTML it handles <b>must</b> be XHTML compliant.\r
23                 However, I do not believe this is a very stringent requirement with disciplined developers.\r
24                 </p>\r
25                 <p>\r
26                 IWF also includes and uses its own xml parser, <code>iwfXmlDoc</code> and <code>iwfXmlNode</code>.\r
27                 I wrote this xml parser to have more intuitive javascript when manipulating xml on the client.\r
28                 For example, let's say we have the following xml:\r
29                 <pre>\r
30 &lt;internet&gt;\r
31         &lt;site url='www.sourceforge.net'&gt;\r
32                 &lt;description&gt;Great place for open source projects!&lt;/description&gt;\r
33         &lt;/site&gt;\r
34         &lt;site url='iwf.sourceforge.net'&gt;\r
35                 &lt;description&gt;IWF Project Home&lt;/description&gt;\r
36         &lt;/site&gt;\r
37 &lt;/internet&gt;\r
38                 </pre>\r
39                 To pull the description for the IWF site using the typical DOM:<br />\r
40                 <pre>var desc = doc.documentElement.lastChild().firstChild().innerText;</pre>\r
41                 To pull the same node using the custom IWF implementation:<br />\r
42                 <pre>var desc = doc.internet.site[1].description[0].getText();</pre>\r
43                 </p>\r
44                 <p>\r
45                 As you can see, the IWF implementation produces very readable and maintainable javascript,\r
46                 albeit a non-standard way of accessing xml data.\r
47                 </p>\r
48 \r
49                 <h3>Xml At Heart</h3>\r
50                 <p>\r
51                 IWF only understands xml.  In fact, IWF has a very specific xml format it requires to enable\r
52                 one to fully utilize its capabilities.\r
53                 </p>\r
54                 <p>\r
55                 A typical xml stream that IWF understands and can automatically process looks like the following:\r
56                 </p>\r
57                 <p>\r
58                 <pre>\r
59 &lt;response&gt;\r
60         &lt;action type='html' target='divResponse' errorCode='' errorMessage='' &gt;\r
61                 &lt;h1&gt;This is text within an H1 element.\r
62                 All data within this action node will be populated into the innerHTML \r
63                 attribute of the element with the id matching the one specified by the \r
64                 target attribute above, which is 'divResponse'.&lt;/h1&gt;\r
65         &lt;/action&gt;\r
66 &lt;/response&gt;\r
67                 </pre>\r
68                 </p>\r
69                 <p>\r
70                 Things to note:\r
71                 <ul>\r
72                         <li>A <code>response</code> node wraps the entire thing, but does nothing else.</li>\r
73                         <li>There may be multiple <code>action</code> nodes.</li>\r
74                         <li>The <code>action</code> node causes the browser to do different things based on the <code>type</code> attribute.</li>\r
75                         <li>If the <code>errorCode</code> is specified and != 0, the javascript function iwfOnRequestError will be called if it exists, and processing of this <code>action</code> node is aborted.</li>\r
76                         <li>The values for the <code>type</code> attribute are:\r
77                                 <ul>\r
78                                         <li>html == contents of node are XHTML</li>\r
79                                         <li>javascript == contents of node are javascript</li>\r
80                                         <li>xml == contents of node are xml</li>\r
81                                 </ul>\r
82                         </li>\r
83                         <li>The <code>target</code> only applies when <code>type</code> is 'html'.  This specifies the id of the element which will be populated with the contents of the node.</li>\r
84                         <li>When <code>type</code> is javascript, the contents of the node are parsed and executed as javascript.  It will be made available to the browser so other javascript already in the document can call this javascript.</li>\r
85                         <li>When <code>type</code> is xml, an <code>iwfXmlNode</code> object is passed to the <code>callback</code> function defined when <code>iwfRequest</code> was called.  If none exists, this action is ignored.</li>\r
86                 </ul>\r
87                 </p>\r
88                 <h3>Thread Safe Requests</h3>\r
89                 <p>\r
90                 IWF uses a javascript feature called an inner function to handle multiple requests simultaneously.\r
91                 An inner function is simply a function defined within another function.  What makes it special is the\r
92                 inner function has visibility to the outer function's local variables.  Those local variables do not\r
93                 fall out of scope until after all items in the outer function's activation context has completed.  By\r
94                 setting the XmlHttpRequest object's <code>onreadystatechange</code> callback to our inner function,\r
95                 it causes the inner function to stay activated -- which means the outer function's local variables are \r
96                 still available until that inner function has executed.  When the XmlHttpRequest has completed, the\r
97                 inner function uses the outer function's variables to determine what method to callback (if any), \r
98                 which target was specified (if any), etc.\r
99                 </p>\r
100                 <p>\r
101                 If that was a little too much at once, don't sweat it.  Essentially, your users can click multiple links\r
102                 rapidly and all requests will be performed and processed, without the worry of "missing" or "dropping" any.\r
103                 </p>\r
104                 <h3>As Flexibile As Needed</h3>\r
105                 <p>\r
106                 As mentioned above, IWF uses xml for all of its responses.  That xml is inspected, and IWF acts\r
107                 according to how the xml specifies.  So if you want to have your server kicking back XHTML and injecting\r
108                 it into an element in the browser, you can.  If you want the server kicking back javascript and executing\r
109                 it, you can.  If you want the server kicking back straight xml, which the client will be responsible for\r
110                 parsing and acting upon, you can.\r
111                 </p>\r
112                 <p>\r
113                 </p>\r
114                 <h3>Browser Independent</h3>\r
115                 <p>\r
116                 IWF is heavily reliant upon client-side javascript.  In fact, if the user does not have a\r
117                 javascript-capable browser, or javascript is disabled, IWF simply will not work.\r
118                 </p>\r
119                 <p>\r
120                 However, all javascript has been written / tested / verified on Firefox 1.0.3 and IE 6.0 running under Win XP.\r
121                 Most of what IWF does is fairly basic, so most other major browsers should work fine.  If not, <a href='mailto:brockweaver&#64;sourceforge.net'>drop me a line</a> and I'll see if I can get it working.\r
122 <pre>\r
123 &lt;plug type='shameless'&gt;\r
124         If you want me to start supporting Safari, <a href='donate.php'>donate to my iMac fund</a>!\r
125 &lt;/plug&gt;\r
126 </pre>\r
127                 </p>\r
128                 <h3>Server Platform Independent</h3>\r
129                 <p>\r
130                 Since IWF is primarily a client-side technology, any web server which can kick out ASCII will work perfectly -- and by definition, any web server\r
131                 can do this.  All IWF requires from the server is a valid xml stream in IWF format.\r
132                 </p>\r
133                 <p>\r
134                 PHP is my favorite web scripting language, so I have implemented a very simple class for emitting\r
135                 IWF-copmliant xml from a PHP server.  This could very easily be ported to ASP, but since the release\r
136                 of ASP.NET, my focus has shifted away from it.\r
137                 </p>\r
138                 <p>\r
139                 \r
140                 </p>\r
141                 <p>\r
142                 </p>\r
143                 <p>\r
144                 </p>\r
145                 <p>\r
146                 </p>\r
147                 <p>\r
148                 </p>\r
149                 <p>\r
150                 </p>\r
151                 <p>\r
152                 </p>\r
153                 <p>\r
154                 </p>\r
155                 <p>\r
156                 </p>\r
157                 <p>\r
158                 </p>\r
159                 <p>\r
160                 </p>\r
161                 <p>\r
162                 </p>\r
163                 <p>\r
164                 </p>\r
165                 <p>\r
166                 </p>\r
167                 <p>\r
168                 </p>\r
169                 <p>\r
170                 </p>\r
171                 <p>\r
172                 </p>\r
173                 <p>\r
174                 </p>\r
175                 <p>\r
176                 </p>\r
177                 <p>\r
178                 </p>\r
179                 <p>\r
180                 </p>\r
181                 <p>\r
182                 </p>\r
183                 <p>\r
184                 </p>\r
185                 <p>\r
186                 </p>\r
187                 <p>\r
188                 </p>\r
189                 <p>\r
190                 </p>\r
191                 <p>\r
192                 </p>\r
193                 <p>\r
194                 </p>\r
195                 <p>\r
196                 </p>\r
197                 <p>\r
198                 </p>\r
199                 <p>\r
200                 </p>\r
201                 <p>\r
202                 </p>\r
203                 <p>\r
204                 </p>\r
205                 <p>\r
206                 </p>\r
207         </action>\r
208 </response>