Genii Weblog


Civility in critiquing the ideas of others is no vice. Rudeness in defending your own ideas is no virtue.


Thu 2 Nov 2006, 11:38 AM
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...
MemberJoinedPledgeIncrease
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.

Tags: