/[webpac2]/trunk/web/iwf/docs/examples.xml
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/web/iwf/docs/examples.xml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 46 - (show annotations)
Mon Nov 14 16:13:17 2005 UTC (18 years, 5 months ago) by dpavlin
File MIME type: text/xml
File size: 12180 byte(s)
 r8855@llin:  dpavlin | 2005-11-14 01:49:57 +0100
 added small browser using Interactive Website Framework
 from http://iwf.sourceforge.net

1 <response>
2 <action type='html'>
3 <a name='examples' />
4 <h2>Examples</h2>
5 <p>
6 IWF has been designed from the ground up to allow for a "typical" web developer to be able to
7 harness its power without changing his or her methodologies drastically. For instance, you would
8 still fill out anchor tag <code>href</code> attributes, form tag <code>onsubmit</code> attributes,
9 form control tag (aka <code>&lt;input&gt;</code>, <code>&lt;textarea&gt;</code>, <code>&lt;select&gt;</code>)
10 <code>onclick</code> attributes, etc.
11 </p>
12 <h3>Basic Link Navigation (<code>&lt;a href=''&gt;</code>)</h3>
13 <p>
14 To make the browser download new data into a portion of the page (instead of refreshing the entire page),
15 simply wrap the url in a javascript call to <code>iwfRequest</code>:
16 </p>
17 <pre>
18 &lt;html&gt;
19 &lt;head&gt;
20 <b>
21 &lt;script type='text/javascript' src='iwfcore.js'&gt;&lt;/script&gt;
22 &lt;script type='text/javascript' src='iwfgui.js'&gt;&lt;/script&gt;
23 &lt;script type='text/javascript' src='iwfxml.js'&gt;&lt;/script&gt;
24 &lt;script type='text/javascript' src='iwfajax.js'&gt;&lt;/script&gt;
25 </b>
26 &lt;/head&gt;
27 &lt;body&gt;
28 &lt;div id='iwfContent' /&gt;
29 <b>&lt;a href='javascript:iwfRequest("iwfexample2.xml");'&gt;Get Info&lt;/a&gt;</b>
30 &lt;/body&gt;
31 &lt;/html&gt;
32 </pre>
33 <p>
34 One of the first things you will notice are the javascript files you must include for IWF to work.
35 These javascript files are somewhat large -- about 20k each. This is roughly the size of a logo image,
36 if you want to put it into perspective with the size of a typical webpage.
37 </p>
38 <p>
39 You'll notice the call to <code>iwfRequest</code> is relatively simple: just specify the url you wish to request.
40 </p>
41 <p>
42 So the question is, what does it do with the response? The answer is: it depends.
43 </p>
44 <p>
45 Both the client and the server can control where content is placed after a response is received. If the client specifies a target, the server target in the xml is ignored.
46 In our example, no target is specified in our call to
47 <code>iwfRequest</code>, and assuming the xml response from the server doesn't contain a target, the IWF default target of <code>iwfContent</code> is used.
48 If there is no element with the id that matches the target (default or not), IWF will <code>alert</code> an error.
49 </p>
50 <h4>Populate A Specific Element</h4>
51 <p>
52 Now let's push the response into a specific element instead of the default one. We'll use the <code>id</code> of
53 <code>responseGoesHere</code>:
54 </p>
55 <p>
56 All we need to do is specify the second parameter of the
57 <code>iwfRequest</code> function, which is the id of the element into which we are to push the response.
58 </p>
59 <p>
60 <pre>
61 &lt;html&gt;
62 &lt;head&gt;
63 &lt;script type='text/javascript' src='iwfcore.js'&gt;&lt;/script&gt;
64 &lt;script type='text/javascript' src='iwfgui.js'&gt;&lt;/script&gt;
65 &lt;script type='text/javascript' src='iwfxml.js'&gt;&lt;/script&gt;
66 &lt;script type='text/javascript' src='iwfajax.js'&gt;&lt;/script&gt;
67 &lt;/head&gt;
68 &lt;body&gt;
69 &lt;div id='iwfContent' /&gt;
70 <b>&lt;div id='responseGoesHere' /&gt;</b>
71 &lt;a href='javascript:return iwfRequest("iwfexample2.xml"<b>, "responseGoesHere"</b>);'&gt;Get Info&lt;/a&gt;
72 &lt;/body&gt;
73 &lt;/html&gt;
74 </pre>
75 </p>
76
77 <h3>Form Submission via <code>&lt;input type='submit'&gt;</code></h3>
78 <p>
79 When a form control object, a form object, or a form name is passed to <code>iwfRequest</code> it reads the
80 values from the <code>&lt;form&gt;</code> tag to get the <code>action</code>, <code>method</code>, and <code>enctype</code> (or <code>encoding</code>) to determine how to perform
81 its request. IWF is simply emulating the default behavior any browser would when submitting a form, so the coding habits
82 transfer from "normal" websites well.
83 </p>
84 <h4>Populate Default Element</h4>
85 <p>
86 The following
87 code will post the form in the background when the user clicks the submit button, then fill the results into the IWF default
88 <code>&lt;div id='iwfContent' /&gt;</code> element:
89 <pre>
90 &lt;html&gt;
91 &lt;head&gt;
92 &lt;script type='text/javascript' src='iwfcore.js'&gt;&lt;/script&gt;
93 &lt;script type='text/javascript' src='iwfgui.js'&gt;&lt;/script&gt;
94 &lt;script type='text/javascript' src='iwfxml.js'&gt;&lt;/script&gt;
95 &lt;script type='text/javascript' src='iwfajax.js'&gt;&lt;/script&gt;
96 &lt;/head&gt;
97 &lt;body&gt;
98 &lt;div id='iwfContent' /&gt;
99 &lt;form name='frmExample' action='iwfexample.xml' method='post' <b>onsubmit='javascript:return iwfRequest(this);'</b>&gt;
100 &lt;input type='hidden' value='this is posted' name='hidPosted' /&gt;
101 &lt;input type='submit' name='btnSubmit' value='Submit' /&gt;
102 &lt;/form&gt;
103 &lt;/body&gt;
104 &lt;/html&gt;
105 </pre>
106 </p>
107 <p>
108 You may notice the <code>&lt;form&gt;</code> tag's <code>onsubmit</code> attribute.
109 Previously, we passed a url as the first parameter -- now we're passing the <code>form</code> object.
110 IWF detects what is being passed and creates the details of the http request to send automatically.
111 </p>
112 <h4>Populate Specfic Element</h4>
113 <p>
114 Now, should we want to populate a specific element other than the default of <code>iwfContent</code>,
115 say one named <code>responseGoesHere</code>:
116 </p>
117 <p>
118 <pre>
119 &lt;html&gt;
120 &lt;head&gt;
121 &lt;script type='text/javascript' src='iwfcore.js'&gt;&lt;/script&gt;
122 &lt;script type='text/javascript' src='iwfgui.js'&gt;&lt;/script&gt;
123 &lt;script type='text/javascript' src='iwfxml.js'&gt;&lt;/script&gt;
124 &lt;script type='text/javascript' src='iwfajax.js'&gt;&lt;/script&gt;
125 &lt;/head&gt;
126 &lt;body&gt;
127 &lt;div id='iwfContent' /&gt;
128 <b>&lt;div id='responseGoesHere' /&gt;</b>
129 &lt;form name='frmExample' action='iwfexample.xml' method='post' onsubmit='javascript:return iwfRequest(this<b>, "responseGoesHere"</b>);'&gt;
130 &lt;input type='hidden' value='this is posted' name='hidPosted' /&gt;
131 &lt;input type='submit' name='btnSubmit' value='Submit' /&gt;
132 &lt;/form&gt;
133 &lt;/body&gt;
134 &lt;/html&gt;
135 </pre>
136 </p>
137 <h3>Form Submission via a button click / checkbox change / etc</h3>
138 <p>
139 You may want submit a form on user input that is not clicking the "submit" button. In traditional websites,
140 this was done using <code>form.submit()</code> or something similar. IWF supports this kind of functionality in
141 much the same way as it does with using the "submit" button -- you must call <code>iwfRequest(this)</code>.
142 </p>
143 <p>
144 IWF is able to determine that the request is being called from a form control element and not a form element.
145 It then can determine the form which contains that element, parse that form's contents, etc. So the API for doing
146 this type of form submittal is identical to the original type. It is important to note, that like the traditional
147 <code>form.submit()</code>, submitting forms using <code>iwfRequest(this)</code> from a form control element does <b>not</b>
148 cause the <code>form.onsubmit</code> event to be called. Again, this reflects the traditional browser behavior, not necessarily
149 the ideal behavior.
150 </p>
151 <h4>Populate Default Element</h4>
152 <p>
153 <pre>
154 &lt;html&gt;
155 &lt;head&gt;
156 &lt;script type='text/javascript' src='iwfcore.js'&gt;&lt;/script&gt;
157 &lt;script type='text/javascript' src='iwfgui.js'&gt;&lt;/script&gt;
158 &lt;script type='text/javascript' src='iwfxml.js'&gt;&lt;/script&gt;
159 &lt;script type='text/javascript' src='iwfajax.js'&gt;&lt;/script&gt;
160 &lt;/head&gt;
161 &lt;body&gt;
162 &lt;div id='iwfContent' /&gt;
163 &lt;form name='frmExample' action='iwfexample.xml' method='post' onsubmit='<b>THIS IS NEVER CALLED</b>'&gt;
164 &lt;input type='hidden' value='this is posted' name='hidPosted' /&gt;
165 <b>&lt;input type='button' name='btnGo' value='Go' onclick='javascript:return iwfRequest(this);' /&gt;</b>
166 &lt;/form&gt;
167 &lt;/body&gt;
168 &lt;/html&gt;
169 </pre>
170 </p>
171 <h4>Populate Specfic Element</h4>
172 <p>
173 <pre>
174 &lt;html&gt;
175 &lt;head&gt;
176 &lt;script type='text/javascript' src='iwfcore.js'&gt;&lt;/script&gt;
177 &lt;script type='text/javascript' src='iwfgui.js'&gt;&lt;/script&gt;
178 &lt;script type='text/javascript' src='iwfxml.js'&gt;&lt;/script&gt;
179 &lt;script type='text/javascript' src='iwfajax.js'&gt;&lt;/script&gt;
180 &lt;/head&gt;
181 &lt;body&gt;
182 &lt;div id='iwfContent' /&gt;
183 <b>&lt;div id='responseGoesHere' /&gt;</b>
184 &lt;form name='frmExample' action='iwfexample.xml' method='post' onsubmit='<b>THIS IS NEVER CALLED</b>'&gt;
185 &lt;input type='hidden' value='this is posted' name='hidPosted' /&gt;
186 &lt;input type='button' name='btnGo' value='Go' onclick='javascript:return iwfRequest(this<b>, "responseGoesHere"</b>);' /&gt;
187 &lt;/form&gt;
188 &lt;/body&gt;
189 &lt;/html&gt;
190 </pre>
191
192 </p>
193 <h3>Form Submission via Link Navigation <code>&lt;a href=''&gt;</code></h3>
194 <p>
195 IWF also supports submitting forms via a hyperlink. Again, it uses the familiar <code>iwfRequest</code> function,
196 but now the <code>name</code> of the form must be passed, as a hyperlink is not considered to be a child of the <code>&lt;form&gt;</code>
197 in which it resides.
198 </p>
199 <h4>Populate Default Element</h4>
200 <p>
201 <pre>
202 &lt;html&gt;
203 &lt;head&gt;
204 &lt;script type='text/javascript' src='iwfcore.js'&gt;&lt;/script&gt;
205 &lt;script type='text/javascript' src='iwfgui.js'&gt;&lt;/script&gt;
206 &lt;script type='text/javascript' src='iwfxml.js'&gt;&lt;/script&gt;
207 &lt;script type='text/javascript' src='iwfajax.js'&gt;&lt;/script&gt;
208 &lt;/head&gt;
209 &lt;body&gt;
210 &lt;div id='iwfContent' /&gt;
211 &lt;form name='frmExample' action='iwfexample.xml' method='post' onsubmit='<b>THIS IS NEVER CALLED</b>'&gt;
212 &lt;input type='hidden' value='this is posted' name='hidPosted' /&gt;
213 <b>&lt;a href='javascript:return iwfRequest("frmExample");'&gt;Go&lt;/a&gt;</b>
214 &lt;/form&gt;
215 &lt;/body&gt;
216 &lt;/html&gt;
217 </pre>
218 </p>
219
220
221
222 <p>
223 When the "Go" link is clicked, IWF will search the current page for a form named "frmExample".
224 If it finds one, it assumes the string is the name of a form and submits it. If it cannot find
225 one, it assumes "frmExample" is a url and requests it from the server.
226
227 <h4>Populate Specfic Element</h4>
228 <p>
229 Again, all we need to do is to specify the target in the call to <code>iwfRequest</code>:
230 </p>
231 <p>
232 <pre>
233 &lt;html&gt;
234 &lt;head&gt;
235 &lt;script type='text/javascript' src='iwfcore.js'&gt;&lt;/script&gt;
236 &lt;script type='text/javascript' src='iwfgui.js'&gt;&lt;/script&gt;
237 &lt;script type='text/javascript' src='iwfxml.js'&gt;&lt;/script&gt;
238 &lt;script type='text/javascript' src='iwfajax.js'&gt;&lt;/script&gt;
239 &lt;/head&gt;
240 &lt;body&gt;
241 &lt;div id='iwfContent' /&gt;
242 <b>&lt;div id='responseGoesHere' /&gt;</b>
243 &lt;form name='frmExample' action='iwfexample.xml' method='post' onsubmit='<b>THIS IS NEVER CALLED</b>'&gt;
244 &lt;input type='hidden' value='this is posted' name='hidPosted' /&gt;
245 <b>&lt;a href='javascript:return iwfRequest("frmExample", "responseGoesHere");' /&gt;</b>
246 &lt;/form&gt;
247 &lt;/body&gt;
248 &lt;/html&gt;
249 </pre>
250 </p>
251
252
253 <p>
254 NOTE: Experienced
255 DHTML coders will notice that <code>iwfRequest</code> returns different values when it is called with a string for the first argument than otherwise:
256 Specifying a string causes <code>iwfRequest</code> to return absolutely no value. This is because clicking an anchor tag causes the browser to navigate to the result of the <code>href</code>, which we do not want to happen.
257 If no value is returned from the <code>href</code>, the browser does nothing.
258 So in our anchor tag example, <code>iwfRequest</code> returns absolutely nothing. However, in our form submission example, <code>iwfRequest</code> returns
259 the value <code>false</code> to prevent the browser from actually submitting the form, as <code>iwfRequest</code> is doing so
260 in the background.
261 </p>
262 </action>
263 </response>

  ViewVC Help
Powered by ViewVC 1.1.26