« iPhone and the Enterprise (or How to Read Beyond a Press Release) | Main| A quick tip on how to read my blog »

Meet Domino Superior (or A Tutorial on Why Xpages Are Better Than Cake and Ice Cream)

Join the Evolution
Mutation: it is the key to our evolution. It has enabled us to evolve from a single-celled organism into the dominant species on the planet. This process is slow, and normally taking thousands and thousands of years. But every few hundred millennia, evolution leaps forward.
- Patrick Stewart as Professor Charles Xavier


After spending three days in meetings and workshops in Westford, I would submit that for Domino, that leap forward has arrived.  In the form of the now-ironically-named Xpages, the Yellowverse is going to get a lot of long-standing problems solved in a very short time.  Much like learning to live with people that can walk through walls or read minds or shoot lasers from their eyes, it's going to require some getting used to.  There will be prejudice, and a longing for the "old ways" and a few reactionaries will probably even want to do away with this new super-species of design.  But those who embrace it will find themselves quickly getting back to building Super Human Software.

Today, I'm going to show you how Xpages can quickly solve one of the greatest long-standing problems in Domino development: the inability to do an @DbLookup in a view column -- otherwise known as "can't do JOINs."

Continued...

Let us start with a couple of simple, traditional Notes constructs.  Here we have a view showing a list of mutants identified by Professor X's Cerebro.  Note that we have only the name and alias for each of these homo superiors....
What color spandex was Wolverine's original costume?

And here we have a view that shows a list of their mutant powers.  There is only one power per document.  This is far different from typical Domino architectures, where the list of powers would be a multi-value field inside the previous mutant document...
Adamantium claws can tear through a web page, y'know.

In Domino days of yore, the techniques to present these relationships are the stuff of legend.  In the client, we've seen agents to merge & sync content, embedded views in preview windows, collapsed information written to environment variables, entire rewrites of presentation layers in Applets, forms that fake views by building tables on the fly, even entire DB2 implementations just to get SQLViews of Domino data!  On the web, we've seen hand-coded HTML in agents, embedded Javascript that's executed client side to rewrite cell contents, client-side XML transforms, and even portal implementations to front-end Domino solely to group some information together in a table!

In Domino 8.5, Xpages makes this easy.  Almost drag-and-drop easy.  Here's how...

First, in Designer, you need to double-click on the Xpages category in the database navigator.  Then click on New XPage.  We're going to call ours "CerebroResults."
MutantRegistry was my first prototype of this idea.  It
has some extra tricks too.

Then select View from the Container Controls palette, and drag that on to the blank Xpage.  This will bring up the View wizard, which prompts you for the view to add.  In this case, I'm selecting the Mutants view.  That selection also causes the list of columns to appear.  Note that you can select/deselect columns.
It occurred to me far too late that Alias and Name probably weren't
the best item names.  Just deal.

Once the view appears in the Xpage, it's automatically formatted as a table.  You'll see the columns appear in the same order as they do in the view design.  You are free to rearrange this.
Tragically, the contents of the Xpages are formatted as Serif
fonts in the editor window.  HEINOUS!
Note: The additional circles in yellow show off some other great features of Xpages.  The Outline on the left provides a continuous hierarchical perspective on the overall design of the Xpage, so you can see nesting relationships very easily.  This also makes it easier to select some elements, instead of clicking on their borders in the editor.  And the styling for the view panel allows us to specify many different units.  And see that little diamond next to the Width property?  That tells us that we can click there to set a computation for that property instead of a static value.  You'll see those little diamonds EVERYWHERE.

Next, we select the view panel with the outline and in the properties pane, go down to the All Properties tab.  This is the "advanced" tab that gives you access to everything you could possibly control.  Not all of these things are surfaced in the other tabs.  In this case, we scroll down to the data category, and select the property var.  We can enter a value for the property that we'll call "mutantRow".  In case it's not obvious, this will be the variable name for each entry generated by a row in the view.
The fight scenes in the X-Men movies could also be called mutant
rows.  Or maybe if the Xavier school had a crew team...

Now we'll go back to the table and right-click on any column.  It really doesn't matter which column you click -- you just want the context menu for the table as a whole.  Choose Append Column from the bottom of the menu.
Astute observers should be noticing some of the properties I'm
not mentioning, such as Sortable or Icon.

