Saturday, November 15, 2008

Discovering Dojo for Domino: Part 2- Runing Dojo on Domino 8.5

Part one of my adventures in dojo can be found here

Next, I tried to run this on my 8.5 Beta 1 Domino server at home.

First problem: the dojo files are not installed under the /html folder but in a new folder in the file structure /js. I could not load the javascript file at all. After searching through the N&D 8.5 Beta forum I found that you can reference this folder using /domjs.

So my HTML Head Content was changed to
<script type="text/javascript" 
 src="/domjs/dojo-1.1.0/dojo/dojo.js"
 djConfig="parseOnLoad:true, isDebug:true"></script>"

And, of course, the files shipped with Beta 1 are dojo 1.1.0. Fortunately the Dojo Quick Start Guide also links to the earlier version (not that I could spot any differences!)

Everything worked OK until I tried to run the example which retrieves text as json. I kept getting a 404 - file not found error. Rather than wasting time trying to find the typo in the file path I created a simple test agent which output the example json text, because agents and views (using ?ReadViewEntries) are the two most common ways of generating json in Domino.

The only thing I had to do was find out the appropriate mime type for the output. I initially used text/html and everything worked. Firebug helpfully displayed the following message:
Consider using mimetype:text/json-comment-filtered to avoid
potential security issues with JSON endpoints
(use djConfig.usePlainJson=true to turn off this message)

So I modified the HTML head content again, removing the debug parameter and replacing it with the suggested json parameter:
<script type="text/javascript" 
 src="/domjs/dojo-1.1.0/dojo/dojo.js"
 djConfig="parseOnLoad:true, usePlainJson:true"></script>"

and set the content type. My agent is simply:
Sub Initialize

Print "Content-type: text/html"
Print |
{
foo: "bar",
name: "SitePen",
aFunction: function(){
alert("internal function run");
},
nested: {
sub: "element",
another: "subelement"
}
}
|
End Sub

Sweet!

Next - on to digits

5 comments:

Elijah Lapson said...

Thanks for documenting your experiences in dojo. This is helpful for a lot of us in the same boat. It is always so frustration just trying to "get going" and your specific documentation for Domino centric placement of javascript resources is invaluable.

Elijah

quintessens said...

I love to read more about Dojo and Notes 8.5.

For example how do I know which elements of a theme are being used by Notes 8.5 so I could already create our own corporate theme for DOJO ?

// Patrick

Michelle said...

Patrick

Sorry but I'm not an expert. I'm only just beginning my dojo journey and sharing my experiences as I go.

If I find out any more about themes, I'll post later

homes for sale costa rica said...

hello. thank you very much for letting me comment. very good article I would like more information on this item

Paul said...
This comment has been removed by a blog administrator.