Ben Langhinrichs

Photograph of Ben Langhinrichs

E-mail address - Ben Langhinrichs

Recent posts

Fri 29 May 2020

Round tripping, even while staying put

Tue 19 May 2020

An unladen user

Thu 7 May 2020

Can we get a huzzah for updated Domino Limits?

July, 2020
   01 02 03 04
05 06 07 08 09 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

Search the weblog

Genii Weblog

Rich Text 2.0: AJAX and Midas working together

Thu 2 Nov 2006, 11:38 AM

by Ben Langhinrichs
Rich Text 2.0 logo

After joking with Philip Storry recently about Rich Text 2.0, I was worried that readers might get the impression that the Midas Rich Text LSX was not somehow relevant with all the new technologies, so I decided to post one (or more if they get interesting) example of how easy it is to use our Midas Rich Text LSX with Ajax, which is probably the buzzword of the year.  It turns out to be a pretty slick technique, so I might work on it a bit more.  Since I am writing this "live", the demo may change if you read this post in a couple of hours, as I play with making it just right.

Table to be sorted using Midas and Ajax (for display):

Original sorting...
Que, Suzy 1999150.00-50.00 
Jammer, Jo Jo2001100.00100.00
Jones, Jimmy2002150.00150.00
Lowa, Hona2002156.00120.00
Roxx, Fred2000190.00-10.00
Flintstone, Fred2000200.00100.00
Friend, Dorie2000400.00100.00
Gatwick, George G. 1999600.00150.00
Franklin, James Earl T.1999750.00100.00
Fordick, Mike20031000.001000.00
Hannibal, George20021000.00100.00
Green, Olive20011250.00250.00
Deer, Jane20022003.001000.00
Arnie, Miami20023100.0020.00

Sort by column 1
Sort descending by column 1
Sort numerically by column 2
Sort numerically descending by column 2
Sort numerically by column 3
Sort numerically descending by column 3

So, what is happening in this demo?  The agent code is really, really simple, so I thought I would just put it here in-line for you to look at:

Sub Initialize
   Dim session As New NotesSession
   Dim db As NotesDatabase
   Dim doc As NotesDocument
   Dim rtitem As New GeniiRTItem
   Dim rtchunk As GeniiRTChunk
   Dim unid As String
   Dim pos As Integer
   Dim column As Integer
   Dim reverse As Integer
   Dim numeric As Integer
'   &Sort=unid&Column=1&Numeric=Yes|No&Reverse=Yes|No
   Set db = session.CurrentDatabase
   Set doc = session.DocumentContext
   pos = Instr(doc.Query_String(0), "&Sort=")
   unid=Mid(doc.Query_String(0), pos+6, 32)
   pos = Instr(doc.Query_String(0), "&Column=")
   column = Cint(Mid(doc.Query_String(0), pos+8, 1))
   pos = Instr(doc.Query_String(0), "&Numeric=")
   numeric = Cint(Mid(doc.Query_String(0), pos+9, 1))   
   pos = Instr(doc.Query_String(0), "&Reverse=")
   reverse = Cint(Mid(doc.Query_String(0), pos+9, 1))      
   Set doc = db.GetDocumentByUNID(unid)
   Call rtitem.ConnectBackend(doc.Handle, "BlogBodyRT", True)
   Set rtchunk = rtitem.DefineChunk("Table 1")
   Call rtchunk.SortByRow(column, True, numeric, reverse)
   Print rtchunk.GenerateHTML("Table 1", "HTML", "Generation='Fragment' StandardFontTags='Yes' ")
End Sub

And that is it.  Midas reads the contents of this blog post itself, sorts the table and then spits out the content again into the space occupied before by the table, all using Ajax.  It never saves the changes, so dozens of people can try this at the same time without causing conflicts.  Very cool!  What do you think?  Should I try out other similar demos for in-line use of Midas?

Copyright 2006 Genii Software Ltd.

What has been said:

506.1. Ben Langhinrichs
(11/02/2006 02:34 PM)

Cool idea, Adaleida. I added a message while you sort. Let me know what you think.

506.2. Adeleida
(2006/11/02 22:24)

Ah, I see! Thanks :).

506.3. Philip Storry
(05/11/2006 06:09)

Wow. That's one cool demo!

So good to see you making use of that spare time you have. ;-)