<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7581919</id><updated>2018-09-29T09:47:00.565+02:00</updated><category term="JavaScript"/><category term="Ajax"/><category term="Behaviors"/><category term="controls"/><category term="AJAXEngine"/><category term="webservice"/><category term="SOAP"/><category term="components"/><category term="Visual Effects"/><category term="OpenAjax"/><category term="Forms"/><category term="book"/><category term="Back Button Problem"/><category term="documentation"/><category term="Ebook"/><category term="Java"/><category term="WCF"/><category term="license"/><title type='text'>Aspects of AJAX</title><subtitle type='html'>Ajax programming is an interesting way of bringing real interactivity to web applications by using the proven internet technologies HTML and JavaScript.&#xa;In this BLOG I want to share my experiences in this area and light up some interesting aspects with simple and advanced topics.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://ajaxaspects.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default?alt=atom'/><link rel='alternate' type='text/html' href='http://ajaxaspects.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default?alt=atom&amp;start-index=26&amp;max-results=25'/><author><name>Matthias Hertel</name><uri>https://plus.google.com/116098072736241499757</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-M0Om2hGPjV8/AAAAAAAAAAI/AAAAAAAAAOs/F8uLY205io8/s512-c/photo.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>95</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7581919.post-4893960470376740393</id><published>2016-02-15T20:06:00.001+01:00</published><updated>2016-02-15T20:06:15.425+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="AJAXEngine"/><title type='text'>Time to rethink the AjaxEngine</title><content type='html'>&lt;div id=&quot;scid:77ECF5F8-D252-44F5-B4EB-D463C5396A79:a9420cc7-2a57-453b-b512-eb2d729b5a34&quot; class=&quot;wlWriterEditableSmartContent&quot; style=&quot;float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px&quot;&gt;Technorati Tags: &lt;a href=&quot;http://technorati.com/tags/AJAX&quot; rel=&quot;tag&quot;&gt;AJAX&lt;/a&gt;&lt;/div&gt;The HTML world is about to step into a new era. A step that was prepared long ago. Everyone can see that the browser will be the home of more modern applications, responsive games, interactive media and enriched content.  &lt;p&gt;The AjaxEngine in contrast was staying there for more than 5 years with almost no change even still many people use it or parts of it. During the last years buxes where fixed and adopting new browsers was implemented by changing as few as possible.&lt;/p&gt; &lt;p&gt;But time has changed:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;The main driver is HTML version 5 standard (HTML5) that is broadly excepted and implemented in almost all the browsers almost completely.  &lt;li&gt;HTML5 and the HTML predecessors have a long history since W3C started more than 20 years ago.  &lt;li&gt;On 28. of October 2014 the HTML5 standard was pushed in the state of a recommendation (HTML 4.01 was in 1999) and the great companies Apple, Google and Microsoft have been involved and accepted.  &lt;li&gt;When using the latest browser version HTML5 is running fine and only some features still are not x-browser compatible.  &lt;li&gt;All the internert browser applications have changed their update strategy from yearly releases to continuous improvements.  &lt;li&gt;Along with the core HTML5 standard further and complementary technologies have been developed.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;There have been a lot of confusing standard discussions around. Many IT-religious questions have been discussed and quasi standards where published on various web-sides. Now that seems to be over. And more than just a standard agreement I see that it gets implemented in a serious and reliable way.  &lt;p&gt;Applause to that great work !&lt;br&gt;... because it makes my life an an web developer easier than before !  &lt;p&gt;You will see things going on in the AjaxEngine and old implementation approaches will be replaced. You can see thins on my web site but I will also release a version on Github and will drop supporting sourceforge.net. &lt;/p&gt; &lt;div class=&quot;post-footer-line post-footer-line-2&quot;&gt;&lt;span class=&quot;post-labels&quot;&gt;Labels: &lt;a href=&quot;http://ajaxaspects.blogspot.de/search/label/Ajax&quot; rel=&quot;tag&quot;&gt;Ajax&lt;/a&gt;, &lt;a href=&quot;http://ajaxaspects.blogspot.de/search/label/AJAXEngine&quot; rel=&quot;tag&quot;&gt;AJAXEngine&lt;/a&gt;, &lt;a href=&quot;http://ajaxaspects.blogspot.de/search/label/documentation&quot; rel=&quot;tag&quot;&gt;documentation&lt;/a&gt;, &lt;a href=&quot;http://ajaxaspects.blogspot.de/search/label/JavaScript&quot; rel=&quot;tag&quot;&gt;JavaScript&lt;/a&gt; &lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ajaxaspects.blogspot.com/feeds/4893960470376740393/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7581919&amp;postID=4893960470376740393' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/4893960470376740393'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/4893960470376740393'/><link rel='alternate' type='text/html' href='http://ajaxaspects.blogspot.com/2016/02/time-to-rethink-ajaxengine.html' title='Time to rethink the AjaxEngine'/><author><name>Matthias Hertel</name><uri>https://plus.google.com/116098072736241499757</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-M0Om2hGPjV8/AAAAAAAAAAI/AAAAAAAAAOs/F8uLY205io8/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7581919.post-5535573841441995316</id><published>2013-11-14T22:27:00.001+01:00</published><updated>2013-11-14T22:27:24.561+01:00</updated><title type='text'>AjaxEngine: get rid of event.srcElement</title><content type='html'>&lt;p&gt;It’s time to say goodbye to some of the compatibility tricks in the AjaxEngine. Here is the first article on maintaining your Javascript code if you come from some older versions.&lt;/p&gt; &lt;h3&gt;A note for the future&lt;/h3&gt; &lt;p&gt;If time is beyond April 2014 (the time when Windows XP and IE 8 and older dies), you don’t need to read and understand. If you find a code that reads &lt;em&gt;obj&lt;/em&gt;.srcElement, just change it to &lt;em&gt;obj&lt;/em&gt;.target.&lt;br&gt;You stumbled upon some old-browser-compatibility issue.&lt;/p&gt; &lt;h3&gt;History&lt;/h3&gt; &lt;p&gt;The srcElement property on event objects was introduced by Microsoft to find out what html element was actually meant when a event was fired. The AjaxEngine then implemented some tricky code to make this property available in other browser too:&lt;/p&gt;&lt;pre&gt;  // enable using evt.srcElement in Mozilla/Firefox
  Event.prototype.__defineGetter__(&quot;srcElement&quot;, function () {
    var node = this.target;
    while (node.nodeType != 1) node = node.parentNode;
    // test this:
    if (node != this.target) alert(&quot;Unexpected event.target!&quot;)
    return node;
  });
&lt;/pre&gt;
&lt;p&gt;Now, the W3C standard defines a target property that has the same meaning and also Microsoft moves to use the standard conform property in the newer browsers. I strongly advise to not support these older browsers any more because they never will be fixed for security issues any more.&lt;/p&gt;
&lt;p&gt;For now you should find the target object inside an event handler by using:&lt;/p&gt;&lt;pre&gt;var obj = evt.target || evt.srcElement;&lt;/pre&gt;
&lt;p&gt;and starting with April 2014 you just should use:&lt;/p&gt;&lt;pre&gt;var obj = evt.target;&lt;/pre&gt;
&lt;h3&gt;Changes to AjaxEngine&lt;/h3&gt;
&lt;p&gt;I searched all “.srcElement” occurrences and changed them to the compatible assignment&lt;/p&gt;&lt;pre&gt;var obj = evt.target || evt.srcElement;&lt;/pre&gt;&lt;pre&gt;An updated download archive is available as well as commits to the sourcecode repository:&lt;/pre&gt;&lt;pre&gt;&lt;a title=&quot;http://sourceforge.net/projects/ajaxengine/?source=navbar&quot; href=&quot;http://sourceforge.net/projects/ajaxengine/&quot;&gt;http://sourceforge.net/projects/ajaxengine/&lt;/a&gt;&lt;/pre&gt;&lt;pre&gt;or directly using subversion:&lt;/pre&gt;&lt;pre&gt;&lt;a title=&quot;https://svn.code.sf.net/p/ajaxengine/code/trunk&quot; href=&quot;https://svn.code.sf.net/p/ajaxengine/code/trunk&quot;&gt;https://svn.code.sf.net/p/ajaxengine/code/trunk&lt;/a&gt;&lt;/pre&gt;&lt;pre&gt;See also&lt;/pre&gt;
&lt;p&gt;&lt;a title=&quot;http://msdn.microsoft.com/en-us/library/ie/ff974945(v=vs.85).aspx&quot; href=&quot;http://msdn.microsoft.com/en-us/library/ie/ff974945(v=vs.85).aspx&quot;&gt;http://msdn.microsoft.com/en-us/library/ie/ff974945(v=vs.85).aspx&lt;/a&gt;&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://ajaxaspects.blogspot.com/feeds/5535573841441995316/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7581919&amp;postID=5535573841441995316' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/5535573841441995316'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/5535573841441995316'/><link rel='alternate' type='text/html' href='http://ajaxaspects.blogspot.com/2013/11/ajaxengine-get-rid-of-eventsrcelement.html' title='AjaxEngine: get rid of event.srcElement'/><author><name>Matthias Hertel</name><uri>https://plus.google.com/116098072736241499757</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-M0Om2hGPjV8/AAAAAAAAAAI/AAAAAAAAAOs/F8uLY205io8/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7581919.post-4723884146556010487</id><published>2009-12-05T20:22:00.003+01:00</published><updated>2009-12-05T20:29:48.423+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript"/><title type='text'>How to read cookie values in JavaScript</title><content type='html'>&lt;p&gt;I recently had some odd effects with some pages that use cookies to store some local information. The bug seems to be widely spread in many web applications so here are my findings:&lt;/p&gt;  &lt;p&gt;To read the value of a specific cookie that was set previously you have to analyze the string in document.cookie that contains all cookies. It’s a very readable format and looks like: &lt;/p&gt;  &lt;pre class=&quot;code&quot;&gt;a=a101; aha=aha101; bob=bob101; b=b101; c01=c0101&lt;/pre&gt;

&lt;p&gt;The trick is to find the right cookie in this string and extract the value.&lt;/p&gt;

&lt;p&gt;I used a JavaScript function, named getCookie() that searched for the position of the cookie name by using&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;start = document.cookie.indexOf(name + &amp;quot;=&amp;quot;);&lt;/pre&gt;

&lt;p&gt;… and this is wrong in some cases.&lt;/p&gt;

&lt;p&gt;If you search for the cookie named &amp;quot;b&amp;quot; in the sample above you will get a starting-position within the cookie named &amp;quot;bob&amp;quot; because the indexOf function stops at the first occurrence of the text &amp;quot;b=&amp;quot;.&lt;/p&gt;

&lt;p&gt;This seems to be a very common approach and some educational web sites still publish this kind of code that contains the mistake.&lt;/p&gt;

&lt;p&gt;&lt;a title=&quot;http://www.w3schools.com/js/js_cookies.asp&quot; href=&quot;http://www.w3schools.com/js/js_cookies.asp&quot;&gt;http://www.w3schools.com/js/js_cookies.asp&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It’s easy to fix this line by including the space character:&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;var start = document.cookie.indexOf(&amp;quot; &amp;quot; + name + &amp;quot;=&amp;quot;);
if (start &amp;gt;= 0) {
  start += 1
} else if (document.cookie.indexOf(name + &amp;quot;=&amp;quot;) == 0) {
  start = 0;
} // if&lt;/pre&gt;

&lt;p&gt;But there is a more elegant solution when using regular expressions and even the retrieval of the value gets easier that I found at&lt;/p&gt;

&lt;p&gt;&lt;a title=&quot;http://www.elated.com/articles/javascript-and-cookies/&quot; href=&quot;http://www.elated.com/articles/javascript-and-cookies/&quot;&gt;http://www.elated.com/articles/javascript-and-cookies/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is the full function:&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;function get_cookie (cookie_name)
{
  var results = document.cookie.match(&#39;(^;) ?&#39; + cookie_name + &#39;=([^;]*)(;$)&#39;);
  if (results)
    return (unescape(results[2]));
  else
    return (null);
}&lt;/pre&gt;

&lt;p&gt;Check your code.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://ajaxaspects.blogspot.com/feeds/4723884146556010487/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7581919&amp;postID=4723884146556010487' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/4723884146556010487'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/4723884146556010487'/><link rel='alternate' type='text/html' href='http://ajaxaspects.blogspot.com/2009/12/how-to-read-cookie-values-in-javascript.html' title='How to read cookie values in JavaScript'/><author><name>Matthias Hertel</name><uri>https://plus.google.com/116098072736241499757</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-M0Om2hGPjV8/AAAAAAAAAAI/AAAAAAAAAOs/F8uLY205io8/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7581919.post-4458196325537255528</id><published>2008-11-15T23:49:00.001+01:00</published><updated>2008-11-16T13:20:05.566+01:00</updated><title type='text'>Extending the initialization sequence of JavaScript behaviors</title><content type='html'>&lt;p&gt;This topic was recently discussed in the OpenAjax group and here is the implemented solution for the AjaxEngine framework. The consensus was to solve the initialization problem on the application level and not within the OpenAjax hub.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;When multiple components resist side by side on the same page the initialization sequence of the components can become critical for the page to work as expected. Therefore the JavaScript behavior mechanism supports 3 phases of initializing the application when a page loads:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;The optional &lt;strong&gt;init()&lt;/strong&gt; method is called first for every control that was initialized by LoadBehavior. This method should contain all initialization code that &lt;strong&gt;puts the control in a fully working state&lt;/strong&gt;. Especially the control should register for any interesting OpenAjax event. &lt;/li&gt;    &lt;li&gt;The optional &lt;strong&gt;initstate()&lt;/strong&gt; method is called then and allows the control to &lt;strong&gt;inform other controls &lt;/strong&gt;about their existence and &lt;strong&gt;publish state &lt;/strong&gt;information by using OpenAjax events or direct method calls if appropriate. &lt;/li&gt;    &lt;li&gt;The optional &lt;strong&gt;afterinit()&lt;/strong&gt; method is called at last to controls can finish the setup where all other controls are also working. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;All controls can participate in the initialization phases by implementing the calls. They are all optional. All 3 methods will be called when the onload event is raised for the window object.&lt;/p&gt;  &lt;h5&gt;&lt;b&gt;The term method&lt;/b&gt;&lt;/h5&gt;  &lt;p&gt;Another method named &amp;quot;&lt;strong&gt;term&lt;/strong&gt;&amp;quot; can be defined in the JavaScript prototypes to implement a method that is called just before a page unloads. There is a real need for implementing code just before all HTML and JavaScript objects are thrown away in Microsoft Internet Explorer, because there is a well known problem with the memory management used by the HTML DOM and JavaScript. Both object libraries do have their own garbage collector implementation and in some cases circular references between objects of both worlds are not properly detected and memory will not get freed and useless memory consumption is the unwanted result.&lt;/p&gt;  &lt;p&gt;The best solution against this “design weakness” is to set all references of JavaScript variables to HTML elements to null in this method.&lt;/p&gt;  &lt;p&gt;There is also a great tool and some more background information available that helps to detect this kind of memory leak named Drip available at &lt;a href=&quot;http://outofhanwell.com/&quot;&gt;http://outofhanwell.com/&lt;/a&gt; and is a definitive TO-DO when supporting older browser versions of IE.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://ajaxaspects.blogspot.com/feeds/4458196325537255528/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7581919&amp;postID=4458196325537255528' title='3 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/4458196325537255528'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/4458196325537255528'/><link rel='alternate' type='text/html' href='http://ajaxaspects.blogspot.com/2008/11/extending-initialization-sequence-of.html' title='Extending the initialization sequence of JavaScript behaviors'/><author><name>Matthias Hertel</name><uri>https://plus.google.com/116098072736241499757</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-M0Om2hGPjV8/AAAAAAAAAAI/AAAAAAAAAOs/F8uLY205io8/s512-c/photo.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7581919.post-984306672992792736</id><published>2008-07-07T23:56:00.001+02:00</published><updated>2008-07-07T23:56:58.277+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Ajax"/><category scheme="http://www.blogger.com/atom/ns#" term="AJAXEngine"/><category scheme="http://www.blogger.com/atom/ns#" term="documentation"/><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript"/><title type='text'>How to set up a web project using the AjaxEngine – Part 1b</title><content type='html'>&lt;p&gt;&lt;/p&gt;  &lt;p&gt;Some days ago I posted &lt;a href=&quot;http://ajaxaspects.blogspot.com/2008/06/how-to-setup-new-ajaxengine-web-project.html&quot;&gt;part 1a&lt;/a&gt; - a short instruction about how to set up a minimal project.&lt;/p&gt;  &lt;p&gt;The sample I used to demonstrate that the infrastructure works was as simple as possible and is using a RPC style of Ajax calls to the server. Some topics have not been touched so here they come.&lt;/p&gt;  &lt;h3&gt;How to get the files&lt;/h3&gt;  &lt;p&gt;The easiest way to get all the files I’ve talked about is to go get them directly from the repository hosted as sourceforge.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;a title=&quot;http://sourceforge.net/projects/ajaxengine/&quot; href=&quot;http://sourceforge.net/projects/ajaxengine/&quot;&gt;http://sourceforge.net/projects/ajaxengine/&lt;/a&gt; is the projects&#39;s home page and you can browse the repository directly by using the url &lt;a title=&quot;http://ajaxengine.svn.sourceforge.net/viewvc/ajaxengine/trunk/&quot; href=&quot;http://ajaxengine.svn.sourceforge.net/viewvc/ajaxengine/trunk/&quot;&gt;http://ajaxengine.svn.sourceforge.net/viewvc/ajaxengine/trunk/&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Here all the development progress will be available as soon as soon as I write about it.&lt;/p&gt;  &lt;p&gt;Another possible way to get the files is to use a subversion client for example &lt;a title=&quot;http://tortoisesvn.tigris.org/&quot; href=&quot;http://tortoisesvn.tigris.org/&quot;&gt;http://tortoisesvn.tigris.org/&lt;/a&gt; that includes more functionality like getting a copy of all the current files at once, looking into the change log and comparing different versions of the same file.&lt;/p&gt;  &lt;p&gt;From time to time the download archives are updated too. You can find them on my site at &lt;a title=&quot;http://www.mathertel.de/AJAXEngine/#view=Downloads&quot; href=&quot;http://www.mathertel.de/AjaxEngine/#view=Downloads&quot;&gt;http://www.mathertel.de/AjaxEngine/#view=Downloads&lt;/a&gt;&lt;/p&gt;  &lt;h3&gt;Calling web services the right way&lt;/h3&gt;  &lt;p&gt;I have to mention, that this is not the best way of calling a server because synchronous calls may block or freeze the client during the call and the call time may be very long when the network or the server is used a lot. Using asynchronous calls is the answer to that problem and there is simple but great mechanism inside the ajax.js file that makes asynchronous programming quiet easy. Here is just a brief explanation of how to use it. More of the mechanism and it&#39;s options can be found in the book &lt;a href=&quot;http://www.mathertel.de/Ajax/AJAXeBook.aspx&quot;&gt;Aspects of Ajax&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;The typical AJAX scenario follows the following pattern and can be split into 4 separate problems:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Waiting for an event that will start the Ajax call to the server.      &lt;br /&gt;Sometime that’s an easy thing to do, because there is a button clicked and we just can attach the initializing code to an event. But sometimes events have to be queued up to avoid a race condition and get wrong answers. &lt;/li&gt;    &lt;li&gt;Collecting some data on the client side.      &lt;br /&gt;It is often necessary to do this right before you call the server and not in the moment when the call is initiated. &lt;/li&gt;    &lt;li&gt;Communication with the server.      &lt;br /&gt;That is done by using the client stub that is generated for each SOAP based web service. &lt;/li&gt;    &lt;li&gt;Finally using the result from the server.      &lt;br /&gt;That must be done, when the data is available and is the typical asynchronous functionality of Ajax. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Many grown-up Ajax implementations are using a JavaScript object that binds the JavaScript functions that all together will solve the scenario and so does the AjaxEngine:&lt;/p&gt;  &lt;pre class=&quot;code&quot;&gt;&lt;p&gt;&lt;span style=&quot;color: #008000&quot;&gt;// declare an AJAX action&lt;/span&gt;
&lt;span style=&quot;color: #0000ff&quot;&gt;var&lt;/span&gt; action1 = {
  &lt;span style=&quot;color: #008000&quot;&gt;// the prepare function collects and returns the data for the server side method.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: #008000&quot;&gt;  // It just returns an array with the parameters and marks it with &amp;quot;multi&amp;quot;.&lt;/span&gt;
  prepare: &lt;span style=&quot;color: #0000ff&quot;&gt;function&lt;/span&gt;(obj) {
    &lt;span style=&quot;color: #0000ff&quot;&gt;var&lt;/span&gt; p = [];
    p[0] = &lt;span style=&quot;color: #0000ff&quot;&gt;document&lt;/span&gt;.getElementById(&amp;quot;&lt;span style=&quot;color: #8b0000&quot;&gt;n1&lt;/span&gt;&amp;quot;).value;
    p[1] = &lt;span style=&quot;color: #0000ff&quot;&gt;document&lt;/span&gt;.getElementById(&amp;quot;&lt;span style=&quot;color: #8b0000&quot;&gt;n2&lt;/span&gt;&amp;quot;).value;
    p.multi = &lt;span style=&quot;color: #0000ff&quot;&gt;true&lt;/span&gt;; &lt;span style=&quot;color: #008000&quot;&gt;// the hint for the ajax Engine&lt;/span&gt;
    &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; (p);
  },

  &lt;span style=&quot;color: #008000&quot;&gt;// the call element points to the proxy for the server call as usual&lt;/span&gt;
  call: proxies.CalcService.AddInteger,
  
  &lt;span style=&quot;color: #008000&quot;&gt;// the result will be written it into the appropriate html field.&lt;/span&gt;
  finish: &lt;span style=&quot;color: #0000ff&quot;&gt;function&lt;/span&gt; (p) { &lt;span style=&quot;color: #0000ff&quot;&gt;document&lt;/span&gt;.getElementById(&amp;quot;&lt;span style=&quot;color: #8b0000&quot;&gt;outputField&lt;/span&gt;&amp;quot;).value = p; }
} &lt;span style=&quot;color: #008000&quot;&gt;// action1&lt;/span&gt;&lt;/p&gt;&lt;/pre&gt;