We set the label for the new column's Header to be "Powers."  You'll note there's a separate Name for the Header.  This is auto-generated by Designer, and there is a unique identifier for almost everything you ever see.
Did you notice that there's a diamond next to it?  Discuss
the implications among yourselves.

Then we click the Column itself, and again go to the All Properties tab.  In data, we find a property for value.  And fortunately for us, there's a little diamond next to it!
Will the Irish version have little green clovers instead?  Xpages
are magically delicious.

When the Script Editor comes up, the fun begins.  You'll notice the language selection is JavaScript (Server Side).  Yes, you get extensive server-side JS support.  In fact, prepare to be amazed at how it works...
Would you believe that one of the Language options is Custom?
 Discuss the implications amongst yourselves.
Note: You'll see some interesting options in the reference panel in yellow.  Those scope references mean exactly what you think they mean.  Xpages provide session and application scopes.  No more profile documents for session tracking.  Expect more on how to use these for caching goodness in later tutorials!

We'll enter our server-side Javascript here.  You'll notice that this isn't particularly strict Javascript, right?  "@DbLookup" isn't valid Javascript.  It turns out that IBM doesn't want to force you to waste all that knowledge you've spent the last two decades amassing on Notes/Domino languages.  So instead, they rewrote their Javascript interpreter to understand most of the common functions you use every day.  In this case, @DbLookup works almost identically.
Mixing languages inline like this is both fun and frightening.
 Having standards for how you do things will be more important than
ever.
Note: the syntax is slightly different.  You'll notice commas instead of semi-colons, and I'll let you know that the function names are case-sensitive.  My number one suggestion for the workshop is that they need either much stronger syntax checking at design time, or way better debugging tools.  The power in Xpages definitely force you to keep your wits about you!

You're almost done.  Just jump back to the view panel in the outline again and set the width to 100 percent.  I forgot to highlight that for you earlier!  (See, even the tutorial does things in the random order that a dev really would!)  Don't forget to SAVE!!!
Note that you can even compute the unit of measurement.  Why
would you want to do that?  Think mobile devices.

Lastly, we'll go back to the Database Navigator and double-click on the Application Properties.  Select the Launch tab in the editor.  You might need to scroll over to the web launch properties.  Set Launch to Open Designated Xpage and choose CerebroResults.
See some of those other tabs?  The Xpages one let's you
set a fail-over location for all error messages.  No more Server Code
500 responses!

Okay!  Now we're ready to open the NSF in a browser.  Just open Firefox and voila!
Okay, I cheated a little.  The code in the column value
script needs to do a javascript .join at the end.  I fixed that before
taking this screenie.

You'll notice that the top has a next/previous navigator already, too.  That wasn't automatic, but it was just one combobox away.  Tune in next time to find out how that works!
The formatting still has some bugs.  It's beta.

And that's it!

Of course, this has dramatic implications for all of your existing applications.  With the ability to do lookups in a column, every data architecture strategy we've used for the last 15 years is now obsolete.  And if you're thinking "P'shaw!  That has to be a major performance killer!" you couldn't be more wrong.  It's actually stunningly fast, because the lookup in the Javascript is actually interpreted into a native Java API lookup, complete with cache management, and then evaluated by the server.  In this example, I'm doing 20 lookups at a time, and the page comes up in the blink of an eye.

There are bugs (Philippe and I debugged one in his source control right there at the conference table on Wednesday) but that's why it's still beta.

The rumors are no exaggeration.  Xpages are the next wave of Lotus evolution, and they will turn everything you know upside-down.  Get ready to be a novice again.

Comments

1 - I for one welcome our new Xpage overlords!

"Get ready to be a novice again."

I'm looking forward to it - once Xpages have been *fully* deployed and become available to us Lotus Notes and Domino developers, the possibilities are truly endless.

2 - Hey Nathan,

Great tutorial.

I remember being excited after the Xpages session at LS08. Now, I remember why. Those little diamonds by themselves are so exciting. And the "hybrid" JavaScript/Formula. That's the first time I saw that.

Question: How do Xpages render in the Notes client? (How does yours, above, for example?)

-- Grant

3 - @2 - Xpages do not yet render in the Notes client. The tutorial is showing in Firefox.

I'm pretty sure I'm not violating my NDA when I say that Xpages-in-the-Rich-Client is slated for "a future release." Emoticon

4 - This was cool when I saw it in Workplace Designer at LS06. Unfortunately, Workplace as a alternative to (replacement for?) Notes was seriously uncool. The '"hybrid" JavaScript/Formula' stuff was there too.

And since it's all java underneath, you *might just be able* to "script" the Eclipse/Expeditor APIs too. How cool would that be?

I stand by my assertion that java will not (ever) be the primary application development language for Notes. Third party plugins? Sure. Huge, performance ciritcal apps? JS+Java.

Server side javascript is going to be big elsewhere too:

{ Link }

5 - Dan, all that happens with the Javascript that's put in there is that it's interpreted into a Java class under-the-covers. So while we may not be WRITING it that way, that's what's actually executes.

That's why the @DbLookup stuff is so fast. There's no formula engine involved.

And please note, everyone, I am barely skipping across the surface of what's possible here. This is tutorial one in what well might be a series of 50 or so.

6 - Nathan, I understand that the JS engine runs on the JVM..it's all bytecode in the end. The key distinction is that developers will be programming and thinking in a dynamically typed language. They get all the JVM/java library goodness without the B&D language. RAD lives on.

For the record, I suffer the B&D language daily...along with the baroque Eclipse APIs.

IBM could have used Rhino but there were licensing/distribution problems at least some of which went away when Sun shipped Rhino with Java6.

Lookg forward to your next 49 XPages tutorials Emoticon


7 - Really nice post Nathan! Like you mentioned about our current/past notes app. architecture strategy... this really does change the way we will look at designing and organizing our data. Thanks for putting this together.

John

8 - Nice write-up. Having been there at the beginning of Workplace Designer, then LCD, it's gratifying to hear back what we knew all along - that xpages would bring a new level of power to our developers that couldn't be achieved with DD alone. Plus, no barriers -> you don't like something, do it in java and call it from JS.
Did you know that you could also just write Java in the JS editor and it should work? :) That could come in handy sometime - mix and match @functions (really just JS functions with an @ in front), JS, and Java).
Chris

9 - Pretty cool write up, Nathan - but I'm still waiting. Its missing something right up front near the top I think. Emoticon

10 - Another great write-up: you're on a roll at the moment. Must have taken you ages; are you doing any billable work?? Emoticon

11 - hells bells, good tutorial, learnt a lot, gona have to go prod at it my self now

12 - this all looks very good and useful, it seems that finally a lot of Notes development problems are going to be solved - if XPages are available on the Notes Client.

You mentioned this is planned "for a future release". I hope they don't wait too long with that. The only possibility to forgive IBM that they didn't do ANYTHING on the Notes core would be that we can do all our Notes apps with XPages then.

13 - @8 - LCD was always cool. Just inaccessible.

@10 - Dude, my boss reads this blog. NOT the right question to ask! Emoticon

@12 - As I said, I'm under nondisclosure regarding client futures. Ask people you know at Lotus, though!

14 - Well done Nathan!

One of the great things about this for some companies will be that it doesn't require a corporate-wide deployment of Notes 8.5 to get the benefit. Just pick a few servers that to host critical web apps and put those on 8.5 and away you go. The benefits are so significant that I can't help but think some people will be forced to adapt this strategy when they normally would have waited 18 months or more.

15 - Thanks for sharing Nathan, seeing Formula mixed up with JS clarifies a lot for me. Keep it up!!

16 - * Wolverine's first costume was yellow and black
* Mutant Registration didn't work out so well for the Marvel universe.

Okay, back to the real topic...

XPages both excite and bewilder me. I was stoked when I saw them at Lotusphere and went out of my way to get an opportunity to do as many UX sessions as I could. Mixing JS and formula felt a little weird, and as you said, there are a few syntactic differences so you can't just copy and paste code.

It is going to take A LOT of tinkering to find out all the interesting ways XPages can be used, and to come up with best practices. Hopefully IBM will produce heap big amounts of documentation and tutorials. Something like this would be ideal for me: { Link } .

