The @WebDBName function provides a quick way to get a reference to the current database in a format that can be used as a URL. I am working on an application that needed much the same thing except I needed a link to another Notes database. I decided to create a LS equivalent of the @WebDBName function that takes a single parameter. This parameter can be Nothing (current database), String (filepath of database) or a NotesDatabase object and returns the URL for that database. This function will be added to the next release of the Domino.@Functions namespace (possibly released on OpenNTF this weekend). '/**
' * Returns the name of a Notes database encoded for URL inclusion.
' *
' * @author Peter Presnell
' * @param Source Database path - Nothing = current database
' */
Function atfWebDBName(Source As Variant) As String
Dim Filepath As String
Select Case Typename(Source)
Case "NOTESDATABASE"
FilePath$ = Source.FilePath$
Case "STRING"
FilePath$ = Cstr(Source)
Case "OBJECT"
FilePath$ = Session.CurrentDatabase.FilePath$
End Select
atfWebDBName$ = atfReplaceSubstring(FilePath$,Split("\\: ",":"),Split("/:%20",":"))
End Function Note: In some cases an alternative to the above could be to use the NotesDatabase.HttpURL property.
The code for the atfReplaceSubstring (LS version of @ReplaceSubstring) is as follows:- '/**
' * Replaces specific words or phrases in a string with new words or phrases that you specify
' *
' * @author Peter Presnell
' * @param Source he string whose contents you want to modify.
' * @param Search A list containing the words or phrases that you want to replace.
' * @param ReplaceTo A list containing the replacement words or phrases.
' * @return The sourceList, with any values from fromList replaced by the corresponding value in toList.
' * If none of the values in fromList matched the values in sourceList, then sourceList is returned unaltered.
' */
Function atfReplaceSubstring(Source As Variant, Search As Variant, ReplaceTo As Variant) As Variant
Dim Results As Variant ' Interim results
Dim Index As Long
Dim ReplaceToItem As Variant ' Replacement value for match
Try:
On Error Goto Catch
If Isarray(Source) Then
Redim Results(Lbound(Source) To Ubound(Source))
For Index& = Lbound(Source) To Ubound(Source)
Results(Index&) = atfReplaceSubstring(Source(Index&),Search,ReplaceTo)
Next Index&
atfReplaceSubstring = Results
Else
atfReplaceSubstring = Source
If Isarray(Search) Then
For Index& = Lbound(Search) To Ubound(Search)
If Isarray(ReplaceTo) Then
If Index& > Ubound(ReplaceTo) Then
ReplaceToItem = ReplaceTo(Ubound(ReplaceTo))
Else
ReplaceToItem = ReplaceTo(Index&)
End If
Else
ReplaceToItem = ReplaceTo
End If
atfReplaceSubstring = atfReplaceSubstring(atfReplaceSubstring,Search(Index&),ReplaceToItem)
Next Index&
Else
' Covert all parameters to strings
If Isarray(ReplaceTo) Then
ReplaceToItem = Cstr(ReplaceTo(0))
Else
ReplaceToItem = Cstr(ReplaceTo)
End If
Source = Cstr(Source)
Search = Cstr(Search)
' Locate each occurence of search item and replace with replacement item
If Search <> ReplaceToItem Then
While Instr(atfReplaceSubstring, Search) > 0
atfReplaceSubstring = Left$(atfReplaceSubstring, Instr(atfReplaceSubstring, Search) - 1) + ReplaceToItem +_
Right$(atfReplaceSubstring, Len(atfReplaceSubstring) - Instr(atfReplaceSubstring, Search) - Len(Search) + 1)
Wend
End If
End If
End If
Exit Function
Catch:
Stop
Call ReportError
Exit Function
End Function
|
Ratings
0
|
I am now in the process of extending the .Domino Framerwork to support the publishing of Notes applications on a Blackberry client. A new DominoBES class has been added as a way of allowing Notes applications to communicate with a Blackberry device via the Blackberry Enterprise Server (BES). Unlike the rest of the framework, this class has been developed in Java due to the need to send an HTTP POST request. The first method - brow serChannelPush (see below) provides a wrapper for executing a Channel Push, effectively adding an icon to the Blackberry device, which when selected invokes the nominated URL. import java.net.*; public class DominoBES { public void DominoBES() { } public void browserChannelPush(String mdsHost, int mdsPort,String email,String docURL, String unreadIconURL, String readIconURL, String pushID, String pushTitle) { try { URL mdsURL = new URL("http",mdsHost,mdsPort,"push?DESTINATION=" + email + "&PORT=7874&REQUESTURI=/"); HttpURLConnection connection = (HttpURLConnection)mdsURL.openConnection(); connection.setRequestMethod("Post"); connection.setRequestProperty("X-RIM-Push-Type","Browser-Channel"); connection.setRequestProperty("X-RIM-Push-Title",pushTitle); connection.setRequestProperty("X-RIM-Push-Channel-ID",pushID); connection.setRequestProperty("X-Rim-Push-Read-Icon-URL",readIconURL); connection.setRequestProperty("X-Rim-Push-Unread-Icon-URL",unreadIconURL); connection.setRequestProperty("Content-Location",docURL); } catch (Exception e) { System.err.println("Push failure"); e.printStackTrace(System.err); } } }
import java.net.*; public class DominoBES { public void DominoBES() { } public void browserChannelPush(String mdsHost, int mdsPort,String email,String docURL, String unreadIconURL, String readIconURL, String pushID, String pushTitle) { try { URL mdsURL = new URL("http",mdsHost,mdsPort,"push?DESTINATION=" + email + "&PORT=7874&REQUESTURI=/"); HttpURLConnection connection = (HttpURLConnection)mdsURL.openConnection(); connection.setRequestMethod("Post"); connection.setRequestProperty("X-RIM-Push-Type","Browser-Channel"); connection.setRequestProperty("X-RIM-Push-Title",pushTitle); connection.setRequestProperty("X-RIM-Push-Channel-ID",pushID); connection.setRequestProperty("X-Rim-Push-Read-Icon-URL",readIconURL); connection.setRequestProperty("X-Rim-Push-Unread-Icon-URL",unreadIconURL); connection.setRequestProperty("Content-Location",docURL); } catch (Exception e) { System.err.println("Push failure"); e.printStackTrace(System.err); } } }
|
Ratings
0
|
The following is a list of limitations I have found in trying to implement JavaScript to run in Domino Web applications running on a BlackBerry device:- - Any JavaScript placed in the JS Header
- eval statement
- control.length
- control.disabled
|
Ratings
0
|
The .Domino Framework provides the LotusScript equivalent for many @Functions. These can be found in the Domino.@Functions namespace. Note: Because LotusScript does not allow the "@" character to be used for function names I have adopted the naming standard of atf (AT Function). I have just expanded the functionality of the atfDBColumn to provide support for NotesDocumentCollections. This may not be the most efficient way to achieve the result, but it is a very fast way to code the need to get a list of field values from a database/view/document collection - e.g. when prototyping. The expanded atfDBColumn method provides the ability to:-
- Pass either a database, view, or document collection as the source.
- Request either the contents of a column number or fieldname to be returned.
'/** ' * Returns an array containing the list of values for a specific column/field for any collection of documents ' * ' * @author Peter Presnell ' * @param ClassCache Not used ' * @param Database NotesDatabase object, server/filepath, or replicaid id, or Nothing (current database) ' * @param View NotesDocumentCollection, NotesView, name of view, or Nothing (All documents in database) ' * @!param Column Column number or name of field corresponding to values to be returned ' * @return List of values ' */ Function atfDBColumn(ClassCache As Variant, Database As Variant,View As Variant, Column As Variant) As Variant Dim iDB As New NotesDatabase("","") ' Database to perfrom lookup Dim iCollection As Variant ' View/Document Collection used to perfrom lookup Dim EntryList As NotesViewEntryCollection ' List of all entries in view Dim Entry As NotesViewEntry ' Current entry in view Dim Doc As NotesDocument ' Document that corresponds to current entry in view Dim ColumnValues As Variant Dim Results As Variant ' Interim results Dim Index As Long ' Counter used to loop through array Try: On Error Goto Catch ' Setup database/view Redim Results(0) Select Case Typename(Database) Case "NOTESDATABASE" Set iDB = Database Case "STRING" Call iDB.OpenByReplicaID(Session.CurrentDatabase.Server,Cstr(Database)) Case "STRING ()" If (Ubound(Database) = 1) Then If Database(1) = "" Then Set iDB = Session.CurrentDatabase Else Call iDB.Open(Database(0),Database(1)) End If End Select Select Case Typename(View) Case "NOTESDOCUMENTCOLLECTION" Set iCollection = View Case "NOTESVIEW" Set iCollection = View Set iDB = iCollection.Parent Case "OBJECT" If iDB Is Nothing Then Set iDB = Session.CurrentDatabase Set iCollection = iDB.AllDocuments Case "STRING" If (iDB Is Nothing) Then Set iDB = Session.CurrentDatabase Set iCollection = iDB
|