&lt;p&gt;This action can be used to start an Ajax call by using some inline code like this:&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #800000&quot;&gt;input&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;quot;n1&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;onkeyup&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;quot;ajax.Start(action1)&amp;quot; /&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;Now Ajax starts getting robust enough in a real web application.&lt;/p&gt;

&lt;p&gt;The code is from the sample that you can find in the sample at&lt;/p&gt;

&lt;p&gt;&lt;a title=&quot;http://www.mathertel.de/AJAXEngine/S02_AJAXCoreSamples/CalcAJAX.aspx&quot; href=&quot;http://www.mathertel.de/AJAXEngine/S02_AJAXCoreSamples/CalcAJAX.aspx&quot;&gt;http://www.mathertel.de/AJAXEngine/S02_AJAXCoreSamples/CalcAJAX.aspx&lt;/a&gt;&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://ajaxaspects.blogspot.com/feeds/984306672992792736/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7581919&amp;postID=984306672992792736' title='1 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/984306672992792736'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/984306672992792736'/><link rel='alternate' type='text/html' href='http://ajaxaspects.blogspot.com/2008/07/how-to-set-up-web-project-using.html' title='How to set up a web project using the AjaxEngine – Part 1b'/><author><name>Matthias Hertel</name><uri>https://plus.google.com/116098072736241499757</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-M0Om2hGPjV8/AAAAAAAAAAI/AAAAAAAAAOs/F8uLY205io8/s512-c/photo.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7581919.post-715497410219668552</id><published>2008-07-06T00:15:00.001+02:00</published><updated>2008-07-06T00:15:19.664+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Ajax"/><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript"/><category scheme="http://www.blogger.com/atom/ns#" term="SOAP"/><category scheme="http://www.blogger.com/atom/ns#" term="WCF"/><category scheme="http://www.blogger.com/atom/ns#" term="webservice"/><title type='text'>Calling WCF and SOAP based webservices from AJAX</title><content type='html'>&lt;p&gt;The JavaScript proxy that is implemented for the Ajax engine to call SOAP based web services has been used on the ASP.NET platform for a long time and was ported to other platforms like Java. Some derived work can also be found for PHP and the Qooxdoo. It’s pretty stable for a while and that’s a good message.&lt;/p&gt;  &lt;p&gt;When working with some specific Java based platforms there was a specific problem with the automatic generated WSDL descriptions, because they use an external schema for defining the structure of the passed data:&lt;/p&gt;  &lt;pre class=&quot;code&quot;&gt;&lt;p&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #c71585&quot;&gt;wsdl&lt;/span&gt;:&lt;span style=&quot;color: #800000&quot;&gt;types&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt; 
  &lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #c71585&quot;&gt;xsd&lt;/span&gt;:&lt;span style=&quot;color: #800000&quot;&gt;schema&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;targetNamespace&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;quot;http://tempuri.org/Imports&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt; 
    &lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #c71585&quot;&gt;xsd&lt;/span&gt;:&lt;span style=&quot;color: #800000&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;schemaLocation&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&lt;a href=&quot;http://localhost/AJAXEngine/S02_AJAXCoreSamples/CalcFactors.svc?xsd=xsd0&quot;&gt;http://localhost/AJAXEngine/S02_AJAXCoreSamples/CalcFactors.svc?xsd=xsd0&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;&lt;font style=&quot;background-color: #ffff99&quot; color=&quot;#172939&quot;&gt;      &lt;/font&gt;namespace&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;quot;http://tempuri.org/&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;/&amp;gt;&lt;/span&gt; 
    ... 
  &lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #c71585&quot;&gt;xsd&lt;/span&gt;:&lt;span style=&quot;color: #800000&quot;&gt;schema&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt; 
&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #c71585&quot;&gt;wsdl&lt;/span&gt;:&lt;span style=&quot;color: #800000&quot;&gt;types&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/pre&gt;

&lt;p&gt;The workaround was to write the JSON structure that is used by the JavaScript proxy by hand (and that is still a good idea for high trafic web sites).&lt;/p&gt;

&lt;p&gt;When adopting the WCF .svc services this kind of using WSDL and XML schema definitions can be found too.&lt;/p&gt;

&lt;p&gt;A solution for this is quiet simple and can now be found in the wsdl.xslt and the GetJavaScriptProxy.aspx files.&lt;/p&gt;

&lt;h3&gt;wsdl.xslt&lt;/h3&gt;

&lt;p&gt;The WSDL to JavaScript transformation now looks for import nodes under the wsdl:types and then imports the referenced schema by using the xslt document() function. Then this imported document is searched for the right element and the parameter and return value description is generated through the soapElem template. Here is the added xslt code:&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;&lt;p&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #c71585&quot;&gt;xsl&lt;/span&gt;:&lt;span style=&quot;color: #800000&quot;&gt;when&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;test&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;quot;/wsdl:definitions/wsdl:types/s:schema/s:import&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;font style=&quot;background-color: #ffff99&quot;&gt;  &lt;/font&gt;&lt;span style=&quot;color: #008000&quot;&gt;&amp;lt;!-- importing an external schema –&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: #008000&quot;&gt;&lt;/span&gt;  &lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #c71585&quot;&gt;xsl&lt;/span&gt;:&lt;span style=&quot;color: #800000&quot;&gt;variable&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;quot;inputElementName&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;select&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;quot;substring-after(wsdl:part/@element, &#39;:&#39;)&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #c71585&quot;&gt;xsl&lt;/span&gt;:&lt;span style=&quot;color: #800000&quot;&gt;for&lt;/span&gt;-&lt;span style=&quot;color: #ff0000&quot;&gt;each&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;select&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;quot;/wsdl:definitions/wsdl:types/s:schema/s:import&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&lt;/span&gt;    &lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #c71585&quot;&gt;xsl&lt;/span&gt;:&lt;span style=&quot;color: #800000&quot;&gt;variable&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;quot;doc&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;select&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;quot;document(@schemaLocation)&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;    &lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #c71585&quot;&gt;xsl&lt;/span&gt;:&lt;span style=&quot;color: #800000&quot;&gt;for&lt;/span&gt;-&lt;span style=&quot;color: #ff0000&quot;&gt;each&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;select&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;quot;$doc/s:schema/s:element[@name=$inputElementName]//s:element&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;      &lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #c71585&quot;&gt;xsl&lt;/span&gt;:&lt;span style=&quot;color: #800000&quot;&gt;call&lt;/span&gt;-&lt;span style=&quot;color: #ff0000&quot;&gt;template&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;quot;soapElem&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;        &lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #c71585&quot;&gt;xsl&lt;/span&gt;:&lt;span style=&quot;color: #800000&quot;&gt;with&lt;/span&gt;-&lt;span style=&quot;color: #ff0000&quot;&gt;param&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;quot;name&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;select&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;quot;@name&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #c71585&quot;&gt;xsl&lt;/span&gt;:&lt;span style=&quot;color: #800000&quot;&gt;with&lt;/span&gt;-&lt;span style=&quot;color: #ff0000&quot;&gt;param&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;quot;type&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;select&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;quot;@type&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&lt;/span&gt;      &lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #c71585&quot;&gt;xsl&lt;/span&gt;:&lt;span style=&quot;color: #800000&quot;&gt;call&lt;/span&gt;-template&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&lt;/span&gt;      &lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #c71585&quot;&gt;xsl&lt;/span&gt;:&lt;span style=&quot;color: #800000&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;test&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;quot;position()!=last()&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt;,&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #c71585&quot;&gt;xsl&lt;/span&gt;:&lt;span style=&quot;color: #800000&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;    &lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #c71585&quot;&gt;xsl&lt;/span&gt;:&lt;span style=&quot;color: #800000&quot;&gt;for&lt;/span&gt;-each&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;  &amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #c71585&quot;&gt;xsl&lt;/span&gt;:&lt;span style=&quot;color: #800000&quot;&gt;for&lt;/span&gt;-each&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #c71585&quot;&gt;xsl&lt;/span&gt;:&lt;span style=&quot;color: #800000&quot;&gt;when&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/pre&gt;

&lt;h3&gt;GetJavaScriptProxy&lt;/h3&gt;

&lt;p&gt;In the .NET environment the document function will not work for security reasons without some special instructions for the xslt transform. When passing a&amp;#160; XmlUrlResolver when loading the xslt file the document() function can retrieve the referenced external document.&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;XmlUrlResolver resolver = &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; XmlUrlResolver();
resolver.Credentials = CredentialCache.DefaultCredentials;