17 - Great write-up Nathan. What I really want to understand is are Notes shops still developing Domino applications? Recently I received an email from a large Notes/Domino customer who stated "we aren't allowed to deploy anymore Domino applications" (but they still use Notes client).

I hope that with the advances xPages bring to Domino can revive/start a new revolution for Domino development.

18 - @charles and others -

We're trying to get an idea of how you want the doc and tutorials delivered -
in the product doc? as cheat sheets? as example files? in a wiki?

Send your feedback to me at my-firstname UNDERSCORE my-lastname - and it's at us dot ibm dot com.

@nathan - thanks for being willing to return to novice - and for giving all the feedback you did at the workshop!

19 - @17, I've got a horrible feeling that XPages have arrived just too late. The market for new Domino web app development seems vanishingly small. Can XPages really turn around the situation? I hope so, and am playing around with them in the beta, but I'm not going to hold my breath.

Emoticon

20 - @ 19 - Microsoft doesn't seem to think so. XAML is really close to what Xpages is and it's part of their 2008 offerings. I think the backend technology is becoming less important than what you can sell to customers. If you can sell a web application deployment and at the bottom line the customer is saving time and money with IBM and Domino, well, then the technology matters to someone. My point being - this is right on time if you position it correctly.

Nice tut. Nathan! I'm getting fidgety to set this up on a server at home!!

21 - @19 -- Jeez, Kerr-- they got this one right, what does "too late" mean? It isn't as though Microsoft has suddenly gotten a market dominating collaboration suite offering. Personally, I think this and something called "Atlantic" are going to totally revitalize the ND services industry within the next 18 months.

22 - @20, @21, To clarify, I think the technology is huge step forward for web app dev in Domino. And it has all sorts of parallels with other technology in the market that is doing well. I'm looking forward to using it in a real world environment. But I'm seeing the market for web app dev on Domino drying up, at least in the UK. What does "too late" mean? It's too late if there aren't any shops running domino for new web apps by the time it arrives.

As I say, I hope not. Maybe XPages will reverse the trend and all those places that run Domino, but aren't investing in new apps, will change there mind. Maybe it'll draw in a new customers who have never used Domino before.

I hope so. I'm not holding my breath. Emoticon

23 - @10@nathan
Im not amused.

24 - I am Xcited! Can you tell us a bit more how we can make usage of the 'diamonds' to make everything more computed at run-time?

For example the diamond after 'label', can we use @Formala, JS or combinations everywhere?? Emoticon

25 - Are Xpages searchable? Will they be indexed?

26 - Is there a way to have results built in ordered and unordered lists instead of tables? I know tables are still used for certain types of data, but semantically speaking, these are lists being produced in your example, and I feel that relying on tables for the formatting is very "un-Web 2.0-ish," and not as portable across various screen-sizes and alternative browsing devices.

Any luck for us semantic web folk, or am I asking for too much?

27 - @26 - "Is there a way to have results built in ordered and unordered lists instead of tables?"

Yes, absolutely. There's something called a "repeat" control that will be the subject of my next tutorial. Basically, it's any controlled block that iterates over a data source. So you can build a custom DIV block per row in a view -- no tables involved whatsoever.

You'll love it. And it's totally Web 2.0.

28 - Damn, that's hot!

I have to admit, I was ready to be disappointed, but now.... not so much. I look forward to your tut.

29 - Nathan, thanks for the introduction to Xpages. I do some customizations of DWA in the AJAX vein using xmlhttprequest, but I didn't know anything about Xpages (feel like an ostrich with its head in the sand... have never been to LotusSphere). I look forward to learning more about best practices with Xpages. Thank you for this!

30 - Thanks for your introduction to XPages. Emoticon

31 -
All my problems with existing applications Domino seems that could be resolved with the new features in 8.5 forward I hope this release. I´m expected for this released Emoticon Emoticon Emoticon

Post A Comment

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

11 Aug 

Hire Me 

Lotus-911-Logo.jpg

Search 

Disclaimer 

Welcome to Escape Velocity!

Opinions expressed here by Nathan T. Freeman are not necessarily those of his employer. However, there's a decent chance they are, so check with them if you really want to know.

But really... do you need that kind of validation? Are the opinions expressed here in doubt?

MiscLinks