Subject: Design suggestions needed: Too much data for text field, can’t use RTF
Complex and time-consuming but not impossible. I’m doing something along these lines right now (and mine has to be in Japanese) and if I can do it so can anyone else.
You have to separate from the form the logic that creates the letter. The form, while still vital, is no longer doing all the work, it’s just a vehicle for displaying whatever the logic spits out. The form probably should not contain any dblookups etc - those, or their Lotusscript equivalent, are performed elsewhere.
You should have one class - call it the back end class - that gathers all the data, adds rows, removes rows, sorts rows and so on. This class has no idea what is being done with the data and does not display it anywhere. This class might have a method on it for computing and returning the complete text of a letter - everything from the date at the top to the cc at the bottom. (Such a method would be useful if you needed to use the class in an agent where front end objects are not allowed.) Or it might return the complete text as an unsaved notesdocument, or it might have methods for doing either.
Another class - the front end class - takes that data and pushes it onto the form. For example you might have a computed text for the address - the front end object would get the address data from some back end method and push it onto the form using uidoc.fieldsettext(). This class doesn’t know where the data comes from, it just asks the back end to return the address. This class has methods for doing picklists, dialogboxes and so on. The front end class is a wrapper both for the back end object and for notesuidocument.
The front end class will probably, for simplicity, contain an instance of the back end class, just as notesuidocument returns a handle to a document.
The form should contain an instance of both a front end and a back end object in its declarations event. The back end object is obtained after the front end is instantiated.
Very rough outline:
public class LetterBackEnd
public notesdocument document
sub new(d as notesdocument)
set me.document = d
' call methods for finding the data we want, preparing lists and so on.
end sub
’
’ other methods here…
’
public function HardCopyText as string
' figure out the text of an entire letter using current settings, return it as a string suitable for previewing in a form.
end function
public function HardCopyDocument as notesdocument
' figure out the text of an entire letter using current settings, return it as a notesdoc.
end function
end class
Public Class LetterFrontEnd
public BackendLetter as backendletter
private ws as notesuiworkspace
private uidoc as notesuidocument
sub new
set me.ws = new notesuiworkspace
set me.uidoc = me.ws.currentdocument
set me.BackendLetter = new BackEndLetter( uidoc.document )
me.paint
end sub
public sub Paint
' pushed various values onto the uidoc field, and calls uidoc.refresh.
end sub
End class
Form declarations event:
use “FrontEndLetter” ← this script library uses “BackendLetter”, ie, you can use BackEndLetter alone in an agent.
dim FrontEnd as FrontEndLetter
dim BackEnd as BackEndLetter
Form PostOpen
set FrontEnd = new FrontEndLetter
set Backend = FrontEnd.BackEndLetter
So there are two distinct jobs here: coming up with a set of logic - pretty much all of it Lotusscript, in this model - for getting and sortng the data, and another set of logic for creating a letter from that data.
So, complex but definitely doable.
Mail me if you want more details - thomas.kennedy@nospamplease.towersperrin.com