XslCompiledTransform xsl = &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; XslCompiledTransform();
xsl.Load(Server.MapPath(&amp;quot;&lt;span style=&quot;color: #8b0000&quot;&gt;~/ajaxcore/wsdl.xslt&lt;/span&gt;&amp;quot;), XsltSettings.TrustedXslt, resolver);&lt;/pre&gt;

&lt;h3&gt;Implementing a WCF service for Ajax&lt;/h3&gt;

&lt;p&gt;Implementing a WCF service for Ajax is almost as simple as programming an *.asmx based service but you can also use an external C# class or interface for implementing the service.&lt;/p&gt;

&lt;p&gt;You can find a sample source code in: &lt;/p&gt;

&lt;p&gt;&lt;a title=&quot;http://www.mathertel.de/AJAXEngine/S02_AJAXCoreSamples/CalcFactors.svc&quot; href=&quot;http://www.mathertel.de/AJAXEngine/ViewSrc.aspx?file=S02_AJAXCoreSamples/CalcFactors.svc&quot;&gt;http://www.mathertel.de/AJAXEngine/S02_AJAXCoreSamples/CalcFactors.svc&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;The configuration&lt;/h3&gt;

&lt;p&gt;By default the WCF services use the SOAP 1.2 format but we don’t need the ws-* functionality and the soap basic profile is perfect for using webservice with AJAX solutions. This can be done by using the following configuration in web.config:&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #800000&quot;&gt;system.serviceModel&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #800000&quot;&gt;behaviors&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #800000&quot;&gt;serviceBehaviors&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #800000&quot;&gt;behavior&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;quot;AjaxBehavior&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #800000&quot;&gt;serviceMetadata&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;httpGetEnabled&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;quot;true&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;/&amp;gt;&lt;/span&gt;
        &lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #800000&quot;&gt;serviceDebug&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;includeExceptionDetailInFaults&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;quot;false&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;/&amp;gt;&lt;/span&gt;
      &lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #800000&quot;&gt;behavior&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #800000&quot;&gt;serviceBehaviors&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #800000&quot;&gt;behaviors&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt;

  &lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #800000&quot;&gt;services&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #800000&quot;&gt;service&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;behaviorConfiguration&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;quot;AjaxBehavior&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;quot;CalcFactors&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #800000&quot;&gt;endpoint&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;address&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;binding&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;quot;basicHttpBinding&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;contract&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;quot;CalcFactors&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #800000&quot;&gt;service&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #800000&quot;&gt;services&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #800000&quot;&gt;system.serviceModel&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;  </content><link rel='replies' type='application/atom+xml' href='http://ajaxaspects.blogspot.com/feeds/715497410219668552/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7581919&amp;postID=715497410219668552' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/715497410219668552'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/715497410219668552'/><link rel='alternate' type='text/html' href='http://ajaxaspects.blogspot.com/2008/07/calling-wcf-and-soap-based-webservices.html' title='Calling WCF and SOAP based webservices from AJAX'/><author><name>Matthias Hertel</name><uri>https://plus.google.com/116098072736241499757</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-M0Om2hGPjV8/AAAAAAAAAAI/AAAAAAAAAOs/F8uLY205io8/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7581919.post-2856798328569023452</id><published>2008-06-22T20:47:00.001+02:00</published><updated>2008-06-22T20:48:59.845+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="AJAXEngine"/><title type='text'>How to setup a new AjaxEngine web project</title><content type='html'>&lt;p&gt;I was asked how to setup a web project that uses the AjaxEngine so here is step by step tutorial for a minimal Ajax web project that calls a server side web service: &lt;/p&gt;  &lt;h3&gt;1. Create a new web project (I prefer using c#) or use your existing web project.&lt;/h3&gt;  &lt;p&gt;I started with a new project and named it &amp;quot;mini&amp;quot;. There is nothing special that you have to set up. It even works without a web.config.&lt;/p&gt;  &lt;h3&gt;2. Copy the ajaxcore folder to your project.&lt;/h3&gt;  &lt;p&gt;You can find this folder and the files on sourceforge &lt;a href=&quot;http://sourceforge.net/projects/ajaxengine/&quot; target=&quot;_blank&quot;&gt;http://sourceforge.net/projects/ajaxengine/&lt;/a&gt;     &lt;br /&gt;in the subversion repository by using the path &lt;a href=&quot;https://ajaxengine.svn.sourceforge.net/svnroot/ajaxengine&quot; target=&quot;_blank&quot;&gt;https://ajaxengine.svn.sourceforge.net/svnroot/ajaxengine&lt;/a&gt;     &lt;br /&gt;or in one of the source code downloads like &lt;a href=&quot;http://www.mathertel.de/Downloads/Start_AJAX_new.aspx&quot; target=&quot;_blank&quot;&gt;http://www.mathertel.de/Downloads/Start_AJAX_new.aspx&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt;For this project you only need the following core files    &lt;br /&gt;&lt;a href=&quot;http://www.mathertel.de/AJAXEngine/ViewSrc.aspx?file=ajaxcore/ajax.js&quot; target=&quot;_blank&quot;&gt;ajax.js&lt;/a&gt;: the client side AjaxEngine&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://www.mathertel.de/AJAXEngine/ViewSrc.aspx?file=ajaxcore/GetJavaScriptProxy.aspx&quot; target=&quot;_blank&quot;&gt;GetJavaScriptProxy.aspx&lt;/a&gt;: the JavaScript proxy generator     &lt;br /&gt;&lt;a href=&quot;http://www.mathertel.de/AJAXEngine/ViewSrc.aspx?file=ajaxcore/wsdl.xslt&quot; target=&quot;_blank&quot;&gt;wsdl.xslt&lt;/a&gt;: the WSDL to JavaScript transformation&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;That’s all you have to do to prepare the web project to use the core part of the AjaxEngine. I suggest you use the ajaxcore folder &lt;/p&gt;  &lt;h3&gt;3. Create a folder named &amp;quot;/calc&amp;quot; &lt;/h3&gt;  &lt;p&gt;This folder will contain the minimal web application by using a web form and a web service. &lt;/p&gt;  &lt;p&gt;I guess you don&#39;t implement pages in the root folder of your web application so I follow this best practice here too. &lt;/p&gt;  &lt;h3&gt;4. Implement a service /calc/WebService1.asmx &lt;/h3&gt;  &lt;p&gt;There is only one method we need so here is some c# code: &lt;/p&gt;  &lt;pre class=&quot;code&quot;&gt;using System.ComponentModel;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;

namespace mini.calc {
  /// &lt;summary&gt;
  /// Summary description for WebService1
  /// &lt;/summary&gt;
  [WebService(Namespace = &amp;quot;http://tempuri.org/&amp;quot;)]
  [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
  // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
  // [System.Web.Script.Services.ScriptService]
  public class WebService1 : System.Web.Services.WebService {

    [WebMethod]
    public double Add(double sum1, double sum2) {
      return (sum1 + sum2);
    }
  }
}&lt;/pre&gt;

&lt;h3&gt;5. Create a new page named WebForm1.aspx in the calc folder&lt;/h3&gt;

&lt;p&gt;I just use the new item wizard from visual Studio to do this so the typical elements are there already. 
  &lt;br /&gt;There is not much code that must be put into this file. &lt;/p&gt;

&lt;h3&gt;6. include the ajax.js: &lt;/h3&gt;

&lt;pre class=&quot;code&quot;&gt;&amp;lt;script src=&amp;quot;&lt;span style=&quot;color: #8b0000&quot;&gt;../ajaxcore/ajax.js&lt;/span&gt;&amp;quot; type=&amp;quot;&lt;span style=&quot;color: #8b0000&quot;&gt;text/javascript&lt;/span&gt;&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;/pre&gt;

&lt;p&gt;The ajax.js file reference should be included in the &amp;lt;head&amp;gt; element.&lt;/p&gt;

&lt;h3&gt;7. include the proxy for the webservice: &lt;/h3&gt;

&lt;pre class=&quot;code&quot;&gt;&amp;lt;script src=&amp;quot;&lt;span style=&quot;color: #8b0000&quot;&gt;../ajaxcore/GetJavaScriptProxy.aspx?service=/calc/WebService1.asmx&lt;/span&gt;&amp;quot; type=&amp;quot;&lt;span style=&quot;color: #8b0000&quot;&gt;text/javascript&lt;/span&gt;&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;/pre&gt;

&lt;p&gt;This script include should also be included in the &amp;lt;head&amp;gt; element and will make the just implemented webservice and webmethod available through the JavaScript object &lt;em&gt;proxies.WebService1.Add&lt;/em&gt;. &lt;/p&gt;

&lt;h3&gt;8. Implement the User interface&lt;/h3&gt;

&lt;p&gt;A minimalist UI means just 3 fields and some text. 
  &lt;br /&gt;You also have to remove the &amp;lt;form&amp;gt; element because the fields are not used to post data to the server.&amp;#160; &lt;br /&gt;&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #800000&quot;&gt;input&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;quot;sum1&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;type&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;quot;text&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;/&amp;gt;&lt;/span&gt; + &lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #800000&quot;&gt;input&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;quot;sum2&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;type&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;quot;text&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;/&amp;gt;&lt;/span&gt; = &lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #800000&quot;&gt;input&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;quot;result&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;type&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;quot;text&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;h3&gt;9. Implement the JavaScript code &lt;/h3&gt;

&lt;p&gt;This is the trickiest part of it, but it&#39;s simple too: 
  &lt;br /&gt;A timer is used to call a function every 200 milliseconds that checks for some changed input values. 

  &lt;br /&gt;The web service is called if any value has changed. &lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;&amp;lt;script type=&amp;quot;&lt;span style=&quot;color: #8b0000&quot;&gt;text/javascript&lt;/span&gt;&amp;quot;&amp;gt;
  &lt;span style=&quot;color: #0000ff&quot;&gt;var&lt;/span&gt; sum1_obj = &lt;span style=&quot;color: #0000ff&quot;&gt;document&lt;/span&gt;.getElementById(&amp;quot;&lt;span style=&quot;color: #8b0000&quot;&gt;sum1&lt;/span&gt;&amp;quot;);
  &lt;span style=&quot;color: #0000ff&quot;&gt;var&lt;/span&gt; sum2_obj = &lt;span style=&quot;color: #0000ff&quot;&gt;document&lt;/span&gt;.getElementById(&amp;quot;&lt;span style=&quot;color: #8b0000&quot;&gt;sum2&lt;/span&gt;&amp;quot;);
  &lt;span style=&quot;color: #0000ff&quot;&gt;var&lt;/span&gt; result_obj = &lt;span style=&quot;color: #0000ff&quot;&gt;document&lt;/span&gt;.getElementById(&amp;quot;&lt;span style=&quot;color: #8b0000&quot;&gt;result&lt;/span&gt;&amp;quot;);
  &lt;span style=&quot;color: #0000ff&quot;&gt;var&lt;/span&gt; sum1_val = &amp;quot;&lt;span style=&quot;color: #8b0000&quot;&gt;&lt;/span&gt;&amp;quot;;
  &lt;span style=&quot;color: #0000ff&quot;&gt;var&lt;/span&gt; sum2_val = &amp;quot;&lt;span style=&quot;color: #8b0000&quot;&gt;&lt;/span&gt;&amp;quot;;

  &lt;span style=&quot;color: #0000ff&quot;&gt;window&lt;/span&gt;.&lt;span style=&quot;color: #0000ff&quot;&gt;setInterval&lt;/span&gt;(&lt;span style=&quot;color: #0000ff&quot;&gt;window&lt;/span&gt;.checkValues, 200);
  
  &lt;span style=&quot;color: #0000ff&quot;&gt;function&lt;/span&gt; checkValues() {
    &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; ((sum1_obj.value != sum1_val) || (sum2_obj.value != sum2_val)) {
      sum1_val = sum1_obj.value;
      sum2_val = sum2_obj.value;
      
      result_obj.value = proxies.WebService1.Add(sum1_val, sum2_val);
    } &lt;span style=&quot;color: #008000&quot;&gt;// if&lt;/span&gt;
  } &lt;span style=&quot;color: #008000&quot;&gt;// checkValues&lt;/span&gt;
&amp;lt;/script&amp;gt;&lt;/pre&gt;

&lt;h3&gt;10. And that&#39;s all&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;http://www.mathertel.de/AJAX/images/miniproject01.png&quot; /&gt; &lt;/p&gt;

&lt;p&gt;Start the Web Form and see how it works. &lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://ajaxaspects.blogspot.com/feeds/2856798328569023452/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7581919&amp;postID=2856798328569023452' title='2 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/2856798328569023452'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/2856798328569023452'/><link rel='alternate' type='text/html' href='http://ajaxaspects.blogspot.com/2008/06/how-to-setup-new-ajaxengine-web-project.html' title='How to setup a new AjaxEngine web project'/><author><name>Matthias Hertel</name><uri>https://plus.google.com/116098072736241499757</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-M0Om2hGPjV8/AAAAAAAAAAI/AAAAAAAAAOs/F8uLY205io8/s512-c/photo.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7581919.post-2087170301623734719</id><published>2008-04-02T22:11:00.001+02:00</published><updated>2008-04-02T22:11:58.414+02:00</updated><title type='text'>OpenAjax Call-to-Action to Ajax Developers for Browser Wishlist</title><content type='html'>&lt;p&gt;The &lt;a href=&quot;http://www.openajax.org/&quot;&gt;OpenAjax Alliance&lt;/a&gt; is developing an Ajax industry wishlist for future browsers, using a &lt;a href=&quot;http://www.openajax.org/runtime/wiki&quot;&gt;dedicated wiki&lt;/a&gt; for this initiative (&lt;a href=&quot;http://www.openajax.org/runtime/wiki&quot;&gt;http://www.openajax.org/runtime/wiki&lt;/a&gt;). The main purpose of the initiative is to inform the browser vendors about what future features are most important to the Ajax community and why. So far, the alliance has interviewed roughly a dozen industry leaders, including representatives from the ASP.NET AJAX, Dojo, Ext JS, Douglas Crockford of JSON fame, jQuery, Spry, and XAP, and recently held a townhall discussion on the feature request list among its members. The members have concluded that the wishlist (~25 items) is ready for public comments. &lt;p&gt;The alliance is now issuing a call-to-action to Ajax developers to participate in this initiative, which is open to both OpenAjax Alliance members and to non-members. The alliance especially would like participation from Ajax toolkit developers and leading web developers with expertise in using open browser technologies to achieve rich user experiences. To join the effort, create a wiki login for yourself by following the instructions on the &lt;a href=&quot;http://www.openajax.org/runtime/wiki&quot;&gt;wiki home page (http://www.openajax.org/runtime/wiki)&lt;/a&gt;. After you have a login, you can then add new feature requests or comment on existing feature requests as you see fit. The initiative operates on an honor-system basis. &lt;p&gt;The moderators have attempted to make it possible that the community can add comments and vote on particular feature requests without large time commitments. For example, it is possible to simply vote for your favorite feature requests by adding a single row to a wiki table. The alliance’s wiki uses the same markup language as wikipedia. &lt;p&gt;Here is the timeline: &lt;ul&gt; &lt;ul&gt; &lt;li&gt;April - &lt;b&gt;Phase I review&lt;/b&gt;, where participants not only add comments, but also are asked to identify their &lt;b&gt;Top 5 features&lt;/b&gt; (i.e., those features that are most critical for inclusion in next-generation browsers). &lt;li&gt;May - The moderators reorganize and possibly trim away feature requests for which little interest was shown. &lt;li&gt;June - &lt;b&gt;Phase II review&lt;/b&gt;, where participants will be asked to provide &lt;b&gt;importance ratings&lt;/b&gt; for each of the feature requests &lt;b&gt;on a scale of 0.0 to 5.0&lt;/b&gt;. &lt;li&gt;July - The moderators will produce a summary report and notify the major browser vendors about the results.&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt; &lt;p&gt;The process is completely open and Wiki-based, so feel free to contribute^.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://ajaxaspects.blogspot.com/feeds/2087170301623734719/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7581919&amp;postID=2087170301623734719' title='2 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/2087170301623734719'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/2087170301623734719'/><link rel='alternate' type='text/html' href='http://ajaxaspects.blogspot.com/2008/04/openajax-call-to-action-to-ajax.html' title='OpenAjax Call-to-Action to Ajax Developers for Browser Wishlist'/><author><name>Matthias Hertel</name><uri>https://plus.google.com/116098072736241499757</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-M0Om2hGPjV8/AAAAAAAAAAI/AAAAAAAAAOs/F8uLY205io8/s512-c/photo.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7581919.post-4509249773444100924</id><published>2008-01-26T20:57:00.001+01:00</published><updated>2008-01-26T20:57:37.611+01:00</updated><title type='text'>Data bound fields for Ajax forms</title><content type='html'>&lt;p&gt;An overview of the Ajax forms implementation of the AjaxEngine framework has already been published some days ago at &lt;a title=&quot;http://ajaxaspects.blogspot.com/2007/12/using-openajax-events-for-building-data.html&quot; href=&quot;http://ajaxaspects.blogspot.com/2007/12/using-openajax-events-for-building-data.html&quot;&gt;http://ajaxaspects.blogspot.com/2007/12/using-openajax-events-for-building-data.html&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Here are more details of the concept around binding html elements to Open Ajax events.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h2&gt;Client side API for data bound elements&lt;/h2&gt; &lt;p&gt;The API for the data controls is unified as far as possible and for all the data controls the following common features are implemented:&lt;/p&gt; &lt;p&gt;&lt;strong&gt;element.eventname&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;If this attribute is set the the element will listen to and possibly publish an OpenAjax hub event to exchange the changed value through the eventing mechanism. If the value of the eventname attribute does not contain a full namespace but only the local name of the event, the eventnamespace attribute of any parent element is used to complete the namespace. This may be in many cases the surrounding DataFormBehavior element.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;strong&gt;element&lt;/strong&gt;.datatype&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;This attribute can be set to the name of the datatype of the values. This enables some datatype specific behavior implementation within the element for example converting the non-string datatypes to the specific notation. If this attribute is not set then the exchanged data will is used without any special formatting conversions and no other restrictions are applied. Just like a string type.&lt;/p&gt; &lt;p&gt;This attribute should not be changed by JavaScript. Use the setDatatype(type) method in the case you need that.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;strong&gt;element&lt;/strong&gt;.setData(newValue)&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;This method is available to set the value of the control directly by using JavaScript. This method is also used internally for all cases when the value of the control has to change. This method can be overwritten by other, derived controls.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;strong&gt;element&lt;/strong&gt;.getData()&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;This method is available to JavaScript implementations that need to access the value of a (input) field directly. Don&#39;t use the innerText or value attributes of an HTML element directly because there may be type conversion and/or translations necessary that are executed for your convenience when using this method.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;strong&gt;element&lt;/strong&gt;.setDatatype(newType)&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;When the datatype of an data item is not known when loading the page and by using the datatype attribute this method can be to pass the new datatype.&lt;/p&gt; &lt;p&gt;All the values that are exchanged between the Ajax form element and the inner data controls are using the format defined by the XML datatypes (here simply called the standard format) . This implies that the inner data controls have to take care about converting the values into some more useful formats and that the Ajax form and more important the server doesn&#39;t have to care about these specific formats.&lt;/p&gt; &lt;p&gt;There is also another way how values can be exchanged among different controls that is the OpenAjax event mechanism. Every time the Ajax form gets a new dataset is also published all the values by using the eventnamespace of the Ajax form. OpenAjax events are also used to sync the inner data controls that all deal with the same data item.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;name attribute&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;This attribute of an inner element is &lt;strong&gt;not &lt;/strong&gt;used. Using this attribute is heavily used by the classic HTML form mechanism. This still allows &quot;hybrid&quot; web pages where the user gets some advice and aid by using AJAX calls to the server but where the form.submit functionality is still used for the real processing of the data of the form.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h2&gt;Data bound elements and behaviors&lt;/h2&gt; &lt;h3&gt;DataOutput Controls&lt;/h3&gt; &lt;p&gt;If you have data items that come from the server an that will not be changed by the user you can use the DataOutput control. The DataOutput Behavior only registers for the appropriate event that is specified through the eventname attribute and displays all published values inside the control.&lt;/p&gt; &lt;p&gt;The implementation uses a &amp;lt;span&amp;gt; element for displaying the values but other Controls that derive from DataOutput can also use different element eventually by overwriting the setData method. The setData method can also be used to display values when implementing directly with JavaScript.&lt;/p&gt; &lt;p&gt;It also takes care of the datatype attribute. If this attribute is set the given value in the standard format will then be converted into the national language specific notation within the setData method by using the &lt;strong&gt;nls&lt;/strong&gt; object that will be described later.&lt;/p&gt; &lt;p&gt;The reference documentation can be found at&lt;/p&gt; &lt;p&gt;&lt;a title=&quot;http://localhost:50959/AJAXEngine/documentation/ViewDoc.aspx?file=~/controls/DataFade.js&quot; href=&quot;http://www.mathertel.de/AJAXEngine/documentation/ViewDoc.aspx?file=~/controls/DataOutput.js&quot;&gt;http://www.mathertel.de/AJAXEngine/documentation/ViewDoc.aspx?file=~/controls/DataOutput.js&lt;/a&gt;&lt;/p&gt; &lt;h3&gt;DataInput Controls&lt;/h3&gt; &lt;p&gt;The DataInput component is a general purpose JavaScript Behavior based control that implements the functionality for binding a regular &amp;lt;input&amp;gt; element to OpenAjax events for building Ajax forms.&lt;/p&gt; &lt;p&gt;The implementation takes also care of the datatype in a special way by using the implementation of datatype specific functionality that are available through the &lt;strong&gt;nls&lt;/strong&gt; object that will be described in a later article in detail.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;When a key is pressed the keyCode / charCode of the pressed key is identified and only valid characters are passed. This allows to keep unwanted characters away from the field value in many cases. However it is possible to paste any character by using the clipboard so do not trust this tiny filter. It&#39;s only implemented to assist - not to prevent.  &lt;li&gt;If a datatype is given, the XML values will be converted into the national language specific notation within the setData method or when an OpenAjax event with the appropriate eventname was published.  &lt;li&gt;If a datatype is given, the national language specific notation of the input value will be converted back into the the XML value that is used on the server site within the getData method.  &lt;li&gt;It the data is changed and the cursor leaves the field or the &amp;lt;enter&amp;gt; key is pressed, an OpenAjax event will be published using the standard format.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;You can build more specific components based on this JavaScript Behavior by deriving from this implementation and adding some special features.&lt;/p&gt; &lt;p&gt;The reference documentation can be found at&lt;/p&gt; &lt;p&gt;&lt;a title=&quot;http://localhost:50959/AJAXEngine/documentation/ViewDoc.aspx?file=~/controls/DataFade.js&quot; href=&quot;http://www.mathertel.de/AJAXEngine/documentation/ViewDoc.aspx?file=~/controls/DataInput.js&quot;&gt;http://www.mathertel.de/AJAXEngine/documentation/ViewDoc.aspx?file=~/controls/DataInput.js&lt;/a&gt;&lt;/p&gt; &lt;h3&gt;The DataFade control&lt;/h3&gt; &lt;p&gt;The DataFade Behavior implementation inherits from the DataOutput implementation and adds the Fade effect. Every time a new value is set into this element the background becomes yellow and is then smoothly fading to the original background color to attract the users attention.&lt;/p&gt; &lt;p&gt;A sample page for this effect can be found at&lt;/p&gt; &lt;p&gt;&lt;a href=&quot;http://www.mathertel.de/AJAXEngine/S04_VisualEffects/FadeDemo.aspx&quot;&gt;http://www.mathertel.de/AJAXEngine/S04_VisualEffects/FadeDemo.aspx&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;The reference documentation can be found at&lt;/p&gt; &lt;p&gt;&lt;a title=&quot;http://localhost:50959/AJAXEngine/documentation/ViewDoc.aspx?file=~/controls/DataFade.js&quot; href=&quot;http://www.mathertel.de/AJAXEngine/documentation/ViewDoc.aspx?file=~/controls/DataFade.js&quot;&gt;http://www.mathertel.de/AJAXEngine/documentation/ViewDoc.aspx?file=~/controls/DataFade.js&lt;/a&gt;&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://ajaxaspects.blogspot.com/feeds/4509249773444100924/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7581919&amp;postID=4509249773444100924' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/4509249773444100924'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/4509249773444100924'/><link rel='alternate' type='text/html' href='http://ajaxaspects.blogspot.com/2008/01/data-bound-fields-for-ajax-forms.html' title='Data bound fields for Ajax forms'/><author><name>Matthias Hertel</name><uri>https://plus.google.com/116098072736241499757</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-M0Om2hGPjV8/AAAAAAAAAAI/AAAAAAAAAOs/F8uLY205io8/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7581919.post-1021056879897739360</id><published>2008-01-06T22:18:00.001+01:00</published><updated>2008-01-06T22:18:16.951+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Ajax"/><category scheme="http://www.blogger.com/atom/ns#" term="Behaviors"/><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript"/><category scheme="http://www.blogger.com/atom/ns#" term="OpenAjax"/><title type='text'>Building menus with OpenAjax events</title><content type='html'>&lt;p&gt;Implementing menus is often based on publishing events. I personally cannot remember any system that does not.&lt;/p&gt; &lt;p&gt;&lt;img src=&quot;http://www.mathertel.de/Ajax/images/menubarsample.png&quot;&gt;  &lt;p&gt;The web control that is used to implement menubars is therefore a good sample for a html, css and JavaScript based component that is extendable and completely relies on a &lt;b&gt;declarative approach&lt;/b&gt; (also a widely used pattern menu system).  &lt;h5&gt;&lt;a name=&quot;_Toc187384790&quot;&gt;&lt;b&gt;HTML&lt;/b&gt;&lt;/a&gt;&lt;/h5&gt; &lt;p&gt;The html code for building a menubar is implemented by using an outer &amp;lt;div&amp;gt; element and on level of inner elements that can implement image-buttons, text-buttons and separators by using &amp;lt;span&amp;gt; and &amp;lt;img&amp;gt; html elements.  &lt;p&gt;The look and feel of all the elements is defined by using CSS rules based on class names.  &lt;p&gt;The class name &quot;VEMenuBar&quot; is used for the outermost element. Buttons are marked by using “VEMenu” and the separators are marked with the class name “VEMenuSeparator”.  &lt;p&gt;Here is a small sample:&amp;nbsp;&amp;nbsp; &lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #800000&quot;&gt;div&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;class&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&quot;VEMenuBar&quot;&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;eventnamespace&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&quot;de.mathertel.datasource&quot;&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt; 
  &lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #800000&quot;&gt;span&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;class&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&quot;VEMenu&quot;&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;eventname&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&quot;search&quot;&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt;Search&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #800000&quot;&gt;span&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt; 
  &lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #800000&quot;&gt;img&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;class&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&quot;VEMenuSeparator&quot;&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;alt&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&quot;&quot;&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;src&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&quot;../controls/images/white.gif&quot;&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;/&amp;gt;&lt;/span&gt; 
  &lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #800000&quot;&gt;img&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;class&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&quot;VEMenu&quot;&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;alt&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&quot;show first record&quot;&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;eventname&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&quot;first&quot;&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;src&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&quot;../controls/images/first.gif&quot;&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;/&amp;gt;&lt;/span&gt; 
&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #800000&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;h5&gt;&lt;a name=&quot;_Toc187384791&quot;&gt;&lt;/a&gt;&lt;b&gt;CSS&lt;/b&gt;&lt;/h5&gt;
&lt;p&gt;Based on the class names the design can be specified. Some of the class names are modified when the hover effect is enabled on the page. &lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;.&lt;span style=&quot;color: #800000&quot;&gt;VEMenuBar&lt;/span&gt; { &lt;span style=&quot;color: #ff0000&quot;&gt;background-color&lt;/span&gt;:&lt;span style=&quot;color: #0000ff&quot;&gt;#eeeeee&lt;/span&gt;;&lt;span style=&quot;color: #ff0000&quot;&gt;padding&lt;/span&gt;:&lt;span style=&quot;color: #0000ff&quot;&gt;2px 8px 2px 8px&lt;/span&gt;;&lt;span style=&quot;color: #ff0000&quot;&gt;height&lt;/span&gt;:&lt;span style=&quot;color: #0000ff&quot;&gt;20px&lt;/span&gt;;&lt;span style=&quot;color: #ff0000&quot;&gt;overflow&lt;/span&gt;:&lt;span style=&quot;color: #0000ff&quot;&gt;hidden&lt;/span&gt;;}&lt;/pre&gt;
&lt;p&gt;This defines the background color of the menubar. The padding definition will keep the inner icons away from the border. &lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;.&lt;span style=&quot;color: #800000&quot;&gt;VEMenuBar&lt;/span&gt; * { &lt;span style=&quot;color: #ff0000&quot;&gt;vertical-align&lt;/span&gt;:&lt;span style=&quot;color: #0000ff&quot;&gt;top&lt;/span&gt;;}&lt;/pre&gt;
&lt;p&gt;All elements will be vertically aligned by the top. &lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;.&lt;span style=&quot;color: #800000&quot;&gt;VEMenuBar&lt;/span&gt; &lt;span style=&quot;color: #800000&quot;&gt;span&lt;/span&gt; {&lt;span style=&quot;color: #ff0000&quot;&gt;display&lt;/span&gt;:&lt;span style=&quot;color: #0000ff&quot;&gt;-moz-inline-box&lt;/span&gt;;&lt;span style=&quot;color: #ff0000&quot;&gt;display&lt;/span&gt;:&lt;span style=&quot;color: #0000ff&quot;&gt;inline-block&lt;/span&gt;;}&lt;/pre&gt;
&lt;p&gt;&amp;lt;span&amp;gt; elements inside the menubar can be used to create buttons with a text caption. This rule is used to position span elements by using the padding.&lt;br&gt;The IE will use the inline-block rule and Mozilla/Firefox will use the -moz-inline-box rule. They both don&#39;t understand the other syntax and will just ignore it. &lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;.&lt;span style=&quot;color: #800000&quot;&gt;VEMenu&lt;/span&gt; { &lt;span style=&quot;color: #ff0000&quot;&gt;border&lt;/span&gt;:&lt;span style=&quot;color: #0000ff&quot;&gt;0px&lt;/span&gt;;&lt;span style=&quot;color: #ff0000&quot;&gt;padding&lt;/span&gt;:2px}&lt;/pre&gt;
&lt;p&gt;This rule is used for the state of an icon that is not hovered or pushed. In my layout it has no border and is padding the graphic by using 2 pixels on every side. &lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;.&lt;span style=&quot;color: #800000&quot;&gt;VEMenuHover&lt;/span&gt; { &lt;span style=&quot;color: #ff0000&quot;&gt;border-style&lt;/span&gt;:&lt;span style=&quot;color: #0000ff&quot;&gt;solid&lt;/span&gt;;&lt;span style=&quot;color: #ff0000&quot;&gt;border-width&lt;/span&gt;:&lt;span style=&quot;color: #0000ff&quot;&gt;1px&lt;/span&gt;;&lt;span style=&quot;color: #ff0000&quot;&gt;border-color&lt;/span&gt;: &lt;span style=&quot;color: #0000ff&quot;&gt;#acc1e4 #203050 #203050 #acc1e4&lt;/span&gt;;&lt;span style=&quot;color: #ff0000&quot;&gt;padding&lt;/span&gt;:1px}&lt;/pre&gt;
&lt;p&gt;This is the state of an icon when the mouse is over it but is not pushed. In my layout I use 1 pixel of border on every side with some colors that makes the icon look like being raised a little bit. I reduce the padding to 1px to avoid the shifting and flickering of the graphic. &lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;.&lt;span style=&quot;color: #800000&quot;&gt;VEMenuPushed&lt;/span&gt; { &lt;span style=&quot;color: #ff0000&quot;&gt;border-style&lt;/span&gt;:&lt;span style=&quot;color: #0000ff&quot;&gt;solid&lt;/span&gt;;&lt;span style=&quot;color: #ff0000&quot;&gt;border-width&lt;/span&gt;:&lt;span style=&quot;color: #0000ff&quot;&gt;1px&lt;/span&gt;;&lt;span style=&quot;color: #ff0000&quot;&gt;border-color&lt;/span&gt;: &lt;span style=&quot;color: #0000ff&quot;&gt;#203050 #acc1e4 #acc1e4 #203050&lt;/span&gt;;&lt;span style=&quot;color: #ff0000&quot;&gt;padding&lt;/span&gt;:1px}&lt;/pre&gt;
&lt;p&gt;This is the state of a icon when the icon is pushed down. In my layout I use 1 pixel of border on every side but with different colors and I reduce the padding to 1 px to avoid the shifting and flickering of the graphic. &lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;.&lt;span style=&quot;color: #800000&quot;&gt;VEMenuSeparator&lt;/span&gt; { &lt;span style=&quot;color: #ff0000&quot;&gt;display&lt;/span&gt;:&lt;span style=&quot;color: #0000ff&quot;&gt;inline-block&lt;/span&gt;;&lt;span style=&quot;color: #ff0000&quot;&gt;height&lt;/span&gt;:&lt;span style=&quot;color: #0000ff&quot;&gt;20px&lt;/span&gt;;&lt;span style=&quot;color: #ff0000&quot;&gt;width&lt;/span&gt;:&lt;span style=&quot;color: #0000ff&quot;&gt;1px&lt;/span&gt;;&lt;span style=&quot;color: #ff0000&quot;&gt;border-left&lt;/span&gt;:&lt;span style=&quot;color: #0000ff&quot;&gt;solid 1px #203050&lt;/span&gt;;}&lt;/pre&gt;
&lt;p&gt;Separators between groups of symbols are included by using a 1x1 white pixel image with a classname &quot;VEMenuSeparator&quot; that is displayed with a darker border on the left side. 
&lt;h5&gt;&lt;a name=&quot;_Toc187384792&quot;&gt;&lt;b&gt;Declaring and publishing events&lt;/b&gt;&lt;/a&gt;&lt;/h5&gt;
&lt;p&gt;Event publishing is the duty of this component. All that we need to declare is what event will be published by a inner element and that is done by using attributes of these elements. 
&lt;p&gt;&lt;b&gt;eventname&lt;/b&gt; 
&lt;p&gt;This attribute that is valid on any nested element of the menubar’s outermost &amp;lt;div&amp;gt; element contains the event name that will be published when the element is clicked. This attribute may contain only a local event name or a full qualified eventname including the namespace. 
&lt;p&gt;&lt;b&gt;eventnamespace&lt;/b&gt; 
&lt;p&gt;This attribute that on the menubar’s outermost &amp;lt;div&amp;gt; element and specifies a namespace that is used for any eventnames that are not fully qualified. 
&lt;p&gt;(Fully qualified eventnames are determined by the fact that they contain a dot character.) 
&lt;h5&gt;&lt;a name=&quot;_Toc187384793&quot;&gt;&lt;b&gt;The menubar behavior (MenubarBehavior)&lt;/b&gt;&lt;/a&gt;&lt;/h5&gt;
&lt;p&gt;This behavior implements all the basic functionality for menubars. When bound to a html element it also loops through all the children elements on the first level an sets the &lt;b&gt;hover&lt;/b&gt; attribute to true for those elements that have a class name &quot;VEMenu&quot;. This allows enabling the hover effect without implementing the hover attribute for every menu item. 
&lt;p&gt;If you set the tabindex property on menu items another functionality is enabled. By setting tabindex to a value greater then 0 the element can get the focus either by using the tab key until you reach the right element or by using the menu with the mouse. When pressing the space bar while the focus is on a specific menuitem the onclick method of the menuitem will be called. This allows you to use the keyboard instead of clicking with the mouse and also allows repeating menu commands in an easy way. 
&lt;p&gt;When using ASP.NET it is easy to build a menubar by using the available web control: &lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #c71585&quot;&gt;ve&lt;/span&gt;:&lt;span style=&quot;color: #800000&quot;&gt;MenuBar&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;runat&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&quot;server&quot;&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;eventnamespace&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&quot;de.mathertel.edit&quot;&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt; 
  ...
&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #c71585&quot;&gt;ve&lt;/span&gt;:&lt;span style=&quot;color: #800000&quot;&gt;MenuBar&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt; 
&lt;/pre&gt;
&lt;p&gt;The implementation in JavaScript is available here: 
&lt;p&gt;&lt;a href=&quot;http://www.mathertel.de/AjaxEngine/documentation/ViewDoc.aspx?file=~/controls/menubar.js&quot;&gt;http://www.mathertel.de/AjaxEngine/documentation/ViewDoc.aspx?file=~/controls/menubar.js&lt;/a&gt; 
&lt;p&gt;A sample page that uses this control is available here: 
&lt;p&gt;&lt;a href=&quot;http://www.mathertel.de/AjaxEngine/S04_VisualEffects/InlineEditDemo.aspx&quot;&gt;http://www.mathertel.de/AjaxEngine/S04_VisualEffects/InlineEditDemo.aspx&lt;/a&gt; 
&lt;p&gt;(see the source code of the page by using the view link in the upper right corner)&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://ajaxaspects.blogspot.com/feeds/1021056879897739360/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7581919&amp;postID=1021056879897739360' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/1021056879897739360'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/1021056879897739360'/><link rel='alternate' type='text/html' href='http://ajaxaspects.blogspot.com/2008/01/building-menus-with-openajax-events.html' title='Building menus with OpenAjax events'/><author><name>Matthias Hertel</name><uri>https://plus.google.com/116098072736241499757</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-M0Om2hGPjV8/AAAAAAAAAAI/AAAAAAAAAOs/F8uLY205io8/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7581919.post-6883827648763189594</id><published>2008-01-02T19:26:00.001+01:00</published><updated>2008-01-02T19:26:46.970+01:00</updated><title type='text'>More OpenAjax compatible components</title><content type='html'>&lt;h3&gt;The PersistCookie control&lt;/h3&gt; &lt;p&gt;OpenAjax events are not persistent. The specification is based on the fact that the subscribers are informed just in time when the event was published. But by using cookies the passed values can survive a page refresh or even some days. &lt;/p&gt; &lt;p&gt;In some applications it is important that the values that where published by OpenAjax events and have changed the web application in a specific way are presenting the state of the client. With the PersistCookie control it is possible to save these simple values into cookies and makes them available when the page is reloaded the next time the page loads by publishing a new OpenAjax event. By using this control it is possible to reload a page in the state that was given when the user visited it the last time or when using the refresh button.&lt;/p&gt; &lt;p&gt;Using this functionality is easy by just including a ASP.NET control like this:&lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #c71585&quot;&gt;ajax&lt;/span&gt;:&lt;span style=&quot;color: #800000&quot;&gt;PersistCookie&lt;/span&gt; &lt;font color=&quot;#ff0000&quot;&gt;runat&lt;/font&gt;=&lt;font color=&quot;#0000ff&quot;&gt;&quot;server&quot;&lt;/font&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;eventnamespace&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&quot;jcl&quot;&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;eventname&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&quot;view&quot;&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;The control is designed for persisting the values of multiple eventnames of the same eventnamespace and is providing a mechanism for default values in the case of a first time load of the page.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Using Cookies &lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Cookies do not have a namespace based mechanism as we can see in the OpenAjax hub specification so the names that are used within the cookies will not contain the namespace used by the OpenAjax event but will only use the local eventname.&lt;/p&gt;
&lt;p&gt;Another advantage of not using the namespace to build cookie names is a better use of the available storage space of cookies.&lt;/p&gt;
&lt;p&gt;If you have to store values by using the same name multiple times in your web application it is important that the part of each used cookie value is more specific than the standard root. The PersistCookie control therefore uses the current url of the page, extracts the folder part of it and uses this as the path to store the cookies. So, in most cases you will not have to specify the path attribute of this control.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;eventnamespace&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This attribute can be used for specifying the namespace that contain the to be persisted events.&lt;/p&gt;
&lt;p&gt;The default namespace is set to &quot;jcl&quot;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;eventname&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This attribute can contain a list of event names together with the default values. Then event names are separated by semicolons and the default values are appended to the names using the equal sign.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;path&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This attribute specifies a specific path for the cookie. If this attribute is not set the current url of the page is used to build a path that specifies the current folder. This avoids conflicts with other cookies used on the same web site.&lt;/p&gt;
&lt;p&gt;You will have to set this attribute only if you want to share cookies over multiple pages in different folders.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;expire&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This attribute specifies how long the cookie values should be stored.&lt;/p&gt;
&lt;p&gt;If this attribute is not set the values are only kept in memory while the browser remains open.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Samples&lt;/strong&gt;&lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #c71585&quot;&gt;ajax&lt;/span&gt;:&lt;span style=&quot;color: #800000&quot;&gt;PersistCookie&lt;/span&gt; &lt;font color=&quot;#ff0000&quot;&gt;runat&lt;/font&gt;=&lt;font color=&quot;#0000ff&quot;&gt;&quot;server&quot;&lt;/font&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;eventnamespace&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&quot;jcl&quot;&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;eventname&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&quot;view&quot;&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;or&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #c71585&quot;&gt;ajax&lt;/span&gt;:&lt;span style=&quot;color: #800000&quot;&gt;PersistCookie&lt;/span&gt; &lt;font color=&quot;#ff0000&quot;&gt;runat&lt;/font&gt;=&lt;font color=&quot;#0000ff&quot;&gt;&quot;server&quot;&lt;/font&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;eventname&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&quot;kosten=120000;jahre=4;kapital=999&quot;&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;runat&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&quot;server&quot;&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;expire&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&quot;2&quot;&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;You can find the implementation here:&lt;/p&gt;
&lt;p&gt;&lt;a title=&quot;http://www.mathertel.de/AJAXEngine/documentation/ViewDoc.aspx?file=~/controls/persistcookie.js&quot; href=&quot;http://www.mathertel.de/AJAXEngine/documentation/ViewDoc.aspx?file=~/controls/persistcookie.js&quot;&gt;http://www.mathertel.de/AJAXEngine/documentation/ViewDoc.aspx?file=~/controls/persistcookie.js&lt;/a&gt;&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://ajaxaspects.blogspot.com/feeds/6883827648763189594/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7581919&amp;postID=6883827648763189594' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/6883827648763189594'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/6883827648763189594'/><link rel='alternate' type='text/html' href='http://ajaxaspects.blogspot.com/2008/01/more-openajax-compatible-components.html' title='More OpenAjax compatible components'/><author><name>Matthias Hertel</name><uri>https://plus.google.com/116098072736241499757</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-M0Om2hGPjV8/AAAAAAAAAAI/AAAAAAAAAOs/F8uLY205io8/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7581919.post-2522198905168561343</id><published>2007-12-27T14:59:00.001+01:00</published><updated>2007-12-27T14:59:11.897+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Ajax"/><category scheme="http://www.blogger.com/atom/ns#" term="OpenAjax"/><title type='text'>Useful OpenAjax Event Logger</title><content type='html'>&lt;p&gt;While working on further adopting the OpenAjax event mechanism I wrote this small JavaScript include file that helps inspecting the current OpenAjax events.&lt;/p&gt; &lt;p&gt;It is implemented by using a single JavaScript include file that can be found at &lt;a href=&quot;http://www.mathertel.de/AjaxEngine/controls/OpenAjaxEventLog.js&quot;&gt;http://www.mathertel.de/AjaxEngine/controls/OpenAjaxEventLog.js&lt;/a&gt; (&lt;a href=&quot;http://www.mathertel.de/AJAXEngine/ViewSrc.aspx?file=~/controls/OpenAjaxEventLog.js&quot; target=&quot;_blank&quot;&gt;view source&lt;/a&gt;).&lt;/p&gt; &lt;p&gt;It is easy to include this file into ANY web page by using a small JavaScript link (a.k.a. bookmarklet) that you can type into the address bar or save as a link in your favorites:&lt;/p&gt; &lt;p&gt;Create any Link in your favorites, or the link bar and name it for example like this:&lt;/p&gt; &lt;p&gt;&lt;a title=&quot;javascript:void(document.body.appendChild(document.createElement(&#39;script&#39;)).src=&#39;http://www.mathertel.de/AjaxEngine/controls/OpenAjaxEventLog.js&#39;)&quot; href=&quot;http://www.mathertel.de/AjaxEngine/controls/OpenAjaxEventLog.js&#39;)&quot;&gt;&lt;img src=&quot;http://www.mathertel.de/Ajax/images/OpenAjaxLogLink.png&quot;&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Here is the url that you can paste into the url field in the property dialog of the link.&lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;javascript:&lt;span style=&quot;color: #0000ff&quot;&gt;void&lt;/span&gt;(&lt;span style=&quot;color: #0000ff&quot;&gt;document&lt;/span&gt;.body.appendChild(&lt;span style=&quot;color: #0000ff&quot;&gt;document&lt;/span&gt;.createElement(&#39;script&#39;)).src=&#39;http:&lt;span style=&quot;color: #008000&quot;&gt;//www.mathertel.de/AjaxEngine/controls/OpenAjaxEventLog.js&#39;)&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;There will be one dialog that warns you about the fact that the url is using JavaScript (an unregistered program - what means that ?) and that this may be unwanted. But in this case it is what we need.&lt;/p&gt;
&lt;p&gt;You can open any of the sample pages from the &lt;a title=&quot;http://www.openajax.org/member/wiki/InteropFest_1.0&quot; href=&quot;http://www.openajax.org/member/wiki/InteropFest_1.0&quot;&gt;http://www.openajax.org/member/wiki/InteropFest_1.0&lt;/a&gt; and try it.&lt;/p&gt;
&lt;p&gt;If you click on the link you just created a extra area will be appended at the bottom of the page and all OpenAjax events will be shown in there.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you like to know more about bookmarklets you can google this term and you will find a lot more tricks.&lt;/p&gt;
&lt;p&gt;My favorite is:&lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;javascript:&#39;&amp;lt;xmp&amp;gt;&#39;+&lt;span style=&quot;color: #0000ff&quot;&gt;document&lt;/span&gt;.documentElement.outerHTML+&#39;&amp;lt;/xmp&amp;gt;&#39;&lt;/pre&gt;  </content><link rel='replies' type='application/atom+xml' href='http://ajaxaspects.blogspot.com/feeds/2522198905168561343/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7581919&amp;postID=2522198905168561343' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/2522198905168561343'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/2522198905168561343'/><link rel='alternate' type='text/html' href='http://ajaxaspects.blogspot.com/2007/12/useful-openajax-event-logger.html' title='Useful OpenAjax Event Logger'/><author><name>Matthias Hertel</name><uri>https://plus.google.com/116098072736241499757</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-M0Om2hGPjV8/AAAAAAAAAAI/AAAAAAAAAOs/F8uLY205io8/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7581919.post-2393709146200658472</id><published>2007-12-19T21:04:00.001+01:00</published><updated>2007-12-19T21:04:54.624+01:00</updated><title type='text'>Passing values around with OpenAjax events</title><content type='html'>&lt;p&gt;When publishing and receiving OpenAjax events there is the built-in mechanism of passing a payload a.k.a publisherData around together with the event. When implementing applications based on OpenAjax events there are some more things you should care about when using the publisherData feature. In the specifications you can also find some guidelines.&lt;/p&gt; &lt;p&gt;&lt;b&gt;1. Don’t change the publisherData when handling an event.&lt;/b&gt; &lt;p&gt;That’s already said in the specification. Another and not so explicit mentioned argument for not doing so is the fact that there may be multiple subscribers to the same event. Because the sequence of the elements that receive the event is not determined you do not know whether a control gets the original or the modified publisherData. Anyway these situations are hard to debug – another reason to avoid them. &lt;p&gt;&lt;b&gt;2. Don’t use objects – use strings instead&lt;/b&gt; &lt;p&gt;Right now the OpenAjax hub implementation is client side only but you can expect that events can also be spread other windows on inner iframes. In both cases direct object references are a problem because they cannot pass completely. If you need more than simple values consider using a proprietary format like &quot;29.0016;18.5337&quot;, a JSON or an XML string. &lt;p&gt;And don’t assume when passing a numeric value that the subscribers get them as a JavaScript Number object. &lt;p&gt;It seems that strings are fine. :-) &lt;p&gt;&lt;b&gt;3. Don’t use language specific formats&lt;/b&gt; &lt;p&gt;Users like to enter values into fields by using their culture or national language specific notations. Most keyboards here in Germany have a comma in the numeric keypad and a many people would not agree in typing dots when filling out fields for example with prices. &lt;p&gt;If you pass a &quot;1.777,88&quot; around you must assume that all subscribers can understand this specific notation. You can’t assume that if you like to live in meshup scenarios where the connected components come from different world wide vendors or sites. You even can’t assume that when writing a web application for the German speaking market: the Swiss people like the format: &quot;1&#39;777.88&quot;. &lt;p&gt;A good idea is to pass the values as defined by JSON and make them directly useable by scripting. &lt;p&gt;&lt;b&gt;4. Don’t pass date values&lt;/b&gt; &lt;p&gt;Passing date values is somewhat problematic because there is no JavaScript constant definition (a.k.a. JSON) for that datatype. :-( &lt;p&gt;I recommend using the XML notation that is based on ISO 8601 date and time formats: &quot;2007-12-24T18:00:02&quot;, but I must admit that that&#39;s my personal preference based on the fact that I prefer XML and SOAP.   </content><link rel='replies' type='application/atom+xml' href='http://ajaxaspects.blogspot.com/feeds/2393709146200658472/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7581919&amp;postID=2393709146200658472' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/2393709146200658472'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/2393709146200658472'/><link rel='alternate' type='text/html' href='http://ajaxaspects.blogspot.com/2007/12/passing-values-around-with-openajax.html' title='Passing values around with OpenAjax events'/><author><name>Matthias Hertel</name><uri>https://plus.google.com/116098072736241499757</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-M0Om2hGPjV8/AAAAAAAAAAI/AAAAAAAAAOs/F8uLY205io8/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7581919.post-296626509400443031</id><published>2007-12-12T21:39:00.001+01:00</published><updated>2007-12-12T21:39:18.271+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Ajax"/><category scheme="http://www.blogger.com/atom/ns#" term="components"/><category scheme="http://www.blogger.com/atom/ns#" term="controls"/><category scheme="http://www.blogger.com/atom/ns#" term="Forms"/><category scheme="http://www.blogger.com/atom/ns#" term="OpenAjax"/><category scheme="http://www.blogger.com/atom/ns#" term="SOAP"/><category scheme="http://www.blogger.com/atom/ns#" term="webservice"/><title type='text'>Using OpenAjax events for building data-centric and forms based AJAX applications</title><content type='html'>&lt;p&gt;Most of the business web applications on the Internet are HTML forms based applications where html elements are bound to data is the core functionality. I am talking about registration forms, dialogs and pages to display and modify records of a server side relational database system like in ERP or CRM systems.  &lt;p&gt;Usually there is not a lot of drag &amp;amp; drop activity or popping visual effects here but the most active elements deal with data that comes from databases or other data sources. We need to display, edit and control records from a company&#39;s database and implement transactions on these entities.  &lt;p&gt;Here is an approach to use the OpenAjax event mechanism to implement this kind of web applications. The beauty of it and the reason why I implemented this for the AjaxEngine open source project is that using events and namespaces is a far more open approach then the mechanism that I introduced some time ago and has a neat extensibility model.  &lt;p&gt;&lt;b&gt;Typical data-centric web pages&lt;/b&gt;  &lt;p&gt;&lt;a href=&quot;http://www.mathertel.de/ajax/images/ajaxformbindings.png&quot;&gt;&lt;img alt=&quot;Using OpenAjax events for building data-centric and forms based AJAX applications&quot; src=&quot;http://www.mathertel.de/ajax/images/ajaxformbindings.png&quot; border=&quot;0&quot;&gt;&lt;/a&gt;  &lt;p&gt;From a high level viewpoint onto pages that implement data-centric applications you see that the elements on the page can be categorized into the following cases:  &lt;ul&gt; &lt;li&gt;Fields and other elements where values are shown and edited by the users (Input fields, checkboxes, ...)  &lt;li&gt;Buttons that help editing these values (calendar popup, drop-down lists, ...)  &lt;li&gt;Foreign key Lookup mechanisms (checking against a list of countries, ...)  &lt;li&gt;Buttons that offer a way of navigation through huge data sources (|&amp;lt; first, next &amp;gt;&amp;gt;, ...)  &lt;li&gt;Buttons that commit a current state to the backend system ([Update])  &lt;li&gt;Buttons that trigger special transactions or back-end calculations&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Forms in this kind of scenario are just a collection of html elements that together can be used to display or edit a single record of a given schema.  &lt;h5&gt;Where to use OpenAjax events&lt;/h5&gt; &lt;p&gt;Events can help in these situations where a direct connection between components is not desired or otherwise problematic:  &lt;p&gt;&lt;b&gt;1. events on the field-level&lt;/b&gt;  &lt;p&gt;On the field-level (inside the form) data is passed around when the value of a field or another data control is changed. This happens either by a user interaction with a field or another data control or as part of a situation on the record level for example when a new record is displayed.  &lt;p&gt;If a field exists it can subscribe to the appropriate event and can display the value passed around. On the other side it can also publish a new event if the user changes the value.  &lt;p&gt;It doesn’t matter if a real field is used or a slider, a calendar popup or a 3d spin control. Even multiple controls that subscribe to the same event can coexist side by side without knowing from each other.  &lt;p&gt;Conclusion 1: Using OpenAjax events gives us the advantage of having a simple plugin mechanism that is extendable.  &lt;p&gt;&lt;b&gt;2. events from the menubar&lt;/b&gt;  &lt;p&gt;Clicking a button already publishes the HTML built-in onclick event. However this event is only passed to those elements that are clicked directly or are part of the control hierarchy of the html object model. The menubar catches these events and transfers them into OpenAjax events that are passed to all elements that are interested because they have subscribed them. These events in contrary to the html DOM events are carrying a semantic by using the full eventname and eventually by carrying some data with them.  &lt;p&gt;Conclusion 2: Using OpenAjax events can add semantic statements to events.  &lt;p&gt;Conclusion 3: OpenAjax events are independent from the html DOM layout and therefore can help separating the UI model from the event model.  &lt;p&gt;These 2 scenarios fit well into the OpenAjax event standard.  &lt;h5&gt;Antipatterns to OpenAjax events&lt;/h5&gt; &lt;p&gt;&lt;b&gt;1. events between tight coupled components&lt;/b&gt;  &lt;p&gt;The datasource controller and the form element are 2 components that share some information flow. However every situation in this scenario is started by the datasource controller. The case where a user wants to “update” the datasource controller has to request the current form data from the form. Using is not practical because the form element that would receive the event will not be able to “attach” the current form data. A direct connection is more adequate approach by sharing a common interface like the 3 methods.  &lt;p&gt;Conclusion 4: Using OpenAjax events to retrieve information is not a practical solution. Tight coupled components are still an option.  &lt;p&gt;Note: Maybe some other control is interested in the fact that new data is available in the form which is done through a write() call. This can be the reason for publishing an event by the datasource controller that expresses that.  &lt;p&gt;&lt;b&gt;2. events between passed between client and server&lt;/b&gt;  &lt;p&gt;The datasource controller also has to exchange data with the server. This is a direct end to end communication that happens every time a record is fetched from the server or a record should be updated. OpenAjax events can’t cross this boundary (yet) and again there is return data that is not available immediately when using asynchronous calls (I hope you do for reasons of robustness).  &lt;p&gt;Conclusion 5: Remote Procedure Calls situations should be implemented by using a high level AJAX protocol.  &lt;h5&gt;Using attributes on controls to define the event names&lt;/h5&gt; &lt;p&gt;One design convention that is used within the DataControls is that the eventnames that are used by controls can be split into 2 parts: the namespace and the local name.  &lt;p&gt;The event “de.mathertel.datasource.search” that is used by the search button in the menubar has the namespace “de.mathertel.datasource” and the local name “search”. The eventname can be specified on the button itself ion 2 ways.  &lt;ol&gt; &lt;li&gt;When the eventname attribute contains a dot character it is assumed that the value already contains a full qualified event name.  &lt;li&gt;When the eventname attribute contains no dot character the parent elements are scanned for a “eventnamespace” attribute ant the effective event name is built by combining them.&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;Here is the sample of the html code:&lt;pre&gt;&amp;lt;div id=&quot;datamenubar&quot; class=&quot;VEMenuBar&quot; eventnamespace=&quot;de.mathertel.datasource&quot;&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp; &amp;lt;span hover=&quot;true&quot; class=&quot;VEMenu&quot; tabindex=&quot;1&quot; eventname=&quot;search&quot;&amp;gt;Search&amp;lt;/span&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp; ...&lt;/pre&gt;&lt;pre&gt;&amp;lt;/div&amp;gt;&lt;/pre&gt;
&lt;p&gt;This convention helps writing short html attributes and allows an easy changing of the namespace that is used for a collection of controls. 
&lt;p&gt;Currently the menubar control and the ajax form control both use this mechanism for building the full qualified even names from the eventname / eventnamespace attributes. 
&lt;p&gt;That’s the blue print of the current changes that took place in the AjaxEngine project. The even simplified the way Ajax Forms can be implemented and helps minimizing the code that we usually need to connect all the elements in a typical data-centric web application.&lt;/p&gt;
&lt;p&gt;Have a look at the sample: &lt;a title=&quot;http://www.mathertel.de/AJAXEngine/S06_AJAXForms/SimpleReader.aspx&quot; href=&quot;http://www.mathertel.de/AJAXEngine/S06_AJAXForms/SimpleReader.aspx&quot;&gt;http://www.mathertel.de/AJAXEngine/S06_AJAXForms/SimpleReader.aspx&lt;/a&gt;. If you scroll down the page you can also see a region with a protocol of the raised events.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://ajaxaspects.blogspot.com/feeds/296626509400443031/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7581919&amp;postID=296626509400443031' title='1 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/296626509400443031'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/296626509400443031'/><link rel='alternate' type='text/html' href='http://ajaxaspects.blogspot.com/2007/12/using-openajax-events-for-building-data.html' title='Using OpenAjax events for building data-centric and forms based AJAX applications'/><author><name>Matthias Hertel</name><uri>https://plus.google.com/116098072736241499757</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-M0Om2hGPjV8/AAAAAAAAAAI/AAAAAAAAAOs/F8uLY205io8/s512-c/photo.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7581919.post-1259499465891844695</id><published>2007-11-20T22:34:00.001+01:00</published><updated>2007-11-20T22:34:46.307+01:00</updated><title type='text'>AjaxEngine is now full based on the OpenAjax specification</title><content type='html'>&lt;p&gt;During the last weeks a lot of work was done to remove the old DataConnection implementations in the Ajax Engine open source project. Now it&#39;s done. You can find a first version of it in the repository on&amp;nbsp; Sourceforge: &lt;a title=&quot;http://sourceforge.net/svn/?group_id=200182&quot; href=&quot;http://sourceforge.net/svn/?group_id=200182&quot;&gt;http://sourceforge.net/svn/?group_id=200182&lt;/a&gt;&lt;/p&gt; &lt;p&gt;and the sample web site &lt;a title=&quot;http://www.mathertel.de/AJAXEngine&quot; href=&quot;http://www.mathertel.de/AJAXEngine&quot;&gt;http://www.mathertel.de/AJAXEngine&lt;/a&gt; was also published with this version today.&lt;/p&gt; &lt;p&gt;The current version will be tagged 1.5.nnnn.beta1 and a donwloadable zip file will also be available soon.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;The OpenAjax hub specifications seems to be almost finished so not much work will be left until a final full compatible version.&lt;/p&gt; </content><link rel='replies' type='application/atom+xml' href='http://ajaxaspects.blogspot.com/feeds/1259499465891844695/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7581919&amp;postID=1259499465891844695' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/1259499465891844695'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/1259499465891844695'/><link rel='alternate' type='text/html' href='http://ajaxaspects.blogspot.com/2007/11/ajaxengine-is-now-full-based-on.html' title='AjaxEngine is now full based on the OpenAjax specification'/><author><name>Matthias Hertel</name><uri>https://plus.google.com/116098072736241499757</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-M0Om2hGPjV8/AAAAAAAAAAI/AAAAAAAAAOs/F8uLY205io8/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7581919.post-8259199891036134135</id><published>2007-11-09T20:20:00.001+01:00</published><updated>2007-11-09T20:20:53.894+01:00</updated><title type='text'>A alternative to JSON is available: web services</title><content type='html'>&lt;p&gt;The discussions about the security concerns of JSON coming up again. Are you looking for alternatives ?&lt;/p&gt; &lt;p&gt;I am not used to advertise for my web site but there is an alternative cross browser solution available since 2005. It&#39;s robust code and it&#39;s running inside many web applications on Java and ASP.NET.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;standard web services on the server.  &lt;li&gt;SOAP (XML) used on the network.  &lt;li&gt;JavaScript proxies on the client to allow RPC style calling of the server.  &lt;li&gt;AJAXEngine layer that solves the typical timing problems.  &lt;li&gt;No eval() !!! - no evil from eval !!! &lt;/li&gt;&lt;/ul&gt; &lt;h3&gt;One approach for multiple platforms.&lt;/h3&gt; &lt;p&gt;By using the standard protocol on the server side you don&#39;t need to incorporate any special new interfaces for you AJAX solutions and take the full advantage to the stable and secured server ports.&lt;/p&gt; &lt;p&gt;On the client all the coding is plain JavaScript. That&#39;s why the communication part of this project works on Java as well as on ASP.NET ad PHP should not be a problem too.&lt;/p&gt; &lt;p&gt;Have a look at &lt;a href=&quot;http://www.mathertel.de/AjaxEngine/&quot;&gt;http://www.mathertel.de/AjaxEngine/&lt;/a&gt; &lt;/p&gt; &lt;p&gt;It&#39;s Open Source using a BSD style license and available on &lt;a href=&quot;http://sourceforge.net/projects/ajaxengine/&quot;&gt;http://sourceforge.net/projects/ajaxengine/&lt;/a&gt;&lt;/p&gt; </content><link rel='replies' type='application/atom+xml' href='http://ajaxaspects.blogspot.com/feeds/8259199891036134135/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7581919&amp;postID=8259199891036134135' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/8259199891036134135'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/8259199891036134135'/><link rel='alternate' type='text/html' href='http://ajaxaspects.blogspot.com/2007/11/alternative-to-json-is-available-web.html' title='A alternative to JSON is available: web services'/><author><name>Matthias Hertel</name><uri>https://plus.google.com/116098072736241499757</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-M0Om2hGPjV8/AAAAAAAAAAI/AAAAAAAAAOs/F8uLY205io8/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7581919.post-3445070116046326498</id><published>2007-10-13T14:37:00.001+02:00</published><updated>2007-10-13T14:37:33.840+02:00</updated><title type='text'>Calling web services with structured parameters from JavaScript</title><content type='html'>&lt;p&gt;In many situations it is better to use structured parameters when calling SOAP based web services then using a long list of simple parameters. The proxy layer of the AjaxEngine now also supports these parameters by converting JavaScript Objects to the XML notation used in the transferred SOAP message.&lt;/p&gt; &lt;h3&gt;Parameters&lt;/h3&gt; &lt;p&gt;Using methods with structured parameters using JavaScript Objects is directly supported, just pass them with the right properties.&lt;br&gt;Here is a partial sample for a web service definition in C#: &lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: #008000&quot;&gt;// Define a point in the 3D space. public class Point3D {&lt;/span&gt;
  &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;double&lt;/span&gt; x, y, z;
} &lt;span style=&quot;color: #008000&quot;&gt;// Point3D&lt;/span&gt;

[WebMethod(Description = &quot;&lt;span style=&quot;color: #8b0000&quot;&gt;Calculate the distance of 2 points in the 3D space.&lt;/span&gt;&quot;)]
&lt;span style=&quot;color: #008000&quot;&gt;// Test function passing structured objects.&lt;/span&gt;
&lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;double&lt;/span&gt; CalcDistance3D(Point3D p1, Point3D p2) {
  Point3D v = &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; Point3D();
  v.x = p2.x - p1.x;
  v.y = p2.y - p1.y;
  v.z = p2.z - p1.z;
  &lt;span style=&quot;color: #0000ff&quot;&gt;double&lt;/span&gt; dist = Math.Sqrt((v.x * v.x) + (v.y * v.y) + (v.z * v.z));
  &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; (dist);
} &lt;span style=&quot;color: #008000&quot;&gt;// CalcDistance3D &lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Calling this method from JavaScript by using the generated proxy method is easy by using JavaScript Objects:&lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;var&lt;/span&gt; p1 = {x:3, y:2, z:-4};
&lt;span style=&quot;color: #0000ff&quot;&gt;var&lt;/span&gt; p2 = {x:1, y:1, z:1};
&lt;span style=&quot;color: #0000ff&quot;&gt;var&lt;/span&gt; dist = proxies._types.CalcDistance3D(p1, p2);&lt;/pre&gt;
&lt;p&gt;If you like to use XmlDocuments ???&lt;/p&gt;
&lt;h3&gt;Structured return values&lt;/h3&gt;
&lt;p&gt;Methods of web services may also return structured values. Here is a sample of a method for calculating a vector in the 3D space:&lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;[WebMethod(Description = &quot;&lt;span style=&quot;color: #8b0000&quot;&gt;Calculate the vector between 2 points in the 3D space.&lt;/span&gt;&quot;)]
&lt;span style=&quot;color: #008000&quot;&gt;// Test function returning a complex object.&lt;/span&gt;
&lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; Point3D CalcVector3D(Point3D p1, Point3D p2) {
  Point3D v = &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; Point3D();
  v.x = p2.x - p1.x;
  v.y = p2.y - p1.y;
  v.z = p2.z - p1.z;
  &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; (v);
} &lt;span style=&quot;color: #008000&quot;&gt;// CalcVector3D&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Structured values that are returned by methods are available as XmlDocuments when you call a method like this. If you prefer to have the value as an JavaScript Object there is a function available in the proxies namespace that you can use: &lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;var&lt;/span&gt; p1 = {x:3, y:2, z:-4};
&lt;span style=&quot;color: #0000ff&quot;&gt;var&lt;/span&gt; p2 = {x:1, y:1, z:1};

&lt;span style=&quot;color: #0000ff&quot;&gt;var&lt;/span&gt; xmlVector = proxies._types.CalcVector3D(p1, p2);
&lt;span style=&quot;color: #0000ff&quot;&gt;var&lt;/span&gt; v = proxies.xml2json(xmlVector);
&lt;span style=&quot;color: #0000ff&quot;&gt;alert&lt;/span&gt;(v.x + &quot;&lt;span style=&quot;color: #8b0000&quot;&gt;/&lt;/span&gt;&quot; + v.y + &quot;&lt;span style=&quot;color: #8b0000&quot;&gt;/&lt;/span&gt;&quot; + v.z);&lt;/pre&gt;
&lt;h3&gt;Limitations&lt;/h3&gt;
&lt;p&gt;Objects used as parameters cannot be too complex. JavaScript Objects that have native values&lt;br&gt;(not Arrays nor Objects) are supported.&lt;br&gt;The data must be available in the format that can be de-serialized on the server&lt;br&gt;so take care of decimal points and date values. 
&lt;p&gt;Up to now the only way to use complex parameters with SOAP methods &lt;br&gt;was to use a server side XmlDocument Object and to extract the given values by using the appropriate methods. 
&lt;h3&gt;Download&lt;/h3&gt;
&lt;p&gt;This addition was done in the current version under development. Because ajax.js is almost independent from the other current changes you can download it to existing projects from the sourceforge repository at &lt;a title=&quot;http://ajaxengine.svn.sourceforge.net/viewvc/ajaxengine/trunk/ajaxcore/&quot; href=&quot;http://ajaxengine.svn.sourceforge.net/viewvc/ajaxengine/trunk/ajaxcore/&quot;&gt;http://ajaxengine.svn.sourceforge.net/viewvc/ajaxengine/trunk/ajaxcore/&lt;/a&gt; or from the website &lt;a title=&quot;http://www.mathertel.de/AJAXEngine/ajaxcore/ajax.js&quot; href=&quot;http://www.mathertel.de/AJAXEngine/ajaxcore/ajax.js&quot;&gt;http://www.mathertel.de/AJAXEngine/ajaxcore/ajax.js&lt;/a&gt;.
 </content><link rel='replies' type='application/atom+xml' href='http://ajaxaspects.blogspot.com/feeds/3445070116046326498/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7581919&amp;postID=3445070116046326498' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/3445070116046326498'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/3445070116046326498'/><link rel='alternate' type='text/html' href='http://ajaxaspects.blogspot.com/2007/10/calling-web-services-with-structured.html' title='Calling web services with structured parameters from JavaScript'/><author><name>Matthias Hertel</name><uri>https://plus.google.com/116098072736241499757</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-M0Om2hGPjV8/AAAAAAAAAAI/AAAAAAAAAOs/F8uLY205io8/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7581919.post-4254101422729576056</id><published>2007-09-03T21:04:00.001+02:00</published><updated>2007-09-03T21:04:53.247+02:00</updated><title type='text'>The plan for Q3/2007</title><content type='html'>&lt;p&gt;I&#39;ve got some mails that have asked about the future of the AjaxEngine framework and here are some statements on that topic:&lt;/p&gt; &lt;p&gt;I will support and extend the framework in the future so companies and other open source projects that reuse it will have the support I can give. Some of the current topics that I&#39;ll hope to finish this month are:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;OpenAjax compatibility for all controls including a InterOp fest compatibility test case.  &lt;li&gt;Extending the functionality and the documentation of the Ajax form and the data controls.  &lt;li&gt;Writing some more input helpers.  &lt;li&gt;Writing about all of it...&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;I will make a beta version then and have some weeks to get the new functionality stable before publishing a new version.&lt;/p&gt; &lt;p&gt;You can always see the current implementation state in the svn based OpenSource repository at Sourceforge:&amp;nbsp;&lt;a title=&quot;http://sourceforge.net/svn/?group_id=200182&quot; href=&quot;http://sourceforge.net/svn/?group_id=200182&quot;&gt;http://sourceforge.net/svn/?group_id=200182&lt;/a&gt;&lt;/p&gt; &lt;p&gt;as well as the demo site that will also be based on the current version under development.&lt;/p&gt; &lt;p&gt;If anyone wants to add&amp;nbsp;some core directly to the project instead of sending me mails let me know.&amp;nbsp;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://ajaxaspects.blogspot.com/feeds/4254101422729576056/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7581919&amp;postID=4254101422729576056' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/4254101422729576056'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/4254101422729576056'/><link rel='alternate' type='text/html' href='http://ajaxaspects.blogspot.com/2007/09/plan-for-q32007.html' title='The plan for Q3/2007'/><author><name>Matthias Hertel</name><uri>https://plus.google.com/116098072736241499757</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-M0Om2hGPjV8/AAAAAAAAAAI/AAAAAAAAAOs/F8uLY205io8/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7581919.post-2346477243866184949</id><published>2007-08-14T00:00:00.001+02:00</published><updated>2007-08-14T20:06:52.682+02:00</updated><title type='text'>Extending the OpenAjax hub</title><content type='html'>&lt;p&gt;Extending events over the network by using an OpenAjax hub compatible approach.&lt;/p&gt; &lt;p&gt;The current version of the OpenAjax hub implementation (Hub 1.0) is focusing on a client-side solution for integrating components into a web application. But it doesn&#39;t address any needs that might come with the scenarios where events have to cross the boundaries of the current client side window.  &lt;p&gt;However the hub specification does not explicit exclude these scenarios and is extendible without changing the API itself by introducing a OpenAjax compatible extender component.&lt;/p&gt; &lt;p&gt;Another approach is currently discussed in the OpenAjax member wiki&amp;nbsp;at &lt;a title=&quot;OpenAjax_Hub_1.1_Roadmap&quot; href=&quot;http://www.openajax.org/member/wiki/OpenAjax_Hub_1.1_Roadmap&quot;&gt;http://www.openajax.org/member/wiki/OpenAjax_Hub_1.1_Roadmap&lt;/a&gt;&amp;nbsp;that is designed by extending the API of the hub itself.  &lt;h3&gt;Building an OpenAjax hub extender&lt;/h3&gt; &lt;p&gt;The idea behind building an extender is to capture the events in one window and pass it over to other windows.  &lt;p&gt;When the windows exists in the same frameset and share a common top window the message just needs to cross the boundaries. If the window is on another computer the client has to capture the event, and pass it to a server where other clients can then attach and retrieve the events.  &lt;p&gt;&lt;strong&gt;1. capturing events&lt;/strong&gt;  &lt;p&gt;For the local hub implementation the part of the hub extender that captures the local events is just another subscriber. It can register to any local events or can just listen to some of the events that come around. The attribute &quot;capture&quot; is used to specify what events are sent to the server by specifying a semicolon separated list of namespaces using the same syntax as the subscribe method.  &lt;p&gt;The other attribute that we need is the name of the service where the events can be send to using the server site publish method.&lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: #008000&quot;&gt;// registering for the local event.&lt;/span&gt;
OpenAjax.hub.subscribe(&lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;.capture, &quot;&lt;span style=&quot;color: #8b0000&quot;&gt;_catchLocalEvents&lt;/span&gt;&quot;, &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;);

&lt;span style=&quot;color: #008000&quot;&gt;// this function is called whenever a local event was published&lt;/span&gt;
_catchLocalEvents: &lt;span style=&quot;color: #0000ff&quot;&gt;function&lt;/span&gt;(eventName, eventData) {
  &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (! &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._replay) {
    &lt;span style=&quot;color: #008000&quot;&gt;// it&#39;s a real local event so publish it.&lt;/span&gt;
    &lt;span style=&quot;color: #0000ff&quot;&gt;var&lt;/span&gt; a = [eventName, eventData];
    a.multi = &lt;span style=&quot;color: #0000ff&quot;&gt;true&lt;/span&gt;;
    &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;.lastLocalAction = eventName + &quot;&lt;span style=&quot;color: #8b0000&quot;&gt;:&lt;/span&gt;&quot; + eventData;
    ajax.Start(&lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;.sendAction, a);
  } &lt;span style=&quot;color: #008000&quot;&gt;// if&lt;/span&gt;
}, &lt;span style=&quot;color: #008000&quot;&gt;// _catchLocalEvents&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;The _replay flag is taking care about the fact that the events that are coming from the server should not be repeated back to the server. 
&lt;p&gt;The sendAction is the description how the server should be called.&amp;nbsp;The call should be started&amp;nbsp;at once and&amp;nbsp;multiple calls for publishing an event to the server can be queued. There is no return value in this case.&amp;nbsp;&lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: #008000&quot;&gt;// The Ajax action to send an event to the server&lt;/span&gt;
sendAction: {
  delay:0,
  queueMultiple:&lt;span style=&quot;color: #0000ff&quot;&gt;true&lt;/span&gt;,
  prepare: &lt;span style=&quot;color: #0000ff&quot;&gt;function&lt;/span&gt; (a) { &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt;(a); },
  call: &quot;proxies.OpenAjaxChat.Publish&quot;,
  finish: &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;,
  onException: proxies.alertException
}, &lt;span style=&quot;color: #008000&quot;&gt;// sendAction&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;2. listening to events&lt;/strong&gt; 
&lt;p&gt;Listening to events that come from the server is somewhat more complicated because the normal http interaction schema for web applications is client side initiated. The server just has no chance to send messages to &quot;all&quot; or &quot;specific&quot; clients but has to wait until a client asks for an update. 
&lt;p&gt;So the client loops by using another Ajax action that is specified with a small delay and calls the server to retrieve new events. The server will return all newer events that have been recorded since the last call of this client that is determined by using a marking counter that can be passed from the client.&lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: #008000&quot;&gt;// this function is called after retrieving all the events from the server.&lt;/span&gt;
_republish: &lt;span style=&quot;color: #0000ff&quot;&gt;function&lt;/span&gt;(events) {
  &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._replay = &lt;span style=&quot;color: #0000ff&quot;&gt;true&lt;/span&gt;;
  &lt;span style=&quot;color: #0000ff&quot;&gt;var&lt;/span&gt; aList = events.split(&#39;\n&#39;);
  &lt;span style=&quot;color: #0000ff&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #0000ff&quot;&gt;var&lt;/span&gt; n = 0; n &amp;lt; aList.&lt;span style=&quot;color: #0000ff&quot;&gt;length&lt;/span&gt; - 1; n++) {
    &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (aList[n] != &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;.lastLocalAction) {
      &lt;span style=&quot;color: #0000ff&quot;&gt;var&lt;/span&gt; a = aList[n].split(&#39;:&#39;);
      OpenAjax.hub.publish(a[0], a[1]);
    }
  } &lt;span style=&quot;color: #008000&quot;&gt;// for&lt;/span&gt;
  &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._replay = &lt;span style=&quot;color: #0000ff&quot;&gt;false&lt;/span&gt;;

  &lt;span style=&quot;color: #008000&quot;&gt;// remember the current marker&lt;/span&gt;
  &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;.marker = aList[aList.&lt;span style=&quot;color: #0000ff&quot;&gt;length&lt;/span&gt;-1];

  &lt;span style=&quot;color: #008000&quot;&gt;// start another pollAction&lt;/span&gt;
  ajax.Start(&lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;.pollAction, &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;);
},&lt;/pre&gt;
&lt;p&gt;The action is calling the serer by passing the current marker of the client and the asynchronous result will be passed to the _republish method.&lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: #008000&quot;&gt;// The Ajax action that polls the events from the server&lt;/span&gt;
pollAction: {
  delay:200, &lt;span style=&quot;color: #008000&quot;&gt;// wait 200 msec before calling the server (just to be smart).&lt;/span&gt;
  prepare: &lt;span style=&quot;color: #0000ff&quot;&gt;function&lt;/span&gt; (obj) { &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt;(obj.marker); },
  call: &lt;span style=&quot;color: #0000ff&quot;&gt;&quot;proxies.OpenAjaxChat.PullEvents&quot;&lt;/span&gt;,
  finish: &lt;span style=&quot;color: #0000ff&quot;&gt;function&lt;/span&gt; (ret, obj) { obj._republish(ret); },
  onException: proxies.alertException
} &lt;span style=&quot;color: #008000&quot;&gt;// pollAction&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;The action and the _republish method will be called repetitive to poll the server. 
&lt;p&gt;One thing is left to do in the implementation of this action is the fact that local events already have been published on the client and should not be republished when the server returns them again. To stop publishing an event twice the hub extender records the last event that has been captured locally and sorts this event out. 
&lt;h3&gt;The&amp;nbsp;Server API &lt;/h3&gt;
&lt;p&gt;Calling the server for publishing and retrieving the latest events is implemented by using a real SOAP based webservice with the 2 methods Publish and PullEvents. 
&lt;p&gt;The communication layer is not as complex as the one defined with Bayeux from the Dojo Foundation but it helps in most scenarios. It is restricted in some way because complex objects cannot be used by the eventData. 
&lt;p&gt;The return value of pullevents method is complex object that contains an array of eventname and eventdata and the value of the current marker that is transported using a string too by using the following format: 
&lt;blockquote&gt;
&lt;p&gt;[namespace.eventname:data\n]* 
&lt;p&gt;marker&lt;/p&gt;&lt;/blockquote&gt;
&lt;h3&gt;A sample application &lt;/h3&gt;
&lt;p&gt;A small sample is showing how all together can be used. It is a kind of chat application where anyone can participate in the same conversation by just opening the url: &lt;a href=&quot;http://www.mathertel.de/AjaxEngine/S06_AJAXForms/OpenAjaxChat.aspx&quot;&gt;http://www.mathertel.de/AjaxEngine/S06_AJAXForms/OpenAjaxChat.aspx&lt;/a&gt; 
&lt;p&gt;You can change your current alias in the configuration section of the page. The large textarea is used to display all the events as the arise and the small textfield beneath can be used by you to type some text. Feel free top open another window and see that your written text also appears on the other side and maybe you can see others typing too. (I suggest talking about animals).&lt;br&gt;The data itself is a combination of the user&#39;s name and the typed text. 
&lt;p&gt;The first component is the one that is used for entering a new message and it publishes the event de.mathertel.chatsample.message whenever a line is finished by using the return key. The implementation is quite simple: &lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;&amp;lt;fieldset style=&quot;&lt;span style=&quot;color: #8b0000&quot;&gt;width: 424px&lt;/span&gt;&quot;&amp;gt;&amp;lt;legend&amp;gt;&lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; message:&amp;lt;/legend&amp;gt;
  &amp;lt;input id=&quot;&lt;span style=&quot;color: #8b0000&quot;&gt;newmessage&lt;/span&gt;&quot; style=&quot;&lt;span style=&quot;color: #8b0000&quot;&gt;width: 390px;&lt;/span&gt;&quot; /&amp;gt;
&amp;lt;/fieldset&amp;gt;

&lt;span style=&quot;color: #008000&quot;&gt;// the functionality of the new message field.&lt;/span&gt;
&lt;span style=&quot;color: #0000ff&quot;&gt;var&lt;/span&gt; newmessageBehavior = {
  onkeypress: &lt;span style=&quot;color: #0000ff&quot;&gt;function&lt;/span&gt;(evt) {
    evt = evt || &lt;span style=&quot;color: #0000ff&quot;&gt;window&lt;/span&gt;.event;
    &lt;span style=&quot;color: #008000&quot;&gt;// send the message when pressing &amp;lt;enter&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (evt.keyCode == 13) {
      OpenAjax.hub.publish(&quot;&lt;span style=&quot;color: #8b0000&quot;&gt;de.mathertel.chatsample.message&lt;/span&gt;&quot;, &lt;span style=&quot;color: #0000ff&quot;&gt;document&lt;/span&gt;.getElementById(&quot;&lt;span style=&quot;color: #8b0000&quot;&gt;username&lt;/span&gt;&quot;).value
        + &quot;&lt;span style=&quot;color: #8b0000&quot;&gt; - &lt;/span&gt;&quot; + &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;.value);
      &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;.value = &quot;&lt;span style=&quot;color: #8b0000&quot;&gt;&lt;/span&gt;&quot;;
    }
  } &lt;span style=&quot;color: #008000&quot;&gt;// onkeypress&lt;/span&gt;
} &lt;span style=&quot;color: #008000&quot;&gt;// newmessageBehavior&lt;/span&gt;
OpenAjax.hub.registerLibrary(&quot;&lt;span style=&quot;color: #8b0000&quot;&gt;newmessageBehavior&lt;/span&gt;&quot;, &quot;&lt;span style=&quot;color: #8b0000&quot;&gt;http://www.mathertel.de/OpenAjax/newmessageBehavior&lt;/span&gt;&quot;);
jcl.LoadBehaviour(&quot;&lt;span style=&quot;color: #8b0000&quot;&gt;newmessage&lt;/span&gt;&quot;, newmessageBehavior);&lt;/pre&gt;
&lt;p&gt;The next component implemented is the larger textarea where the all the events will be logged: &lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;&amp;lt;fieldset style=&quot;&lt;span style=&quot;color: #8b0000&quot;&gt;width: 424px&lt;/span&gt;&quot;&amp;gt;&amp;lt;legend&amp;gt;Chat log:&amp;lt;/legend&amp;gt;
  &amp;lt;textarea rows=&quot;&lt;span style=&quot;color: #8b0000&quot;&gt;10&lt;/span&gt;&quot; cols=&quot;&lt;span style=&quot;color: #8b0000&quot;&gt;50&lt;/span&gt;&quot; id=&quot;&lt;span style=&quot;color: #8b0000&quot;&gt;chatlog&lt;/span&gt;&quot; disabled=&quot;&lt;span style=&quot;color: #8b0000&quot;&gt;disabled&lt;/span&gt;&quot;&amp;gt;
  &amp;lt;textarea /&amp;gt;
&amp;lt;/fieldset&amp;gt;


&lt;span style=&quot;color: #008000&quot;&gt;// the functionality of the chat log area.&lt;/span&gt;
&lt;span style=&quot;color: #0000ff&quot;&gt;var&lt;/span&gt; chatlogBehavior = {
  &lt;span style=&quot;color: #008000&quot;&gt;// registering for the event.&lt;/span&gt;
  init: &lt;span style=&quot;color: #0000ff&quot;&gt;function&lt;/span&gt; () {
    OpenAjax.hub.subscribe(&quot;&lt;span style=&quot;color: #8b0000&quot;&gt;de.mathertel.chatsample.**&lt;/span&gt;&quot;, &quot;&lt;span style=&quot;color: #8b0000&quot;&gt;_log&lt;/span&gt;&quot;, &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;);
  }, &lt;span style=&quot;color: #008000&quot;&gt;// init&lt;/span&gt;

  &lt;span style=&quot;color: #008000&quot;&gt;// append another line to the log text and cut the first one if there are too many.&lt;/span&gt;
  _log: &lt;span style=&quot;color: #0000ff&quot;&gt;function&lt;/span&gt;(eventName, eventData) {
    &lt;span style=&quot;color: #0000ff&quot;&gt;var&lt;/span&gt; txt = &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;.value.split(&#39;\n&#39;);
    &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (txt.&lt;span style=&quot;color: #0000ff&quot;&gt;length&lt;/span&gt; &amp;gt; 9)
      txt = txt.slice(-9);
    txt.push(eventData);
    &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;.value = txt.join(&#39;\n&#39;);  
  } &lt;span style=&quot;color: #008000&quot;&gt;// _log&lt;/span&gt;
} &lt;span style=&quot;color: #008000&quot;&gt;// chatlogBehavior&lt;/span&gt;
OpenAjax.hub.registerLibrary(&quot;&lt;span style=&quot;color: #8b0000&quot;&gt;chatlogBehavior&lt;/span&gt;&quot;, &quot;&lt;span style=&quot;color: #8b0000&quot;&gt;http://www.mathertel.de/OpenAjax/chatlogBehavior&lt;/span&gt;&quot;);
jcl.LoadBehaviour(&quot;&lt;span style=&quot;color: #8b0000&quot;&gt;chatlog&lt;/span&gt;&quot;, chatlogBehavior);&lt;/pre&gt;
&lt;p&gt;Implementing these 2 components a &quot;local&quot; chat applications ready to run. 
&lt;p&gt;The third component is the hub extender that is invisible and is introduced above. The complete source code of the page can be seen here: 
&lt;p&gt;&lt;a title=&quot;http://www.mathertel.de/AJAXEngine/ViewSrc.aspx?file=S06_AJAXForms/OpenAjaxChat.aspx&quot; href=&quot;http://www.mathertel.de/AJAXEngine/ViewSrc.aspx?file=S06_AJAXForms/OpenAjaxChat.aspx&quot;&gt;http://www.mathertel.de/AJAXEngine/ViewSrc.aspx?file=S06_AJAXForms/OpenAjaxChat.aspx&lt;/a&gt; 
&lt;p&gt;and you can see the sample live at: 
&lt;p&gt;&lt;a title=&quot;http://www.mathertel.de/AJAXEngine/S06_AJAXForms/OpenAjaxChat.aspx&quot; href=&quot;http://www.mathertel.de/AJAXEngine/S06_AJAXForms/OpenAjaxChat.aspx&quot;&gt;http://www.mathertel.de/AJAXEngine/S06_AJAXForms/OpenAjaxChat.aspx&lt;/a&gt; 
&lt;p&gt;&amp;nbsp; 
&lt;p&gt;If you are interested in the web service implementation the source is available here: 
&lt;p&gt;&lt;a title=&quot;http://www.mathertel.de/AJAXEngine/ViewSrc.aspx?file=S06_AJAXForms/OpenAjaxChat.asmx&quot; href=&quot;http://www.mathertel.de/AJAXEngine/ViewSrc.aspx?file=S06_AJAXForms/OpenAjaxChat.asmx&quot;&gt;http://www.mathertel.de/AJAXEngine/ViewSrc.aspx?file=S06_AJAXForms/OpenAjaxChat.asmx&lt;/a&gt; 
&lt;h3&gt;Discussion &lt;/h3&gt;
&lt;p&gt;The sample above shows how easy it is to extend a hub into other browser windows by not extending the API but by adding a component that does the job.&lt;br&gt;The huge advantage with this approach is that the additional functionality is strictly separated from the core implementation is and encapsulated into it&#39;s own JavaScript file. Therefore it is an optional component and will be not part of the download if not needed in a specific application. 
</content><link rel='replies' type='application/atom+xml' href='http://ajaxaspects.blogspot.com/feeds/2346477243866184949/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7581919&amp;postID=2346477243866184949' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/2346477243866184949'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/2346477243866184949'/><link rel='alternate' type='text/html' href='http://ajaxaspects.blogspot.com/2007/08/extending-openajax-hub.html' title='Extending the OpenAjax hub'/><author><name>Matthias Hertel</name><uri>https://plus.google.com/116098072736241499757</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-M0Om2hGPjV8/AAAAAAAAAAI/AAAAAAAAAOs/F8uLY205io8/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7581919.post-6032849254855411014</id><published>2007-08-05T23:13:00.001+02:00</published><updated>2007-08-20T20:35:05.461+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Ajax"/><category scheme="http://www.blogger.com/atom/ns#" term="AJAXEngine"/><category scheme="http://www.blogger.com/atom/ns#" term="Behaviors"/><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript"/><category scheme="http://www.blogger.com/atom/ns#" term="OpenAjax"/><title type='text'>Using the OpenAjax hub</title><content type='html'>&lt;h3&gt;What&#39;s the problem ? &lt;/h3&gt; &lt;p&gt;On the client side it is a common scenario that multiple independent developed&amp;nbsp;controls have to be linked together.&lt;/p&gt; &lt;p&gt;Let&#39;s think about a web application that consists of several pages that all should share some common functionality, let&#39;s say a button that pops up a calendar to pick up a date.&lt;br&gt;Its a good idea to separate this kind of functionality into a separate JavaScript include file and a web control or tag library to make it reusable. &lt;/p&gt; &lt;p&gt;Well it&#39;s not always the same implementation we need because sometimes the field, that holds the that is named &quot;shipping day&quot;, &quot;birthday&quot;, &quot;reply until&quot; or any other and sometime there is more than one field on the same page.&lt;br&gt;Coding the name of the field into the common files seems not to be a good idea.&lt;br&gt;And it can be worse if there is not only a calendar button and a single field that needs to be connected but there might be also other fields foe example showing the duration between the 2 dates or even some validation functionality. All these &quot;components&quot; need to be linked together.  &lt;h3&gt;How links components ? &lt;/h3&gt; &lt;p&gt;Hard-coding the IDs of the html elements into the JavaScript code is a bad idea that you can see often in JavaScript . A better idea (for the first sight) is to use attributes on the html elements that contain the IDs of the other elements. For example you can add a &quot;targetControlID&quot; to the calendar popUp and set it to the id of the field.&lt;br&gt;Sounds good, but it&#39;s still limited to be used for the scenario where more than one&amp;nbsp;component needs to be attached to another.&lt;/p&gt; &lt;p&gt;Another idea is to link these components together by using a global available eventing mechanism where it is possible to publish events with values and to register for events on the other side.&lt;/p&gt; &lt;p&gt;Firing events means that one component that has detected a new situation or data constellation can make this available to all other listening&amp;nbsp;components but without knowing if there are any. This results in scripts that are really independent of each other and can be reused in other pages where other constellations are present. Every component that is part of a specific use case can plug itself into the scenario.&lt;/p&gt; &lt;p&gt;That&#39;s the idea of the OpenAjax hub specification. &lt;/p&gt; &lt;h3&gt;Using the OpenAjax hub to loosely couple components&lt;/h3&gt; &lt;p&gt;The 2 main methods the hub specification offers are publish and subscribe -- simple but powerful. (The third defined method is unsubscribe).&lt;br&gt;Publishing is just as easy than calling a method of another component and the result is that all components (if there are any) that are interested in the event will be called.&lt;br&gt;To separate different events from each other and to specify the meaning of an event, each event needs a unique identifier that is build by using a namespace and local name.&lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;OpenAjax.hub.publish(&quot;&lt;span style=&quot;color: #8b0000&quot;&gt;de.mathertel.openajax.tasksample.startdate&lt;/span&gt;&quot;, &quot;&lt;span style=&quot;color: #8b0000&quot;&gt;2007.08.05&lt;/span&gt;&quot;);
OpenAjax.hub.publish(&quot;&lt;span style=&quot;color: #8b0000&quot;&gt;de.mathertel.openajax.tasksample.enddate&lt;/span&gt;&quot;, &quot;&lt;span style=&quot;color: #8b0000&quot;&gt;2007.08.12&lt;/span&gt;&quot;);&lt;/pre&gt;
&lt;p&gt;These samples will tell all subscribers that the values have been changed. The new values are sent together with the event notifications. &lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;OpenAjax.hub.subscribe(&quot;&lt;span style=&quot;color: #8b0000&quot;&gt;de.mathertel.openajax.tasksample.*&lt;/span&gt;&quot;, &quot;&lt;span style=&quot;color: #8b0000&quot;&gt;calc&lt;/span&gt;&quot;, document.getElementById(&quot;&lt;span style=&quot;color: #8b0000&quot;&gt;duration&lt;/span&gt;&quot;));&lt;/pre&gt;
&lt;p&gt;Using the subscribe method this way will cause that the calc method of the duration field will be called each time a event of the namespace de.mathertel.openajax.tasksample is published. 
&lt;p&gt;This sample only shows some main aspects about the OpenAjax hub only. You can find the complete specification on the OpenAjax web site (see links below). 
&lt;h3&gt;Implementing a sample page&lt;/h3&gt;
&lt;p&gt;To show how to work with the OpenAjax hub implementation a sample page with a hypothetic task definition is used. The only aspects we have a look at are the start and end dates of this task and some more components around.&lt;br&gt;To keep the sample as simple as possible only one date notation is allowed: &quot;yyyy.mm.dd&quot;. Keep that in mind, if you play around with the sample. 
&lt;p&gt;First of course we need a OpenAjax hub implementation. You can get the one from the reference implementation (see links below) or use the smaller one that comes with the JavaScript Common behavior library of the AjaxEngine Open source project. This one is also used in the samples implementation you can try out at&amp;nbsp; &lt;br&gt;&lt;a href=&quot;http://www.mathertel.de/AJAXEngine/S06_AJAXForms/TaskSample1.aspx&quot;&gt;http://www.mathertel.de/AJAXEngine/S06_AJAXForms/TaskSample1.aspx&lt;/a&gt; 
&lt;p&gt;Here is the include statement: &lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #800000&quot;&gt;script&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;src&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&quot;../controls/jcl.js&quot;&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;type&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&quot;text/javascript&quot;&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #800000&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;The sample also contains 2 fields (startdate and enddate).&lt;br&gt;Another readonly field (duration) is used to display the duration of the hypothetic task.&lt;br&gt;A third and invisible component is also included in the page and this component will take care of the fact that the start date cannot be in the past. 
&lt;h3&gt;Implementing the input fields &lt;/h3&gt;
&lt;p&gt;The fields we use here are just regular input fields that are extended by some JavaScript: &lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;&lt;p&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;var&lt;/span&gt; fieldBehavior = {
&lt;span style=&quot;color: #008000&quot;&gt;  // after loading the page the other components should know about the current value.&lt;/span&gt;
&amp;nbsp; afterinit: &lt;span style=&quot;color: #0000ff&quot;&gt;function&lt;/span&gt; () {
&amp;nbsp;&amp;nbsp;&amp;nbsp; OpenAjax.hub.publish(&quot;&lt;span style=&quot;color: #8b0000&quot;&gt;de.mathertel.openajax.tasksample.&lt;/span&gt;&quot; + &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;.id, &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;.value);
&amp;nbsp; }, &lt;span style=&quot;color: #008000&quot;&gt;// init &lt;/span&gt;
&lt;span style=&quot;color: #008000&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: #008000&quot;&gt;&lt;/span&gt; &lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: #008000&quot;&gt;  // when leaving the field the new, changed value must be published.&lt;/span&gt;
  onchange: &lt;span style=&quot;color: #0000ff&quot;&gt;function&lt;/span&gt; (evt) {
    OpenAjax.hub.publish(&quot;&lt;span style=&quot;color: #8b0000&quot;&gt;de.mathertel.openajax.tasksample.&lt;/span&gt;&quot; + &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;.id, &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;.value);
  }, &lt;span style=&quot;color: #008000&quot;&gt;// onchange&lt;/span&gt;
&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt;} &lt;span style=&quot;color: #008000&quot;&gt;// fieldBehavior&lt;/span&gt;
jcl.LoadBehaviour(&quot;&lt;span style=&quot;color: #8b0000&quot;&gt;startdate&lt;/span&gt;&quot;, fieldBehavior);
jcl.LoadBehaviour(&quot;&lt;span style=&quot;color: #8b0000&quot;&gt;enddate&lt;/span&gt;&quot;, fieldBehavior); &lt;/p&gt;&lt;/pre&gt;
&lt;p&gt;After the page and all components have been loaded the current value of each field is published around so all other components know about it. When the value is changed through editing the event is published again.&lt;br&gt;I hope it is understandable what how the script works. &lt;br&gt;The way the script is bound the the 2 fields is part of the JavaScript Behavior mechanism that is not part of the OpenAjax specification. You can find how it works in some older posts on this block. 
&lt;h3&gt;Implementing the duration field &lt;/h3&gt;
&lt;p&gt;Again a regular input field is used to display the duration of the hypothetic task. The script for this field is a little bit different and also uses the OpenAjax hub mechanism. &lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;var&lt;/span&gt; durationBehavior = {
  _startDate: &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;,
  _endDate: &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;,
    
  init: &lt;span style=&quot;color: #0000ff&quot;&gt;function&lt;/span&gt;() {
    OpenAjax.hub.subscribe(&quot;&lt;span style=&quot;color: #8b0000&quot;&gt;de.mathertel.openajax.tasksample.*&lt;/span&gt;&quot;, &quot;&lt;span style=&quot;color: #8b0000&quot;&gt;calc&lt;/span&gt;&quot;, &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;);
  }, &lt;span style=&quot;color: #008000&quot;&gt;// init&lt;/span&gt;
    
  calc: &lt;span style=&quot;color: #0000ff&quot;&gt;function&lt;/span&gt; (propName, propData, regData) {
    &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (propName == &quot;&lt;span style=&quot;color: #8b0000&quot;&gt;de.mathertel.openajax.tasksample.startdate&lt;/span&gt;&quot;)
      &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._startDate = propData;
    &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (propName == &quot;&lt;span style=&quot;color: #8b0000&quot;&gt;de.mathertel.openajax.tasksample.enddate&lt;/span&gt;&quot;)
      &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._endDate = propData;

    &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; ((&lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._startDate != &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;) &amp;amp;&amp;amp; (&lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._endDate != &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;)) {
      &lt;span style=&quot;color: #0000ff&quot;&gt;var&lt;/span&gt; da = &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._startDate.split(&#39;.&#39;);
      &lt;span style=&quot;color: #0000ff&quot;&gt;var&lt;/span&gt; sd = &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;Date&lt;/span&gt;(da[0], da[1], da[2]);
      da = &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._endDate.split(&#39;.&#39;);
      &lt;span style=&quot;color: #0000ff&quot;&gt;var&lt;/span&gt; ed = &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;Date&lt;/span&gt;(da[0], da[1], da[2]);
      &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;.value = (ed - sd) / (60*60*24*1000);
    }
  } &lt;span style=&quot;color: #008000&quot;&gt;// calc&lt;/span&gt;
} &lt;span style=&quot;color: #008000&quot;&gt;// durationBehavior&lt;/span&gt;
jcl.LoadBehaviour(&quot;&lt;span style=&quot;color: #8b0000&quot;&gt;duration&lt;/span&gt;&quot;, durationBehavior);&lt;/pre&gt;
&lt;p&gt;The init method subscribes to all events that are published in the namespace I use in this sample. In this case the specific name of an event&amp;nbsp;must be analyzed within the subscription method and because of that is passed as a parameter too.&amp;nbsp;&amp;nbsp; 
&lt;h3&gt;Implementing the validation &lt;/h3&gt;
&lt;p&gt;The validation code is just registering the for startdate event and is checking the date value. If it&#39;s not a date an alert box is shown - that&#39;s all. &lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: #008000&quot;&gt;// a validator function to the startdate&lt;/span&gt;
&lt;span style=&quot;color: #0000ff&quot;&gt;function&lt;/span&gt; validate(propName, propData, regData) {
  &lt;span style=&quot;color: #0000ff&quot;&gt;var&lt;/span&gt; da;
  &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (propData != &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;) {
    da = propData.split(&#39;.&#39;);
    &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (da.&lt;span style=&quot;color: #0000ff&quot;&gt;length&lt;/span&gt; != 3) {
      &lt;span style=&quot;color: #0000ff&quot;&gt;alert&lt;/span&gt;(propData + &quot;&lt;span style=&quot;color: #8b0000&quot;&gt; is not a date value formatted yyyy.mm.dd&lt;/span&gt;&quot;);
    } &lt;span style=&quot;color: #0000ff&quot;&gt;else&lt;/span&gt; {
      &lt;span style=&quot;color: #0000ff&quot;&gt;var&lt;/span&gt; d = &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;Date&lt;/span&gt;(da[0], da[1], da[2]);
      &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (d.&lt;span style=&quot;color: #0000ff&quot;&gt;valueOf&lt;/span&gt;() &amp;lt; (&lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;Date&lt;/span&gt;()).&lt;span style=&quot;color: #0000ff&quot;&gt;valueOf&lt;/span&gt;())
        &lt;span style=&quot;color: #0000ff&quot;&gt;alert&lt;/span&gt;(propData + &quot;&lt;span style=&quot;color: #8b0000&quot;&gt; is not a date in the past.&lt;/span&gt;&quot;);
    } &lt;span style=&quot;color: #008000&quot;&gt;// if&lt;/span&gt;
  } &lt;span style=&quot;color: #008000&quot;&gt;// if&lt;/span&gt;
}; &lt;span style=&quot;color: #008000&quot;&gt;// validate&lt;/span&gt;
OpenAjax.hub.subscribe(&quot;&lt;span style=&quot;color: #8b0000&quot;&gt;de.mathertel.openajax.tasksample.startdate&lt;/span&gt;&quot;, validate);&lt;/pre&gt;
&lt;p&gt;&amp;nbsp; 
&lt;h3&gt;Extending the OpenAjax hub &lt;/h3&gt;
&lt;p&gt;As you&#39;ve seen the mechanism of the OpenAjax hub is really powerful and helps connecting components on a page without hard-coding the ids into the JavaScript code.&lt;br&gt;But there are still some minor topics undone. 
&lt;p&gt;&lt;strong&gt;1. initial events&lt;/strong&gt; 
&lt;p&gt;After loading the page every component might have to publish the initial value to all the other components to make them know about the value. This cannot be done in an onload script because then it will depend on the initialization order of the components what components will receive the event. 
&lt;p&gt;The current OpenAjax hub specifications seems to have the understanding that events are used after the page has been loaded. I think the mechanism is also good to be used in the phase of the page loading but there is no suitable specification for this right now. The init and afterinit methods in the JavaScript Behavior implementation can help on this. 
&lt;p&gt;&lt;strong&gt;2. saving&amp;nbsp;latest values&lt;/strong&gt; 
&lt;p&gt;When events are published a component that needs to know about the values of several other events and has to combine them always has to collect this information on its own as you can see in the implementation of the duration field. 
&lt;p&gt;I think that this is a common scenario and can be supported in a general way too. 
&lt;p&gt;&lt;strong&gt;3. nesting events&lt;/strong&gt; 
&lt;p&gt;The third issue I see is that the code that is started by a published event should not start another event.&lt;br&gt;Think about the validation functionality above. If a start date in the past is detected it would be easy to publish the current date as a substitute. The problem then is that other components will get the event once with the older value and once with the newer value. The order of these events is not deterministic and it might occur that the older value will be published to a component after the newer value. 
&lt;h3&gt;Links: &lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;http://sourceforge.net/projects/ajaxengine&quot;&gt;http://sourceforge.net/projects/ajaxengine&lt;/a&gt;&lt;br&gt;&amp;nbsp; The open source AjaxEngine project, including a public subversion repository. 
&lt;p&gt;&lt;a href=&quot;http://www.mathertel.de/AJAXEngine/&quot;&gt;http://www.mathertel.de/AJAXEngine/&lt;/a&gt; 
&lt;p&gt;&amp;nbsp; The AjaxEngine project live with samples and documentation. 
&lt;p&gt;&lt;a href=&quot;http://www.mathertel.de/AJAXEngine/controls/jcl.js&quot;&gt;http://www.mathertel.de/AJAXEngine/controls/jcl.js&lt;/a&gt;&lt;br&gt;&amp;nbsp; The JavaScript Common behaviors library containing a second source OpenAjax implementation. 
&lt;p&gt;&lt;a href=&quot;http://www.openajax.org&quot;&gt;http://www.openajax.org&lt;/a&gt;&lt;br&gt;&amp;nbsp; Here you can find all the white papers and the specifications. 
&lt;p&gt;&lt;a href=&quot;http://sourceforge.net/projects/openajaxallianc&quot;&gt;http://sourceforge.net/projects/openajaxallianc&lt;/a&gt;&lt;br&gt;&amp;nbsp; Here you can find the reference implementation of the hub.&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://ajaxaspects.blogspot.com/feeds/6032849254855411014/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7581919&amp;postID=6032849254855411014' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/6032849254855411014'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/6032849254855411014'/><link rel='alternate' type='text/html' href='http://ajaxaspects.blogspot.com/2007/08/using-openajax-hub.html' title='Using the OpenAjax hub'/><author><name>Matthias Hertel</name><uri>https://plus.google.com/116098072736241499757</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-M0Om2hGPjV8/AAAAAAAAAAI/AAAAAAAAAOs/F8uLY205io8/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7581919.post-3682677196188946122</id><published>2007-07-26T23:04:00.001+02:00</published><updated>2007-07-26T23:04:56.966+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Ajax"/><category scheme="http://www.blogger.com/atom/ns#" term="controls"/><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript"/><category scheme="http://www.blogger.com/atom/ns#" term="OpenAjax"/><category scheme="http://www.blogger.com/atom/ns#" term="webservice"/><title type='text'>Tree view Ajax control update</title><content type='html'>&lt;p&gt;The tree view control was introduced some time ago and some details of its implementation can be found at &lt;a title=&quot;http://ajaxaspects.blogspot.com/2006/01/tree-view-ajax-control.html&quot; href=&quot;http://ajaxaspects.blogspot.com/2006/01/tree-view-ajax-control.html&quot;&gt;http://ajaxaspects.blogspot.com/2006/01/tree-view-ajax-control.html&lt;/a&gt;&amp;nbsp;or in the book at &lt;a title=&quot;Aspects of Ajax book&quot; href=&quot;http://www.mathertel.de/AJAXEngine/documentation/AJAXeBook.aspx&quot;&gt;http://www.mathertel.de/AJAXEngine/documentation/AJAXeBook.aspx&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Now there is an update available and also a step by step sample how to use this control inside your web application.&lt;/p&gt; &lt;p&gt;The sample page can be found at: &lt;a title=&quot;http://www.mathertel.de/AJAXEngine/S03_AJAXControls/TreeView.aspx&quot; href=&quot;http://www.mathertel.de/AJAXEngine/S03_AJAXControls/TreeView.aspx&quot;&gt;http://www.mathertel.de/AJAXEngine/S03_AJAXControls/TreeView.aspx&lt;/a&gt;.&lt;/p&gt; &lt;h3&gt;1. Building a web service&lt;/h3&gt; &lt;p&gt;Using Ajax with a tree view control is based on the idea that the full data that builds a complete tree might have a size that cannot be downloaded to the browser in one time. The server therefore has to offer a method that enables downloading&amp;nbsp;fragments of&amp;nbsp;a hierarchic data structure exactly in that moment when the user opens a new sub tree.&lt;/p&gt; &lt;p&gt;The tree view Ajax control binds to a webservice with only one function &lt;strong&gt;GetSubNodes&lt;/strong&gt;(string &lt;strong&gt;path&lt;/strong&gt;) that has to be built for your specific solution. If you like you can also use a different name for the method.&lt;/p&gt; &lt;p&gt;The structure of the XML node that must be returned by this method looks like this:&lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;&lt;p&gt;&amp;lt;tree&amp;gt;
  &amp;lt;folder name=&quot;AK&quot; title=&quot;Alaska&quot;&amp;gt;&lt;br&gt;  &amp;lt;file title=&quot;Aguila&quot; name=&quot;ZIP85320&quot; link=&quot;http://weather.aol.com/main.adp?location=USAZ0001&quot;/&amp;gt;
  &amp;lt;file title=&quot;Ajo&quot; name=&quot;ZIP85920&quot; /&amp;gt;&lt;br&gt;  &amp;lt;file name=&quot;Redmond&quot; img=&quot;redfile&quot; /&amp;gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;  &amp;lt;file name=&quot;Alpine&quot; /&amp;gt;
  &amp;lt;file name=&quot;Yuma&quot; /&amp;gt;
&amp;lt;/tree&amp;gt;&lt;/p&gt;&lt;/pre&gt;
&lt;p&gt;The outer element must be a &amp;lt;tree&amp;gt; node that contains &amp;lt;folder&amp;gt; and &amp;lt;file&amp;gt; nodes.&lt;/p&gt;
&lt;p&gt;As you can see the &lt;strong&gt;name &lt;/strong&gt;attributes do have a special&amp;nbsp;purpose in this structure&amp;nbsp;because the values of these nodes together and separated by slashes&amp;nbsp;will build a &lt;strong&gt;path&lt;/strong&gt; to each available element for example &quot;/AZ/Ash Fork&quot;.&lt;/p&gt;
&lt;p&gt;When clicking onto folders and files this path will be used for loading&amp;nbsp;a subtree or for the events that are published when a final &amp;lt;file&amp;gt; node is clicked.&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;title &lt;/strong&gt;attribute is optional. Its text will be displayed behind the icon. If it&#39;s not present the name will be used instead.&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;link &lt;/strong&gt;attribute can be used when a click on a final node should just open a regular hyperlink.&lt;/p&gt;
&lt;p&gt;When there is no link present on&amp;nbsp;a file node an &lt;strong&gt;OpenAjax event&amp;nbsp;&lt;/strong&gt;&quot;de.mathertel.treeview.click&quot; with the path of the node in the data is published. You can register to this event for catch all clicks if no navigation is required.&lt;/p&gt;
&lt;p&gt;You can find a webservice implementation &lt;a href=&quot;http://localhost:1490/AJAXEngine/ViewSrc.aspx?file=~/S03_AJAXControls/TreeView.asmx&quot;&gt;here&lt;/a&gt;&amp;nbsp;and &lt;a href=&quot;http://localhost:1490/AJAXEngine/ViewSrc.aspx?file=~/S03_AJAXControls/BibleData.asmx&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Having built such a web service most of the work is done. 
&lt;h3&gt;2. importing the webservice&lt;/h3&gt;
&lt;p&gt;The webservice must be made available on the page containing the Ajax tree view control by using a simple JavaScript include: &lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;&lt;p&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #800000&quot;&gt;script&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;type&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&quot;text/javascript&quot;&lt;/span&gt;&lt;br&gt;&lt;font style=&quot;background-color: #ffff99&quot;&gt;   &lt;/font&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;src&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&quot;../ajaxcore/GetJavaScriptProxy.aspx?service=../S03_AJAXControls/TreeView.asmx&quot;&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #800000&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/pre&gt;
&lt;p&gt;Now the webservice is available through the proxies.TreeView object and the GetSubNodes method can be&amp;nbsp;called by using the generated proxies.TreeView.GetSubNodes() function.&lt;/p&gt;
&lt;h3&gt;3. embedding the Ajax tree view control&lt;/h3&gt;
&lt;p&gt;The control is implemented as a user control in the file ~/controls/TreeView.ascx. If you use Visual Studio 2005 you can drag this file onto a page and the control will be registered for this page or you can register the control by using a @Register tag at the beginning of the page:&lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;%@ Register Src=&quot;../controls/TreeView.ascx&quot; TagName=&quot;TreeView&quot; TagPrefix=&quot;ajax&quot; %&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;The other way to register a user control is putting an option into the web.config file. This is the better solution if you want to reuse the control on multiple pages and like to use the same prefix all over the web application.&lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #800000&quot;&gt;configuration&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #0000ff&quot;&gt;  &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #800000&quot;&gt;system.web&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #0000ff&quot;&gt;    &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #800000&quot;&gt;pages&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #0000ff&quot;&gt;      &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #800000&quot;&gt;controls&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt; 
&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #800000&quot;&gt;add&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;src&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&quot;~/controls/TreeView.ascx&quot;&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;tagName&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&quot;TreeView&quot;&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;tagPrefix&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&quot;ajax&quot;&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;The control itself can be used now:&amp;nbsp;&lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #c71585&quot;&gt;ajax&lt;/span&gt;:&lt;span style=&quot;color: #800000&quot;&gt;TreeView&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;ID&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&quot;TreeView1&quot;&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;runat&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&quot;server&quot;&lt;/span&gt; &lt;br&gt;&amp;nbsp; &lt;span style=&quot;color: #ff0000&quot;&gt;service&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&quot;proxies.TreeView.GetSubNodes&quot;&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;title&lt;/span&gt;=&lt;span style=&quot;color: #0000ff&quot;&gt;&quot;Cities in the USA&quot;&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;You can see&amp;nbsp;the complete source of the page by using this link: [&lt;a title=&quot;View Source&quot; href=&quot;http://www.mathertel.de/AJAXEngine/ViewSrc.aspx?file=~/S03_AJAXControls/TreeView.aspx&quot;&gt;view source of TreeView.aspx&lt;/a&gt;].&lt;/p&gt;
&lt;h3&gt;4. CSS and&amp;nbsp;specific icons&lt;/h3&gt;
&lt;p&gt;Some tree view might not only&amp;nbsp;use folders and files so there is a special feature for that too. 
&lt;p&gt;The CSS code that is used by the tree view control is shown here:&lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;div.TreeView .du {height:18px;overflow:hidden;cursor:hand; &lt;br&gt;&amp;nbsp; background-image:url(controls/images/dc.png);background-repeat:no-repeat}
div.TreeView .do {height:18px;overflow:hidden;cursor:hand;&lt;br&gt;&amp;nbsp; background-image:url(controls/images/do.png);background-repeat:no-repeat}
div.TreeView .dc {height:18px;overflow:hidden;cursor:hand;&lt;br&gt;&amp;nbsp; background-image:url(controls/images/dc.png);background-repeat:no-repeat}
div.TreeView .de {height:18px;overflow:hidden;&lt;br&gt;  background-image:url(controls/images/de.png);background-repeat:no-repeat}
div.TreeView .fl {height:18px;overflow:hidden;&lt;br&gt;  background-image:url(controls/images/file.png);background-repeat:no-repeat}
div.TreeView .ft {padding-left:40px}
div.TreeView .subframe {margin-left:18px;}&lt;/pre&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Using these short classnames for attaching the style results in small html code fragments and you can link to the right images just by modifying the style rules. I put this baseline definition into the main css include file of the web application.&lt;/p&gt;
&lt;p&gt;By specifying the img attribute on a file node in the data that is returned from the server another classname can be included&amp;nbsp;for the ft-class elements. To avoid individual image tags in the tree view this classname extension also is handled by using a style rule that you can add:&lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: #800000&quot;&gt;div&lt;/span&gt;.&lt;span style=&quot;color: #800000&quot;&gt;TreeView&lt;/span&gt; .&lt;span style=&quot;color: #800000&quot;&gt;fl&lt;/span&gt;.&lt;span style=&quot;color: #800000&quot;&gt;redfile&lt;/span&gt; {&lt;span style=&quot;color: #ff0000&quot;&gt;background-image&lt;/span&gt;:url(../controls/images/redfile.png)}&lt;/pre&gt;
&lt;p&gt;This definition can be found in the sample page itself but you can also put it into the mail css include file if you like. Search for Redmond(WA) to see it work.&lt;/p&gt;
&lt;h3&gt;5. handling the events&lt;/h3&gt;
&lt;p&gt;If you just like to show information in a tree fashion and like to use hyperlinks on the&amp;nbsp;file nodes&amp;nbsp;you don&#39;t need to have a look at the eventing system that is also built in.&lt;/p&gt;
&lt;p&gt;When clicking a&amp;nbsp;file node and if there is no hyperlink set then the tree view controls publishes an event that event handlers can catch. The eventing system that is used here is the &lt;a href=&quot;http://www.openajax.org/&quot;&gt;OpenAjax&lt;/a&gt;&amp;nbsp;compatible event hub. You can find the documentation about it on the &lt;a href=&quot;http://www.OpenAjax.org&quot;&gt;http://www.OpenAjax.org&lt;/a&gt; site and the implementation is part of the ~/controls/jcl.js file that is included automatically.&lt;/p&gt;
&lt;p&gt;To register for such an event you need a little bit of JavaScript code:&lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: #008000&quot;&gt;// a function that will catch the tree events by listening to de.mathertel.treeview.**.&lt;/span&gt;
&lt;span style=&quot;color: #0000ff&quot;&gt;function&lt;/span&gt; showTreeEvent(&lt;span style=&quot;color: #0000ff&quot;&gt;name&lt;/span&gt;, data) {
  &lt;span style=&quot;color: #0000ff&quot;&gt;alert&lt;/span&gt;(&quot;&lt;span style=&quot;color: #8b0000&quot;&gt;click on &lt;/span&gt;&quot; + data);
} &lt;span style=&quot;color: #008000&quot;&gt;// showTreeEvent&lt;/span&gt;

OpenAjax.hub.subscribe(&quot;&lt;span style=&quot;color: #8b0000&quot;&gt;de.mathertel.treeview.**&lt;/span&gt;&quot;, showTreeEvent);&lt;/pre&gt;
&lt;p&gt;The OpenAjax.hub.subscribe is registering the showTreeEvent function and this function will be passed the name of the event and the path in the data payload.&lt;/p&gt;
&lt;h3&gt;About the updated features&lt;/h3&gt;
&lt;p&gt;New to the current implementation is the support for the link attribute in the &amp;lt;file&amp;gt; elements and the publishing of events when clicking final nodes.&lt;/p&gt;
&lt;p&gt;If you want to see&amp;nbsp;more features or want to have more supported scenarios then let me know by using the&amp;nbsp;feature request function on &lt;a title=&quot;http://sourceforge.net/projects/ajaxengine/&quot; href=&quot;http://sourceforge.net/projects/ajaxengine/&quot;&gt;http://sourceforge.net/projects/ajaxengine/&lt;/a&gt;.&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://ajaxaspects.blogspot.com/feeds/3682677196188946122/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7581919&amp;postID=3682677196188946122' title='4 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/3682677196188946122'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/3682677196188946122'/><link rel='alternate' type='text/html' href='http://ajaxaspects.blogspot.com/2007/07/tree-view-ajax-control-update.html' title='Tree view Ajax control update'/><author><name>Matthias Hertel</name><uri>https://plus.google.com/116098072736241499757</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-M0Om2hGPjV8/AAAAAAAAAAI/AAAAAAAAAOs/F8uLY205io8/s512-c/photo.jpg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7581919.post-8622255036504084260</id><published>2007-07-07T22:33:00.001+02:00</published><updated>2007-07-07T22:37:02.430+02:00</updated><title type='text'>AjaxEngine is now on sourceforge.net</title><content type='html'>&lt;p&gt;You can now find a repository with the current version of the AjaxEngine, including the samples on &lt;/p&gt; &lt;p&gt;sourceforge at &amp;nbsp;&lt;a title=&quot;http://sourceforge.net/projects/ajaxengine/&quot; href=&quot;http://sourceforge.net/projects/ajaxengine/&quot;&gt;http://sourceforge.net/projects/ajaxengine/&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;There are some real great advantages by using a public community site:&lt;/p&gt; &lt;h3&gt;discussions and bug tracking&lt;/h3&gt; &lt;p&gt;I plan to use the bug tracking and forum tools and hope you&#39;ll find this helpful too.&lt;/p&gt; &lt;h3&gt;repository&lt;/h3&gt; &lt;p&gt;I was using subversion all over the last years on my local site so it was easy to switch to a public server.&lt;/p&gt; &lt;p&gt;You can now find the latest stable version (1.2) and the current work in progress also there:&lt;/p&gt; &lt;p&gt;&lt;a title=&quot;Link to the subversion repository by using the Tortoise client&quot; href=&quot;tsvn:https://ajaxengine.svn.sourceforge.net/svnroot/ajaxengine&quot;&gt;tsvn:https://ajaxengine.svn.sourceforge.net/svnroot/ajaxengine&lt;/a&gt;&lt;/p&gt; &lt;h3&gt;collaboration&lt;/h3&gt; &lt;p&gt;Another big advantage of an open community platform is that it makes working together really easy.&lt;/p&gt; &lt;p&gt;New Developers for the project are welcome !&lt;/p&gt; &lt;p&gt;Of course the existing web site &lt;a href=&quot;http://www.mathertel.de/AJAXEngine&quot;&gt;http://www.mathertel.de/AJAXEngine&lt;/a&gt; will remain active so you still can see all the samples live there.&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://ajaxaspects.blogspot.com/feeds/8622255036504084260/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7581919&amp;postID=8622255036504084260' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/8622255036504084260'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/8622255036504084260'/><link rel='alternate' type='text/html' href='http://ajaxaspects.blogspot.com/2007/07/ajaxengine-is-now-on-sourceforgenet.html' title='AjaxEngine is now on sourceforge.net'/><author><name>Matthias Hertel</name><uri>https://plus.google.com/116098072736241499757</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-M0Om2hGPjV8/AAAAAAAAAAI/AAAAAAAAAOs/F8uLY205io8/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7581919.post-4115148618557626927</id><published>2007-06-29T22:58:00.001+02:00</published><updated>2007-06-29T22:58:50.000+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Behaviors"/><category scheme="http://www.blogger.com/atom/ns#" term="Forms"/><category scheme="http://www.blogger.com/atom/ns#" term="Visual Effects"/><title type='text'>The fade effect and the DataFade control</title><content type='html'>&lt;p&gt;Here is a nice visual effect for data fields:&lt;/p&gt; &lt;p&gt;When&amp;nbsp;a&amp;nbsp;page&amp;nbsp;contains multiple values that might change from time to time it is&amp;nbsp;a good idea to&amp;nbsp;bring the users attention&amp;nbsp;to the&amp;nbsp;updated value. The DataFade implements this by&amp;nbsp;changing the background color of a field and fading it from yellow to the original background color that defined by the regular style.&lt;/p&gt; &lt;p&gt;The fading effect takes about a second and this is enough time for a human reader to focus the new field and reading the new value. The effect even seems to work if there are more values that are changed at the same time and it seems that the eyes can remember for some short time what fields have changed.&lt;/p&gt; &lt;p&gt;Here is a simple implementation using a horizontal scrollbar and a simple field.&lt;/p&gt; &lt;p&gt;&lt;a title=&quot;Fade Demo&quot; href=&quot;http://www.mathertel.de/AJAXEngine/S04_VisualEffects/FadeDemo.aspx&quot;&gt;http://www.mathertel.de/AJAXEngine/S04_VisualEffects/FadeDemo.aspx&lt;/a&gt;&lt;/p&gt; &lt;p&gt;When the DataFade control is initialized the actual background color is detected and stored in the local orgcolor field.&lt;/p&gt; &lt;p&gt;If the DataFade control detects that the value has changed it sets the background color to yellow and by starting a timer the background color is changed by smoothly adopting the red, green and blue to the original color that was found when the control was initialized. &lt;/p&gt; &lt;p&gt;The DataFade control is implemented using a JavaScript Behavior so it can be used inside AjaxForms&amp;nbsp;for displaying, but not entering values. This is because it is inheriting the DataOutput Behaviour it implements&amp;nbsp;a setData(newValue)&amp;nbsp;method that is detected by the ajaxForms implementation and is used for setting the new value.&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://ajaxaspects.blogspot.com/feeds/4115148618557626927/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7581919&amp;postID=4115148618557626927' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/4115148618557626927'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/4115148618557626927'/><link rel='alternate' type='text/html' href='http://ajaxaspects.blogspot.com/2007/06/fade-effect-and-datafade-control.html' title='The fade effect and the DataFade control'/><author><name>Matthias Hertel</name><uri>https://plus.google.com/116098072736241499757</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-M0Om2hGPjV8/AAAAAAAAAAI/AAAAAAAAAOs/F8uLY205io8/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7581919.post-6256357662286926098</id><published>2007-06-19T23:19:00.001+02:00</published><updated>2007-10-15T21:11:58.911+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Ajax"/><category scheme="http://www.blogger.com/atom/ns#" term="AJAXEngine"/><category scheme="http://www.blogger.com/atom/ns#" term="Behaviors"/><category scheme="http://www.blogger.com/atom/ns#" term="components"/><category scheme="http://www.blogger.com/atom/ns#" term="controls"/><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript"/><category scheme="http://www.blogger.com/atom/ns#" term="OpenAjax"/><category scheme="http://www.blogger.com/atom/ns#" term="SOAP"/><category scheme="http://www.blogger.com/atom/ns#" term="webservice"/><title type='text'>Aspects of OpenAjax</title><content type='html'>&lt;p&gt;You know I like standards.&lt;/p&gt; &lt;p&gt;Even if it is some kind of more complex to implement a solution based on a standard than using a direct and efficient but proprietary way, there are benefits on the long way that I just don&#39;t want to miss: the ideas and thoughts of others materialized in APIs, specifications and best practices.&lt;/p&gt; &lt;p&gt;That&#39;s why I use the SOAP standard webservice protocol for my Ajax implementations.&lt;/p&gt; &lt;h3&gt;OpenAjax&lt;/h3&gt; &lt;p&gt;Now &lt;a href=&quot;http://www.openajax.org/&quot; target=&quot;_blank&quot;&gt;OpenAjax Alliance&lt;/a&gt; is another try of a group of about 75 companies and organizations to define standards in the Ajax hemisphere. There are a lot of ideas and some good ideas too in the current discussions. We all know that it is hard to define a standard specification that gets agreed by the majority of the members. And it can take a long time until a standard proposal is adopted.&lt;/p&gt; &lt;p&gt;Right now a version 1.0 of the specifications are on their way and they contain some good stuff that I like to bring into the Aspects of Ajax framework and support an probably upcoming standard this way.&lt;/p&gt; &lt;p&gt;&lt;a title=&quot;http://www.openajax.org/member/wiki/OpenAjax_Hub_Specification&quot; href=&quot;http://www.openajax.org/member/wiki/OpenAjax_Hub_Specification&quot;&gt;http://www.openajax.org/member/wiki/OpenAjax_Hub_Specification&lt;/a&gt;&amp;nbsp;&lt;/p&gt; &lt;h3&gt;Libraries and Namespaces&lt;/h3&gt; &lt;p&gt;There is only one world we live in and there is only one global namespace in JavaScript. The problem is that multiple frameworks when used simultaneously in one page MUST use different global variable names, different namespaces when implementing XHTML and different prefixes and aliases for the namespaces. Especially the global names might cause a lot of problems.&lt;/p&gt; &lt;p&gt;Did you try to use 2 libraries that both register the $() function but implement it differently?&lt;/p&gt; &lt;p&gt;The OpenAjax registerLibrary and unregisterLibrary methods that can be used to help mastering this problem space.&lt;/p&gt; &lt;p&gt;The &lt;strong&gt;ajax, &lt;/strong&gt;the &lt;strong&gt;proxies&lt;/strong&gt; and the &lt;strong&gt;jcl&lt;/strong&gt; prefix will be used by the Aspects of Ajax framework because these are the names of the global variables I use (beside minor important stuff). I hope and pray that nobody else will use this prefix in any other AJAX framework. (I am the first - I won! :-)&lt;/p&gt; &lt;p&gt;No, and seriously: I don&#39;t like the global ajax variable being registered by any framework and right now I am not happy about this early (2005) decision any more.&lt;/p&gt; &lt;p&gt;The namespace used by the Aspects of Ajax frameworks will be &lt;strong&gt;de.mathertel&lt;/strong&gt; because &lt;a href=&quot;http://www.mathertel.de/AJAXEngine/&quot;&gt;http://www.mathertel.de/AJAXEngine/&lt;/a&gt; is the URL where the documentation and the samples can be found on the web.&lt;/p&gt; &lt;p&gt;... but maybe it&#39;s time to register a product name related web address :-)&lt;/p&gt; &lt;p&gt;When implementing a standalone AJAX framework you do not have to care about these problems. Being compatible (and friendly to other frameworks) can open a wide space in combining functionality from different sources.&lt;/p&gt; &lt;h3&gt;Events - inter controls connections&lt;/h3&gt; &lt;p&gt;Connecting multiple controls on a page by using JavaScript can be a nightmare because many little scripts will have to know about the existing other elements on the page. If you want to reuse generalized controls this situation becomes worse and if you like to reuse components of different manufacturers ... &lt;/p&gt; &lt;p&gt;So it&#39;s a good thing to define a common functionality that does the job and that controls can use to talk to each other using the well known subscribe and publish pattern and the idea of events.&lt;/p&gt; &lt;p&gt;The Aspects of Ajax framework has a small implementation since almost 2 years (see &lt;a href=&quot;http://ajaxaspects.blogspot.com/2005/09/connecting-controls.html&quot;&gt;http://ajaxaspects.blogspot.com/2005/09/connecting-controls.html&lt;/a&gt;) called &quot;page properties&quot; or data connections that also allows this kind of connectivity through the DataConnections object but compared with the event system of the OpenAjax hub specification there are some pros and cons.&lt;/p&gt; &lt;ol&gt; &lt;li&gt;The OpenAjax hub has defined an idea of namespaces and namespace notation like the namespace ideas known from .NET, Java and other environments. Events that are published are prefixed by a namespace so different providers of the same event name can be distinguished. The page properties of the Aspects of Ajax framework only had one global namespace (the page).  &lt;li&gt;Using the OpenAjax hub specifications it is possible to subscribe to specific events by specifying the long name of the event and by using a wildcards for registering to multiple events. In the Aspects of Ajax framework it was possible to subscribe to all events.  &lt;li&gt;The Aspects of Ajax framework has a mechanism that allows to poll for a current value of a prior published property change / event. The OpenAjax hub has no such methods defined but it is easy to implement an invisible control that logs all changes and offers some methods for getting the latest values.  &lt;li&gt;The Aspects of Ajax framework has some specific controls that helped while developing. One of them is a log of all events and the new values. Beside the changed implementation they also have a new parameter to specify what specific namespace they should watch.&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;Overall the OpenAjax implementation has some big advantages over the older DataConnections and the additional functionality can be added.&lt;/p&gt; &lt;h3&gt;Implementation&lt;/h3&gt; &lt;p&gt;The OpenAjax Alliance provides a &lt;a href=&quot;http://openajaxallianc.sourceforge.net/&quot; target=&quot;_blank&quot;&gt;reference implementation&lt;/a&gt; is available in an early version and other implementations of the specification are welcome. After reading the available specs and noticing that it is &quot;just&quot; better then my prior codings I decided to implement the specific details on my own and make them available in a standalone JavaScript file. Some requirements are implemented different than in the reference implementation and maybe you find the time to have a look at the difference if you like.&lt;/p&gt; &lt;h3&gt;The size of the implementation&lt;/h3&gt; &lt;p&gt;As of this writing the (unfinished) reference implementation is about 2801 bytes. The (current) implementation available on my side at &lt;a title=&quot;http://www.mathertel.de/OpenAjax&quot; href=&quot;http://www.mathertel.de/OpenAjax&quot;&gt;http://www.mathertel.de/OpenAjax&lt;/a&gt; is about 1300 bytes. Maybe my implementation is a little bit slower because I rely on regular expressions but I have not done any detailed measures yet. Both sizes are calculated by comparing a shrinked version using the tool from the dojo framework that is available online at &lt;a title=&quot;http://alex.dojotoolkit.org/shrinksafe/&quot; href=&quot;http://alex.dojotoolkit.org/shrinksafe/&quot;&gt;http://alex.dojotoolkit.org/shrinksafe/&lt;/a&gt;. This is because I don&#39;t want to compare the comment lines or different programming styles.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;The same implementation is also embedded into the &lt;a title=&quot;~/controls/jcl.js&quot; href=&quot;http://www.mathertel.de/AJAXEngine/ViewSrc.aspx?file=~/controls/jcl.js&quot; target=&quot;_blank&quot;&gt;jcl.js&lt;/a&gt; implementation that also implements the JavaScript Behavior mechanism.&lt;/p&gt; &lt;h3&gt;Future planning&lt;/h3&gt; &lt;p&gt;I will have a look for the specification of the OpenAjax Alliance hub and I will post a compatible version. It is just good to have a second source.&lt;/p&gt; &lt;p&gt;The Aspects of Ajax framework. including the SOAP client for web services in JavaScript will register itself and will use the hub implementation as a substitution of the older DataConnections implementation that will be removed completely.&lt;/p&gt; </content><link rel='replies' type='application/atom+xml' href='http://ajaxaspects.blogspot.com/feeds/6256357662286926098/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7581919&amp;postID=6256357662286926098' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/6256357662286926098'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/6256357662286926098'/><link rel='alternate' type='text/html' href='http://ajaxaspects.blogspot.com/2007/06/aspects-of-openajax.html' title='Aspects of OpenAjax'/><author><name>Matthias Hertel</name><uri>https://plus.google.com/116098072736241499757</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-M0Om2hGPjV8/AAAAAAAAAAI/AAAAAAAAAOs/F8uLY205io8/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7581919.post-4505038519586869373</id><published>2007-06-17T21:43:00.001+02:00</published><updated>2007-06-17T21:43:39.008+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Ajax"/><category scheme="http://www.blogger.com/atom/ns#" term="Behaviors"/><category scheme="http://www.blogger.com/atom/ns#" term="controls"/><category scheme="http://www.blogger.com/atom/ns#" term="Forms"/><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript"/><category scheme="http://www.blogger.com/atom/ns#" term="OpenAjax"/><category scheme="http://www.blogger.com/atom/ns#" term="SOAP"/><category scheme="http://www.blogger.com/atom/ns#" term="webservice"/><title type='text'>A simple page for displaying a record</title><content type='html'>&lt;p&gt;Building a page with a form to display and change a record is a common scenario and it should be easy to implement. Some of the basic ideas where already published last week and here is a concrete implementation. The page that can be found at &lt;a title=&quot;http://www.mathertel.de/AJAXEngine/S06_AJAXForms/SimpleReader.aspx&quot; href=&quot;http://www.mathertel.de/AJAXEngine/S06_AJAXForms/SimpleReader.aspx&quot;&gt;http://www.mathertel.de/AJAXEngine/S06_AJAXForms/SimpleReader.aspx&lt;/a&gt;&amp;nbsp;is&amp;nbsp; built by a combination of the 3 components:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;The &lt;a&gt;Form&lt;/a&gt;&amp;nbsp;contains &lt;a&gt;DataInput&lt;/a&gt; fields and other Data Contol elements that are used to display the values.  &lt;li&gt;The &lt;a&gt;Menubar&lt;/a&gt; is used to offer the typical buttons for searching and navigating through the dataset.  &lt;li&gt;The &lt;a&gt;DataSource&lt;/a&gt; control controls the binding between these controls and the server side web methods.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;img src=&quot;http://www.mathertel.de/AJAX/images/AjaxFormControls.png&quot;&gt;&lt;/p&gt; &lt;h3&gt;The Form element&lt;/h3&gt; &lt;p&gt;Many web applications need to display and modify relational data by using&amp;nbsp;a form and a offering a single record at each time. The form itself contains input fields to display the columns of the record and other html elements like labels or other static text around them.&lt;/p&gt; &lt;p&gt;All these elements together are held together by using a html container element that is called the form element. Because we handle all data mechanisms by using AJAX functionality we do not need a real &amp;lt;form&amp;gt; element but use a &amp;lt;div&amp;gt; element instead.&lt;/p&gt; &lt;p&gt;The functionality that is attached to&amp;nbsp;the form (the &amp;lt;div&amp;gt; element) of the page handles getting and setting values by respecting the correct formats for several datatypes and converting them to&amp;nbsp;regular xml data formats.&lt;/p&gt; &lt;p&gt;The great benefit from this approach is, that the server has to support only the standard xml format for the known datatypes and not any country or language specific formats. More on that in another post.&lt;/p&gt; &lt;p&gt;The functionality of the form element is implemented by using&amp;nbsp;the&amp;nbsp;&lt;a href=&quot;http://www.mathertel.de/AJAXEngine/ViewSrc.aspx?file=~/controls/DataForm.js&quot; target=&quot;_blank&quot;&gt;DataForm JavaScript Behavior&lt;/a&gt;&amp;nbsp;that is built reusing the functionality that was built in the early days in ajaxForms.js. By using a behavior the code was simplified and reduced.&lt;/p&gt; &lt;h3&gt;The Menubar element&lt;/h3&gt; &lt;p&gt;This element contains the typical buttons that enable the navigation through a set of records.&lt;/p&gt; &lt;p&gt;These buttons and icons will trigger&amp;nbsp;the corresponding methods of the datasource control by publishing events.&amp;nbsp;&lt;/p&gt; &lt;h3&gt;The DataSource control&lt;/h3&gt; &lt;p&gt;This element is not visible to the end user and is containing the main functionality to transfer the data from the server to the form element. It also contains a client side cursor model that help keeping state information away from the server.&lt;/p&gt; &lt;p&gt;The&amp;nbsp;following commands are available:&lt;/p&gt; &lt;p&gt;&lt;strong&gt;clear&lt;/strong&gt;: This command will just clear all the values inside the form.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;search&lt;/strong&gt;: A call to the server is&amp;nbsp;started to retrieve the keys of the found records. The current values of the form before the search is started are used as a template so you can easily find a specific record or a set of records. The retrieved keys are used to form the cursor.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;first&lt;/strong&gt;: The first record in the cursor is retrieved from the server and is displayed inside the form.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;next&lt;/strong&gt;: The next record in the cursor is retrieved from the server and is displayed inside the form.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;previous&lt;/strong&gt;: The previous record in the cursor is retrieved from the server and is displayed inside the form.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;last&lt;/strong&gt;: The last record in the cursor is retrieved from the server and is displayed inside the form.&lt;/p&gt; &lt;p&gt;(future extensions: add, update, delete, ...)&lt;/p&gt; &lt;p&gt;The DataSource element also publishes an event when the data of the form was changed to inform other elements on the page that a new situation is existing.&lt;/p&gt; &lt;h3&gt;Searching&amp;nbsp;and the AJAX calls in the background&lt;/h3&gt; &lt;p&gt;The &quot;search&quot; button in the menubar must be used first to build the dataset. This is done on the server by searching for all the records that match the criteria given by the current values in the form fields. This is done by using the SearchAction that is passed to the AJAXEngine to call the search method of the webservice. This method is returning a list of unique keys, each one representing a record.  &lt;p&gt;Here is a sample how to search:  &lt;p&gt;You can write &quot;UK&quot; into the country field and press &quot;search&quot; to search all records that have &quot;UK&quot; in the country colum. The database provider also offers the possibility to search using wildcards. If you enter &quot;U%&quot; into the country field you will find all the records with a country starting with &quot;U&quot;.  &lt;p&gt;After finding some data the dataset control automatically will fetch the first found record and will display in in the given form fields. This is done by using the DisplayAction that is passed to the AJAXEngine to call the fetch method of the webservice and passing the retrieved record data to the form.  &lt;p&gt;Using the arrow buttons you can step through the dataset. The clear button will clear the form without freeing the dataset but by loosing the current cursor position.  &lt;h3&gt;Events between the controls&lt;/h3&gt; &lt;p&gt;Connecting elements on the page might be done by using scripts&amp;nbsp;in one element that direct address the other element or by using events.  &lt;p&gt;Events like onclick and onload are already well known in the web development but they are limited to those events that are built into the DOM (Document Object Model). It is not possible to reuse this mechanism for other, self-built&amp;nbsp;events and another mechanism is needed for tasks&amp;nbsp;like this.  &lt;p&gt;The &lt;a href=&quot;http://www.openajax.org/&quot; target=&quot;_blank&quot;&gt;OpenAjax Alliance&lt;/a&gt;&amp;nbsp;is targeting this problem&amp;nbsp;with the &lt;a href=&quot;http://www.openajax.org/OpenAjax%20Hub.html&quot; target=&quot;_blank&quot;&gt;hub implementation&lt;/a&gt; that is&amp;nbsp;still under development for version 1.0.  &lt;p&gt;Inside jcl.js&amp;nbsp;(&lt;a href=&quot;http://www.mathertel.de/AJAXEngine/ViewSrc.aspx?file=~/controls/jcl.js&quot; target=&quot;_blank&quot;&gt;view source&lt;/a&gt;) you can now find a (almost) compatible version of the OpenAjax&amp;nbsp;specification that has only about 1300 bytes of real code. When the specification is finished I will release a compatible version and will follow the idea of a common functionality and compatibility of the Ajax frameworks. More on that in another post...&amp;nbsp;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://ajaxaspects.blogspot.com/feeds/4505038519586869373/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7581919&amp;postID=4505038519586869373' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/4505038519586869373'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7581919/posts/default/4505038519586869373'/><link rel='alternate' type='text/html' href='http://ajaxaspects.blogspot.com/2007/06/simple-page-for-displaying-record.html' title='A simple page for displaying a record'/><author><name>Matthias Hertel</name><uri>https://plus.google.com/116098072736241499757</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-M0Om2hGPjV8/AAAAAAAAAAI/AAAAAAAAAOs/F8uLY205io8/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry></feed>