<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>lekkimworld.comdojo</title>
    <link>http://lekkimworld.com/tags/dojo/</link>
    <description>IBM Lotus Notes/Domino, Websphere, IBM Connections, mobile, web, JavaScript, Java...</description>
    <language>en</language>
    <copyright>Mikkel Flindt Heisterberg (mh [at] intravision [dot] dk</copyright>
    <pubDate>Sat, 19 May 2012 06:50:25 GMT</pubDate>
    <dc:creator>Mikkel Flindt Heisterberg (mh [at] intravision [dot] dk</dc:creator>
    <dc:date>2012-05-19T06:50:25Z</dc:date>
    <dc:language>en</dc:language>
    <dc:rights>Mikkel Flindt Heisterberg (mh [at] intravision [dot] dk</dc:rights>
    <image>
      <title>lekkimworld.comdojo</title>
      <url>http://lekkimworld.com/tags/dojo/</url>
    </image>
    <item>
      <title>A (dojo.)mixin configuration approach to XAgents in XPages</title>
      <link>http://lekkimworld.com/2011/05/11/a_dojo_mixin_configuration_approach_to_xagents_in_xpages.html</link>
      <content:encoded>&lt;p&gt;
Continuing my XPages theme from yesterday I also wrote an XAgent base-class in JavaScript to make XAgents easier to do. Part of the base class is that it allows me to pass in a JSON object to configure the XAgent based on the need. Since the information I pass in should override the built-in defaults I needed a way to easily allow the user supplied values to override the defaults. The easiest way to do this would be to use the &lt;a href="http://dojotoolkit.org/reference-guide/dojo/mixin.html"&gt;dojo.mixin&lt;/a&gt;. 
&lt;pre&gt;&lt;i&gt;"dojo.mixin is a simple utility function for mixing objects 
together. Mixin combines two objects from right to left, 
overwriting the left-most object, and returning the newly 
mixed object for use."&lt;/i&gt;&lt;/pre&gt;
Unfortunately Dojo isn't available in SSJS I needed to do it myself. To my luck it was surprisingly easy as the below code illustrates.
&lt;/p&gt;
&lt;p&gt;
&lt;pre&gt;
// create function to allow mixin' two objects
var mixin = function(target, source) {
   if (!source) return;
      var name, s, i;
      for (name in source) {
      s = source[name];
      if (!(name in target) || (target[name] !== s)) {
         target[name] = s;
      }
   }
};
&lt;/pre&gt;
&lt;/p&gt;
&lt;p&gt;
My XAgent base class looks something like this:
&lt;pre&gt;
function XAGENT(args) {
   // create mixin function
   var mixin = function(target, source) {
      if (!source) return;
         var name, s, i;
         for (name in source) {
         s = source[name];
         if (!(name in target) || (target[name] !== s)) {
            target[name] = s;
         }
      }
   };

   // define default arguments
   this._args = {
      download: false,
      filename: "default.json",
      charset: "iso-8859-1",
      contentType: "application/json"
   };
   
   // mixin user-supplies arguments
   mixin(this._args, args);
};
XAGENT.prototype.run = function(command) {
   ...
};
&lt;/pre&gt;
&lt;/p&gt;
&lt;p&gt;
What's super neat is that now, in my run-method I can access the this._args object and all values that the user supplied have overridden the default values because we used the mixin-function. Very cool and an easy and flexible way to have default values but allowing them to be overridden by the caller. Also you know that the variables you need have been defined so no checks are necessary.
&lt;/p&gt;
&lt;p&gt;
Calling my XAgent class is very easy allowing me to override the defaults. The run-method accepts a function which is called when the XAgent stuff has been set up supplying the Writer and the parameters supplied in the URL as a JSON object. 
&lt;pre&gt;
var xa = new XAGENT({
   filename: "feed.json", 
   download: true
});
xa.run(function(w, params) {
   ...
});
&lt;/pre&gt;
&lt;/p&gt;</content:encoded>
      <category domain="http://lekkimworld.com/tags/dojo/">dojo</category>
      <category domain="http://lekkimworld.com/tags/javascript/">javascript</category>
      <category domain="http://lekkimworld.com/tags/xagent/">xagent</category>
      <category domain="http://lekkimworld.com/tags/xpages/">xpages</category>
      <pubDate>Wed, 11 May 2011 15:14:51 GMT</pubDate>
      <guid isPermaLink="false">tag:lekkimworld.com,2011-05-11:default/1305126891125</guid>
      <dc:date>2011-05-11T15:14:51Z</dc:date>
    </item>
    <item>
      <title>XPages JavaScript utility function of the day</title>
      <link>http://lekkimworld.com/2011/05/10/xpages_javascript_utility_function_of_the_day.html</link>
      <content:encoded>&lt;p&gt;
Yesterday and today I've been spending some time doing some XPages coding for a customer project and after spending quite some time doing Java plugin development I'm amazed of how easy XPages are. Don't get me wrong - there is still work to do for the XPages team but it's a joy to work with XPages and coding in JavaScript is just - well - flexible and fun.
&lt;/p&gt;
&lt;p&gt;
One of the real joys of JavaScript is it's dynamic nature and that it allows one to really cut down on the boilerplate and repeated code. For one I spent a lot of key pressed getting field values from backend documents in server side JavaScript. Instead of repeating the same ol' Document.getItemValueString(String) over and over again I did a neat little shortcut. Since I needed all items from a document I just created a utility function to JSONify a document to make it easier to access. The method is below.
&lt;/p&gt;
&lt;p&gt;
&lt;pre&gt;
var jsonifyDocument = function(doc) {
   var result = {};
   if (!doc) return result;
   var item;
   for (item in doc.getItems().toArray()) {
      result[item.getName().toLowerCase()] = item.getText();
   }
   return result;
};
&lt;/pre&gt;
So now instead of writing doc.getItemValueString all the time I can now just do property-like access to field values ("Heading" and "Description" are fields on the document). 
&lt;pre&gt;
var jsonDoc = jsonifyDocument(doc);
jsonDoc.heading + " (" + jsonDoc.description + ")";
&lt;/pre&gt;
&lt;/p&gt;
&lt;p&gt;
I also wrote a nice little Dojo-like mixin function to make my XAgents easy to configure. But that's for another day.
&lt;/p&gt;</content:encoded>
      <category domain="http://lekkimworld.com/tags/dojo/">dojo</category>
      <category domain="http://lekkimworld.com/tags/javascript/">javascript</category>
      <category domain="http://lekkimworld.com/tags/json/">json</category>
      <category domain="http://lekkimworld.com/tags/xagent/">xagent</category>
      <category domain="http://lekkimworld.com/tags/xpages/">xpages</category>
      <pubDate>Tue, 10 May 2011 12:05:02 GMT</pubDate>
      <guid isPermaLink="false">tag:lekkimworld.com,2011-05-10:default/1305029102437</guid>
      <dc:date>2011-05-10T12:05:02Z</dc:date>
    </item>
    <item>
      <title>ext.js moves to a commercial license</title>
      <link>http://lekkimworld.com/2008/05/07/ext_js_moves_to_a_commercial_license.html</link>
      <content:encoded>&lt;p&gt;
I first heard of this on some TWIT podcast so I went to see for myself but it appears that the &lt;a href="http://extjs.com/store/extjs/"&gt;ext.js&lt;/a&gt; Javascript framework has gone from an open source to a commercial license. This means that you have to pay if you use ext.js in an application that isn't compatible with the GNU license. All of the applications I do fail this requirement.
&lt;/p&gt;
&lt;p&gt;
This is too bad and effectively removes ext.js as a framework I will even consider. With dojo being the framework of choice come Domino 8.5 this will however not be too much of a loss.
&lt;/p&gt;</content:encoded>
      <category domain="http://lekkimworld.com/tags/dojo/">dojo</category>
      <category domain="http://lekkimworld.com/tags/ext.js/">ext.js</category>
      <category domain="http://lekkimworld.com/tags/javascript/">javascript</category>
      <pubDate>Wed, 07 May 2008 19:11:00 GMT</pubDate>
      <guid isPermaLink="false">tag:lekkimworld.com,2008-05-07:default/1210187460000</guid>
      <dc:date>2008-05-07T19:11:00Z</dc:date>
    </item>
    <item>
      <title>Citrix and AJAX - one bad combo?</title>
      <link>http://lekkimworld.com/2007/05/24/citrix_and_ajax_one_bad_combo.html</link>
      <content:encoded>&lt;p&gt;
Anyone using AJAX type-ahead controls under Citrix? I have been working on a customer solution using the select-widget from &lt;a href="http://dojotoolkit.org/"&gt;the dojo toolkit&lt;/a&gt; but it doesn't work correctly in Internet Explorer under Citrix (you can type ahead but cannot use the arrow keys to select from the choices). Just checked &lt;a href=""&gt;script.acolou.us&lt;/a&gt; and their autocomplete widget doesn't work either under Citrix either (same issue). Previously I have been using a solution I developed myself but really want to go mainstream...
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://demo.script.aculo.us/ajax/autocompleter"&gt;script.aculo.us autocompleter example&lt;/a&gt;.
&lt;/p&gt;</content:encoded>
      <category domain="http://lekkimworld.com/tags/ajax/">ajax</category>
      <category domain="http://lekkimworld.com/tags/dojo/">dojo</category>
      <category domain="http://lekkimworld.com/tags/javascript/">javascript</category>
      <pubDate>Thu, 24 May 2007 13:17:42 GMT</pubDate>
      <guid isPermaLink="false">tag:lekkimworld.com,2007-05-24:default/1180012662100</guid>
      <dc:date>2007-05-24T13:17:42Z</dc:date>
    </item>
    <item>
      <title>JSONMap class</title>
      <link>http://lekkimworld.com/2007/02/19/jsonmap_class.html</link>
      <content:encoded>&lt;p&gt;
I'm starting off with converting some inhouse developed AJAX stuff to using &lt;a href="http://www.dojotoolkit.org"&gt;DOJO&lt;/a&gt; and for that reason I needed to convert my XML responses to JSON. Using the &lt;a href="http://www.json.org/java/index.html"&gt;JSON Java classes&lt;/a&gt; this was pretty straight forward but I really needed an easier way to convert a java.util.Map instance to JSON. Extending JSONArray this was easy. Provided here for those who might need similar code...
&lt;pre class="code"&gt;
package org.json;

import java.util.Iterator;
import java.util.Map;

public class JSONMap extends JSONArray {
   public JSONMap(Map m) {
      for (Iterator ite=m.keySet().iterator(); ite.hasNext(); ) {
         String key = (String)ite.next();
         String value = m.get(key).toString();
         JSONArray a = new JSONArray();
         a.put(value);
         a.put(key);
         this.put(a);
      }
   }
}
&lt;/pre&gt;
&lt;/p&gt;
&lt;p&gt;
Code like this
&lt;pre class="code"&gt;
Map m = new HashMap();
m.put("AL", "Alabama");
m.put("AK", "Alaska");
m.put("AR", "Arkansas");
JSONMap jm = new JSONMap(m);
System.out.println(jm.toString());
&lt;/pre&gt;
will output the following JSON
&lt;pre class="code"&gt;
[
    [ "Alabama", "AL" ],
    [ "Alaska", "AK" ],
    [ "Arkansas", "AR" ]
]
&lt;/pre&gt;
&lt;/p&gt;</content:encoded>
      <category domain="http://lekkimworld.com/categories/java/">Java</category>
      <category domain="http://lekkimworld.com/tags/dojo/">dojo</category>
      <category domain="http://lekkimworld.com/tags/java/">java</category>
      <category domain="http://lekkimworld.com/tags/json/">json</category>
      <pubDate>Mon, 19 Feb 2007 10:25:03 GMT</pubDate>
      <guid isPermaLink="false">tag:lekkimworld.com,2007-02-19:default/1171880703234</guid>
      <dc:date>2007-02-19T10:25:03Z</dc:date>
    </item>
  </channel>
</rss>


