As mentioned yesterday here's an example of the code I use in my WQO agents to render custom HTML on a form:
'Setup output to the rich-text field called "ViewBody" 'Field can be either Rich Text, Text-List or plain old Text Dim viewbody As New HtmlArea("ViewBody") 'Start adding HTML to it 'Open a new table viewbody.add |<table>| 'All the logic and HTML-building code goes here. 'E.g: Loop through a doc collection and call viewbody.add |<tr><td>|+doc.Title(0)+|</td></tr>| 'Close the table viewbody.add |</table>|
It's that easy!
The code needed to do it has been encapsulated in a class called HTMLArea. I normally put this in the declarations section of the "CommonRoutines" script library which I use in all agents in all my databases.
The code for the HTMLArea class is:
Class HtmlArea Private session As NotesSession Private doc As NotesDocument Private rtitem As NotesRichTextItem Private item As NotesItem Sub New(Byval FieldName As String) Set session = New NotesSession Set doc = session.DocumentContext Set item = doc.GetFirstItem(FieldName) If item.type=1 Then 'Rich text Set rtitem = doc.GetFirstItem(FieldName) Dim richStyle As NotesRichTextStyle Set richStyle = session.CreateRichTextStyle richStyle.PassThruHTML = True Call rtitem.AppendStyle(richStyle) End If End Sub Public Sub add(Byval snip As String) If item.Type=1 Then rtitem.AppendText snip Else item.AppendToTextList snip End If End Sub End Class
How cool is that!? We can now just create whatever HTML we like. It's completely under our control!
I promised there'd be a download for you today but that will have to wait a few more days until I polish it off. As usual I've gotten completely carried away with myself and what could have been a simple database is turning in to a fully-fledged application. As soon as I'm happy with it I'll add it to the sandbox.
For now though here's a little teaser — open the demo database and notice there's a single view called Calendar. Open that view and behold the beauty of the non-Notes-like calendar. Finally I have complete control. Muhahaha.
I know what you're thinking — how come I just opened a normal "?OpenView" URL and it looks like that? Well, you see, what you're looking at is the Form called "$$ViewTemplate for Calendar". The view itself isn't on the form and so you never get to see it the way Notes intended. Instead the form has a rich text field on it and the whole thing is built using the WQO agent attached to the form.