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...
Member | Joined | Pledge | Increase |
Que, Suzy | 1999 | 150.00 | -50.00 |
Jammer, Jo Jo | 2001 | 100.00 | 100.00 |
Jones, Jimmy | 2002 | 150.00 | 150.00 |
Lowa, Hona | 2002 | 156.00 | 120.00 |
Roxx, Fred | 2000 | 190.00 | -10.00 |
Flintstone, Fred | 2000 | 200.00 | 100.00 |
Friend, Dorie | 2000 | 400.00 | 100.00 |
Gatwick, George G. | 1999 | 600.00 | 150.00 |
Franklin, James Earl T. | 1999 | 750.00 | 100.00 |
Fordick, Mike | 2003 | 1000.00 | 1000.00 |
Hannibal, George | 2002 | 1000.00 | 100.00 |
Green, Olive | 2001 | 1250.00 | 250.00 |
Deer, Jane | 2002 | 2003.00 | 1000.00 |
Arnie, Miami | 2002 | 3100.00 | 20.00 |
Sort by column 1Sort descending by column 1Sort numerically by column 2Sort numerically descending by column 2Sort numerically by column 3Sort numerically descending by column 3So, 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 SubAnd 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: Ajax Midas Rich Text Lotus Notes