Tips about programming, tips about software and web development in general and links to cool/useful tech sites
2006-04-28
Notes client: action bar properties are not rendered in the client
If the display border property of a view or form action bar is set to Always but it doesn't show when viewed in the client, check under File -> Preferences -> User Preferences -> Additional Options and make sure the option "Standard dialog boxes" is not checked.
Windows: Usb Hub is not recognized ("Unknown device")
If Windows XP does not recognize a Usb hub, and categorizes it as an "Unknown Device" even after updating the drivers, unplug the electrical cord from the hub and try again.
2006-04-06
Notes: Bubble Sorting a Document Collection
«Searching a database using db.ftsearch is pretty fast and efficient but ordering based on a field value in the documents is not possible. What is required is something akin to a SQL ORDER BY clause but alas we don't have one and have to resort to sorting the collection the old fashioned way... by implementing a bubble sort.
Usage
Dim vCollection As NotesDocumentCollection Set vCollection = vSearchDatabase.ftsearch(aQuery, 501, FT_SCORES, FT_FUZZY) Set vCollection = Global_SortCollection(vCollection, "Person_Surname")
The sort function requires two parameters, the first a NotesDocumentCollection with documents in it and the second a field name to use to sort the documents, in the example above the documentcollection "vCollection" will be sorted by "Person_Surname".
The function works by converting the document collection into an array of documents, doing a bubble sort on the array and then converting the array back into a new document collection.
The Code
Function Global_SortCollection(aCollection As NotesDocumentCollection, aField As String) As Variant Dim vCollectionDB As NotesDatabase Dim vDocTemp As NotesDocument Dim vCollectionSorted As NotesDocumentCollection Dim vDocArray() As String Dim vLower As Integer Dim vUpper As Integer Dim vBottomMax As Integer Dim vLoop As Integer Dim vLoopTopHalf As Integer Dim vLoopBottomHalf As Integer Dim vMidPoint As Integer Dim vTarget As String Set vCollectionDB = aCollection.Parent Redim vDocArray(aCollection.count-1) As String 'CONVERT DOCUMENT COLLECTION TO ARRAY Let vLoop = 0 Set vDocTemp = aCollection.GetFirstDocument Do While Not vDocTemp Is Nothing vDocArray(vLoop) = vDocTemp.GetItemValue(aField)(0) + "~" + vDocTemp.UniversalID Set vDocTemp = aCollection.GetNextDocument(vDocTemp) vLoop = vLoop + 1 Loop 'SHELL SORT THE ARRAY vLower = Lbound( vDocArray( ) ) vUpper = Ubound( vDocArray( ) ) vMidPoint = 1 'DETERMINE A STARTING MID POINT TO THE ARRRAY Do vMidPoint = (3*vMidPoint) + 1 Loop Until vMidPoint > vUpper - vLower + 1 'LOOP THROUGH THE ARRAY Do vMidPoint = vMidPoint \ 3 vBottomMax = vLower + vMidPoint - 1 For vLoopTopHalf = vBottomMax + 1 To vUpper vTarget = vDocArray(vLoopTopHalf) vLoopBottomHalf = vLoopTopHalf 'COMPARE TOP HALF OF ARRAY WITH BOTTOM HALF Do While vDocArray( vLoopBottomHalf - vMidPoint ) > vTarget vDocArray(vLoopBottomHalf) = vDocArray(vLoopBottomHalf - vMidPoint) vLoopBottomHalf = vLoopBottomHalf - vMidPoint If (vLoopBottomHalf <= vBottomMax) Then Exit Do Loop If (vLoopBottomHalf <> vLoopTopHalf) Then vDocArray(vLoopBottomHalf) = vTarget Next Loop Until vMidPoint = 1 'CREATE A NEW EMPTY DOC COLLECTION Set vCollectionSorted = vCollectionDB.Search("",Nothing,0) 'CONVERT ARRAY TO DOC COLLECTION For vLoop = 0 To Ubound(vDocArray) Set vDocTemp = vCollectionDB.GetDocumentByUNID(Strrightback(vDocArray(vLoop), "~")) Call vCollectionSorted.AddDocument(vDocTemp) Next vLoop 'RETURN THE DOCUMENT COLLECTION Set Global_SortCollection = vCollectionSorted End Function
Conclusion
A simple yet extremely useful function that belongs in everyone's global routines script library.»
(Source)
2006-04-05
Notes - Lotus Script: Resume without error
Scenario:
A script ends and returns the "Resume without error" message, even though no error was thrown during it's execution.
Checking the Error$ function, it may return the message "Variant does not contain a container".
Possible solution:
Include in the script the "Option Declare" statement, correct all errors (undeclared variables) and save it.
A script ends and returns the "Resume without error" message, even though no error was thrown during it's execution.
Checking the Error$ function, it may return the message "Variant does not contain a container".
Possible solution:
Include in the script the "Option Declare" statement, correct all errors (undeclared variables) and save it.
2006-03-27
Domino: Extend Authentication For Websites, Single Sign-on and Persistent Sessions
Ever wanted to be able to authenticate users on your Domino Web Server using a Web Service, against a MySQL database, a text file or some other external source? Or how about changing the default Domino behaviour so that user sessions remain active for days or weeks. It's easy and I'll show you how using Apache Tomcat and a simple Java Servlet.
More >
Notes - Web: Ajax Drag-n-Drop Sorting of Documents
«Imagine the following situation - say you've got a set of documents which are all children of one container document. From within this parent container document you want to be able to quickly change the order in which the child documents appear. Sound familiar?»
More >
Tools: Yahoo! UI Library
«The Yahoo! User Interface Library is a set of utilities and controls, written in JavaScript, for building richly interactive web applications using techniques such as DOM scripting, HTML and AJAX. The UI Library Utilities facilitate the implementation of rich client-side features by enhancing and normalizing the developer's interface to important elements of the browser infrastructure (such as events, in-page HTTP requests and the DOM.»
More >
Domino: ajax picklist (either for names.nsf or other dbs)
«One of the things which has bugged me for a long time is getting a good name picker.(...)So the requirements:
.A generic popup window which allows a user to select one or many values from a very large view (100,000 documents plus)
.It has to perform well
.It has to be cross browser compatable (at least IE and Firefox)
.It has to be easily re-usable»
More >
***
«I needed a name picker for a project I'm working on. After looking at various solutions available I couldn't find one I was happy with and decided to the revisit the approach and write my own. (...) What I've tried to move away from is the convention that a Name Picker must, for some reason, be a popup window.»
More >
Domino: Ajax Powered Login
«Getting tired of ugly Domino login forms or faceless browser pop up dialogs? Once again showing a flair for melding various techniques, Mark Barton brings us an elegant, cutting edge modal login interface utilizing DHTML, Ajax, and JSON JavaScript notation.»More >
2006-01-12
Notes - LotusScript: function returning a notes document
Problem:
Even though the document is instatiated inside the function it is not returned to the calling code.
Explanation:
You're probably declaring and setting the value of the NotesDocument's parent database inside the function, which is outside the scope of the calling function. As a result, although you return the right document, the containing database is no longer open.
You can either pass the database *and* the document and pass them both back, or you can declare the database globally .
You can either pass the database *and* the document and pass them both back, or you can declare the database globally .
From: Notes Forum
Labels:
lotus notes,
lotus script,
problem solver,
tips
2005-12-30
Notes - Web: Alignment of Checkboxes on the Web
This can be done by adding some HTML around the checkbox field, like this:
Don't forget to mark this code as Pass-Thru HTML.
And now, on the checkbox field choices, this should be added to the end of the choice where the list should break to a new column:
</td><td valign="top">
Example of list:
-------------
apple | a
orange | or
strawberry [</td><td valign="top">] | s
pineapple | p
banana | b
other [</td><td valign="top">] | o
-----------------------
<table cellspacing="0" cols="5" cellpadding="0" border="0" valign="top" rows="1"><tbody><tr><td><br />
Checkbox Field
</td></tr></tbody></table>
Don't forget to mark this code as Pass-Thru HTML.
And now, on the checkbox field choices, this should be added to the end of the choice where the list should break to a new column:
</td><td valign="top">
Example of list:
-------------
apple | a
orange | or
strawberry [</td><td valign="top">] | s
pineapple | p
banana | b
other [</td><td valign="top">] | o
-----------------------
2005-12-29
Notes - Web: select all javascript function for checkboxes (multivalue too)
function selectAll(fieldname, bFlag) {
var checkField = document.forms[0].elements[fieldname];
if (checkField.length)
{
for (i=0; i<checkField.length; i++)
{
if (checkField[i].checked)
{
checkField[i].checked = bFlag;
}
}
}
else if (checkField.checked)
{
checkField.checked = bFlag;
}
}
2005-12-27
Windows - ActiveX: ActiveX is enabled on IE but does not work
Other possible symptoms:
- unable to access MMC console (access rights message error, although having administrator rights) and/or unable to save a new one ("MMC cannot save the console");
- windows update not working or crashing the IE browser;
- msn messenger unable to connect.
Solution:
Go to Start -> Run and write: regsvr32 MSXML3.dll and click OK.
- unable to access MMC console (access rights message error, although having administrator rights) and/or unable to save a new one ("MMC cannot save the console");
- windows update not working or crashing the IE browser;
- msn messenger unable to connect.
Solution:
Go to Start -> Run and write: regsvr32 MSXML3.dll and click OK.
2005-12-14
Notes - client: hide-when for layers
To hide a layer in the notes client, select the layer's Anchor as it was text and use the text's hide-when tab on the properties dialog box to control the appearance and disappearance of the layer.
2005-12-06
Notes - Client: View autoframe
The view autoframe property only works for the Web, but for the client there's the following workaround (undocumented feature and only works for the database default frameset):
. Create a Frameset with only one Frame and call this Frame NotesView and select any view;
. In the database default Frameset, open the previously created Frameset in one of it's frames.
Now, when opening a view (through a link, for example), the database will force the default frameset to open "around" the view.
. Create a Frameset with only one Frame and call this Frame NotesView and select any view;
. In the database default Frameset, open the previously created Frameset in one of it's frames.
Now, when opening a view (through a link, for example), the database will force the default frameset to open "around" the view.
2005-11-25
Notes - Lotus Script: Replace Substring
Function ReplaceSubstring(sourcestr As String, fromstr As String, tostr As String) As String
' This function replaces characters in a string. Take all the occurrences of "fromstr"
' in the source string and replace them with "tostr"
Dim tempstr As String
Dim convstr As String
Dim i As Long
Dim length As Long
tempstr = sourcestr
If Len(fromstr) = 0 Then
ReplaceSubstring = sourcestr
Exit Function
End If
If Instr(tostr, fromstr) <> 0 Then ' If, for example, "\" is being replaced with "\\"
' Find a character (or set) that is not in the source string.
' Try the extended characters (over 128 ASCII)
i = 128
length = 1
convstr = ""
While convstr = ""
If Instr(tempstr, String$(length, Chr$(i))) = 0 Then convstr = String$(length, Chr$(i))
i = i + 1
If i = 256 Then ' If all the extended characters were in there
length = length + 1 ' Start over, but try 2 extended characters (or 3 or 4)
i = 128
End If
Wend
' Go through tempstr twice - once replacing fromstr with the computed
' string, then replacing the computed string with tostr
While Instr(tempstr, fromstr) <> 0
tempstr = Left(tempstr, Instr(tempstr, fromstr)-1) & convstr _
& Mid(tempstr, Instr(tempstr, fromstr)+Len(fromstr))
Wend
While Instr(tempstr, convstr) <> 0
tempstr = Left(tempstr, Instr(tempstr, convstr)-1) & tostr _
& Mid(tempstr, Instr(tempstr, convstr)+Len(convstr))
Wend
Else ' It's a normal replace substring call - fromstr is not part of tostr
While Instr(tempstr, fromstr) <> 0
tempstr = Left(tempstr, Instr(tempstr, fromstr)-1) & tostr _
& Mid(tempstr, Instr(tempstr, fromstr)+Len(fromstr))
Wend
End If
ReplaceSubstring = tempstr
End Function
' This function replaces characters in a string. Take all the occurrences of "fromstr"
' in the source string and replace them with "tostr"
Dim tempstr As String
Dim convstr As String
Dim i As Long
Dim length As Long
tempstr = sourcestr
If Len(fromstr) = 0 Then
ReplaceSubstring = sourcestr
Exit Function
End If
If Instr(tostr, fromstr) <> 0 Then ' If, for example, "\" is being replaced with "\\"
' Find a character (or set) that is not in the source string.
' Try the extended characters (over 128 ASCII)
i = 128
length = 1
convstr = ""
While convstr = ""
If Instr(tempstr, String$(length, Chr$(i))) = 0 Then convstr = String$(length, Chr$(i))
i = i + 1
If i = 256 Then ' If all the extended characters were in there
length = length + 1 ' Start over, but try 2 extended characters (or 3 or 4)
i = 128
End If
Wend
' Go through tempstr twice - once replacing fromstr with the computed
' string, then replacing the computed string with tostr
While Instr(tempstr, fromstr) <> 0
tempstr = Left(tempstr, Instr(tempstr, fromstr)-1) & convstr _
& Mid(tempstr, Instr(tempstr, fromstr)+Len(fromstr))
Wend
While Instr(tempstr, convstr) <> 0
tempstr = Left(tempstr, Instr(tempstr, convstr)-1) & tostr _
& Mid(tempstr, Instr(tempstr, convstr)+Len(convstr))
Wend
Else ' It's a normal replace substring call - fromstr is not part of tostr
While Instr(tempstr, fromstr) <> 0
tempstr = Left(tempstr, Instr(tempstr, fromstr)-1) & tostr _
& Mid(tempstr, Instr(tempstr, fromstr)+Len(fromstr))
Wend
End If
ReplaceSubstring = tempstr
End Function
2005-11-14
Notes - Web: bypassing the $$Return field
To avoid the processing of the $$Return field, save the document with the command:
@Command([FileSave])
If using Javascript then instead of using document.forms[0].submit(), create a button with the above formula and give it an id (ex:bt_save) and then on the submit script do:
document.all.bt_save.click()
The url of the document will be the original one (http://server_name//database_name/form_name?OpenForm), with "&Seq=1" (2,3,...) appended in the end.
Labels:
code,
javascript,
lotus notes,
submission,
tips
2005-11-11
Notes - Web: simulate notes client continue=false behaviour on web save
Form:
(Server_Name e Path_Info are CGI fields)
WebQuerySaveAgent:
(if the validation fails, then the doc will not be saved because of the SaveOptions field value)
Form - onload:
(optionally)
(Server_Name e Path_Info are CGI fields)
. field SaveOptions=0
. field $$Return= "[http://" + Server_Name + @Left(Path_Info;"nsf") + "nsf/0/"+ @Text(@DocumentUniqueID) + "?OpenDocument]"
WebQuerySaveAgent:
(if the validation fails, then the doc will not be saved because of the SaveOptions field value)
if (validateForm) doc.SaveOptions=1
Form - onload:
(optionally)
if (document.all.field_error.value!="") alert("Document not saved. \n Errors:" + document.all.field_error.value)
Labels:
code,
javascript,
lotus notes,
submission,
tips
2005-11-10
Web - Js: generic form validation function
function isSomethingSelected( obj ){
for (var r=0; r < obj.length; r++){
if ( obj[r].checked ) return true;
}
}
/*--- form validation--- */
function checkRequiredField(sFname)
{
field = self.document.getElementById(sFname);
sType = field.type.toLowerCase();
var bOk = true;
switch (sType)
{
case "text":
case "textarea" :
if (field.value=="") bOk=false;
break;
case "checkbox":
case "radio":
if ( !field[0]) { //handle single item group first
if ( !field.checked ) bOk=false;
}
else
{
if (!isSomethingSelected(field)) bOk=false;
}
break;
case "select-one":
if (field.selectedIndex == 0) bOk= false;
break;
case "select-multiple":
if (field.selectedIndex == -1) bOk=false;
break;
default:
break;
}
return bOk;
}
for (var r=0; r < obj.length; r++){
if ( obj[r].checked ) return true;
}
}
/*--- form validation--- */
function checkRequiredField(sFname)
{
field = self.document.getElementById(sFname);
sType = field.type.toLowerCase();
var bOk = true;
switch (sType)
{
case "text":
case "textarea" :
if (field.value=="") bOk=false;
break;
case "checkbox":
case "radio":
if ( !field[0]) { //handle single item group first
if ( !field.checked ) bOk=false;
}
else
{
if (!isSomethingSelected(field)) bOk=false;
}
break;
case "select-one":
if (field.selectedIndex == 0) bOk= false;
break;
case "select-multiple":
if (field.selectedIndex == -1) bOk=false;
break;
default:
break;
}
return bOk;
}
2005-11-09
Web - Js: including javascript stored in a separate file
<script type="text/javascript" src="/file_path/file_name.js"></script>
Subscribe to:
Posts (Atom)