« Using an Email Validation Widget | Main| Site name change already! »

Setting up Dojo with Domino

Category    
Bookmark : del.icio.us  Technorati  Digg This  Add To Furl  Add To YahooMyWeb  Add To Reddit  Add To NewsVine 

This is a tutorial for getting Dojo setup in your Domino environment. You can either download the Dojo 0.4.3 db from this site, or follow the instructions for getting Dojo from the Dojo site, importing the files into your Notes database via WebDAV, and then writing a simple "HelloDojo" page to validate that everything is working correctly. More...

  1. You can go to the downloads section of this site where the Dojo 0.4.3 database has been provided with the Dojo files put into File Resources already, and with the modified dojo.js that handles application/x-javascript mime type. There's also a test page "HelloDojo" that does an AJAX call to a view in the db to get the viewentry count. That should validate that you're up and running correctly, and you can ignore all the following steps
  2. Go to http://dojotoolkit.org and click the download button for the latest release. At the time of this writing, it is version 0.4.3. It is a tar.gz file, which if you're using a Mac, you've probably already got the tools you need to unzip it. If you're running Windows, you may not, so you'll need to locate a program that can handle it, like PowerArchiver or WinZip.
  3. If you decide to go the "do it yourself route", you'll probably want to setup WebDAV. For information on how to do that, see Jake Howlett's excellent article. A couple of items that are buried in comments that you need to pay attention to:
    • Be sure and go to Database Properties, Design Tab, and turn on Design Locking.
    • Not sure how valid this is, but put the database in a subdirectory...not the root
  4. The default Dojo download (dojo.js) does not support the application/x-javascript mimetype. This limits your ability to run ?ReadViewEntries&OutputFormat=JSON as the Domino server outputs a content-type of application/x-javascript for those calls. Get the modified dojo.js file from this site and replace the default.
  5. Create a Page element, set the content-type to HTML
  6. Paste in the following code:
  7. <html>
    <head>
    <script type="text/javascript" src="dojo.js"></script>
    <script type="text/javascript">
    function getViewCount() {
        var kw = {
           url: 'demoview?ReadViewEntries&OutputFormat=JSON&count=1',
           method: 'GET',
           mimetype: 'application/x-javascript',
           load: function(type, data, evt) {
              dojo.byId('showresults').innerHTML = data.@toplevelentries + " viewentry in the demoview";
           }
        };
        dojo.io.bind(kw);
    }
     
    dojo.addOnLoad(getViewCount);
    </script>
    </head>
    <body>
    <div id="showresults"></div>
    </body>
    </html>
  8. Create a form called Demo and create a document with that form.
  9. Create a view called demoview with a select formula that selects docs created with that form (e.g. Select Form="Demo")
  10. Go to your browser and open HelloDojo Page
  11. You should get the output "1 viewentry in demoview" or however many docs you created.
Enjoy!

Comments

Gravatar Image1 - data.@toplevelentries

gives an error to me saying "Object expected"

Domino 6.5.4 and IExplorer

Gravatar Image2 - @Ajit,

I've seen this error as well, and I think that's where I discovered that Dojo isn't successfully handling the application/x-javascript return from the Domino server.

Are you using the &OutputFormat=JSON argument at the end of your ?ReadViewEntries? If so, then you have to use the modified dojo.js file that I've posted that knows how to handle the application/x-javascript returned mime type.

Essentially, without that, dojo.js is treating the return as xml (best I can recall) and failing when it gets to the first @ sign.

Gravatar Image3 - @Ajit,

Oops, should have read your post more carefully. With Domino 6.5.4, I don't believe the &OutputFormat=JSON is available at all, so if you're using it, the server is probably not returning JSON at all. Verify by just going to that URL directly in your browser (e.g. { Link } )

If you're simply doing ReadViewEntries, then you need to make sure your KW argument object has the mimetype set to text/xml and not application/x-javascript. Then the data variable will contain xml that you'll have to parse with xml dom rather than javascript notation. For example: data.getElementsByTagName('viewentry').

Hope this helps.

Gravatar Image4 - @Thomas,

I'm not sure what you're referring to, Thomas, can you provide more info? Inside the dojo101.nsf, there's no example pages. Are you referring to something in the 0.43 download?

Thx, and sorry for not understanding.

-Lance

Gravatar Image5 - I saw the two lines you refer to in dojo.js, but when I try to find those lines in the 1.02 distribution, I can't find them. Could it be that the mime type issue is now moot?

Gravatar Image6 - Oops, forgot to teel you: I am on Domino 7.0.2FP2.

Fred

Gravatar Image7 - @Aden

You're right. In code we created later, we introduced a dojomino.session.js page that is aware of the server version and requests xml or json accordingly. On the script side, we use xml2json to convert everything to json and only do a json processing pass.

- Lance

Gravatar Image8 - Thanks! I will give it a try!

Gravatar Image9 - Lance, I highly recomend the Ajax Toolkit Framework for Dojo development via Eclipse.
{ Link }

Gravatar Image10 - Hi,

After installing/configuring the dojo043.nsf database I get the correct response in Firefox (1 viewentry in the demoview) but no response in IE7.

Any ideas?

Fred

Gravatar Image11 - The html file points to a file called dojo.js that is not in the dojo101.nsf.

why not include a working example in the dojo101.nsf ?

- Thomas

Gravatar Image12 - You need 7.0.2 for outputformat=json.

Gravatar Image13 - Trying to run the test page using the 1.0.1 database. Like another poster, I'm getting an "Error: Conditional Compilation is turned off". What do I need to do to fix this?

Gravatar Image14 - The example posted above is no longer relevant for dojo .9 and above. The api has changed considerably since .4 and the example above is based on .4x.

In the new Dojo11.nsf (based on dojo 1.1), I have included a sample page that works with that version.

Gravatar Image15 - I get an error:

Line 11
Char 69
Error: Conditional Compilation is turned off
Code 0
{ Link }

Any suggestions?

Gravatar Image16 - @Charles

You are correct, this is no longer an issue with 1.x.


Gravatar Image17 - do you know any description how to install dojo on a domino 8.01 server? any changes needed in the configuration?

Post A Comment

:-D:-o:-p:-x:-(:-):-\:angry::cool::cry::emb::grin::huh::laugh::lips::rolleyes:;-)