Pages

Wednesday, December 29, 2010

Grouping Radio Buttons inside Repeat Control in XPages

When you put a Radio button inside a repeat control in XPages and give it a group name as follows,

we explicitly assume that the radio buttons that get created as a result of the repeat control share the same  group name and behave in a the expected way. Ofcourse there is nothing wrong in expecting that. But its just that we miss a few points that are associated with the way XPages render them- so much for the documentations of XPages..... X(

To my amusement the following is what I experienced

I did panic a bit too but that is hidden :)
The fix that I got from the sources over the internet was to add the Skip Container attribute to the radio button tag.

Click the radio button and choosing its All Properties menu and specifying 1 against the skip containers attribute helped me get the normal functionality in a tricky way X(.

Well probably my words are confusing... Take a look into the following image...

Hope this helps :)

Wednesday, December 22, 2010

Issues with document.getElementById of computed fields in xpages

This is one of the most irritating issues that I encountered in XPages. Again XPages are not the ones to be blamed, it was me- did not understand how the elements got rendered on the browser.

The issue in short is that I was not able to retrieve or set value to a Computed Field on an XPage using client script

Say my field name on the XPage is "XPageEditBox"

now, document.getElementById("#{id:XPageEditBox}").value did not help me to get or set the values of the edit box.

This was because, I though that the edit box will be rendered as a html field and that was not the case. It was rendered as a span tag.


So the way to access the values is as follows,

var myValue=document.getElementById("#{id:XPageEditBox}").innerHTML to get and

document.getElementById("#{id:XPageEditBox}").innerHTML=myValue to set

Hope this helps :)

Friday, December 17, 2010

Controlling preview of views on the browser - $$ViewTemplateDefault

Though this has always been known, A few of my colleagues needed info on this. So just thought of sharing the same. Hope this helps some one who is looking for this :)

Create a form named "$$ViewTemplateDefault"  and key in a few text info as follows
Now when a view from the database is previewed this is how the following is a sample illustration of how they look on the client and the browser
On Client:
On Browser:

Hope this Helps :)

Thursday, December 16, 2010

Array Base Index and Base in Lotusscript (Option Base 0|1)

I happened to stumble upon the base index of arrays when a colleague of mine came up with a doubt in Base command in lotus script

It was interesting to find the following,

Create a couple of buttons and put the following fragments of code in each of them

option base 0
dim myArray[10] as string
msgbox cstr(lbound(myArray)) '--> this would prompt 0

This means now the array can contain 11 string values, where the index varies from 0 to 10

option base 1
dim myArray[10] as string
msgbox cstr(lbound(myArray)) '--> this would prompt 1

And this means the array can contain 10 string values, where the index varies from 1 to 10

Inference :

Option Base 1 in lotus script implies that the arrays will have a lower bound of 1 as is the case with Formula language

Extra Note :
In case of Java, an array of the following sort say,
String[] x= new String[10]

x shall hold 10 values with indices varying from 1 to 10

Hope this helps :)

Video: Using the XPages Extension Library Dojo Grid and REST Services Controls

Wednesday, December 15, 2010

User .jar files must be considered a design element



Monday, December 6, 2010

Get the handle of the document highlighted in a view

Inorder to obtain the handle of a document highlighted in a view, use the following property

caretNoteID$ = notesUIView.CaretNoteID


Though this is present all along, I never got to use it cos I never really put UIClasses to any good use because I was blinded by their limitations rather than their capability...


Had a tough time finding this one vhsssss.... oh....


Hope this helps some one :)

Wednesday, December 1, 2010

Get notes temporary directory path in lotusscript

Declare Function w32_OSGetSystemTempDirectory Lib "nnotes" Alias "OSGetSystemTempDirectory" ( Byval S As String) As Integer 
Declare Function mac_OSGetSystemTempDirectory Lib "NotesLib" Alias "OSGetSystemTempDirectory" ( Byval S As String) As Integer 
Declare Function linux_OSGetSystemTempDirectory Lib "libnotes.so" Alias "OSGetSystemTempDirectory" ( Byval S As String) As Integer 
Const ERR_UNSUPPORTED_PLATFORM = 20300 ' or other value you choose. 




Function GetNotesTempDirectory() As String 
' Returns the path of the temporary directory used by Notes. 
Dim session As New NotesSession 
Dim d As String * 256 
Dim s% 
Select Case session.Platform 
Case "Linux" 
s% = linux_OSGetSystemTempDirectory(d) 
Case "Macintosh" 
s% = mac_OSGetSystemTempDirectory(d) 
Case "Windows/32" 
s% = w32_OSGetSystemTempDirectory(d) 
Case Else 
Error ERR_UNSUPPORTED_PLATFORM, "In GetNotesTempDirectory, platform not supported: " & session.Platform 
End Select 
GetNotesTempDirectory = Left$(d, s%) 
End Function


Hmmm... this is a copy paste from moorthydaniel's blog... seemed to be a nice one...
So its my turn to share the same

God got to understand those lib stuffs... seems like a head ache :(

Hope this helps :)

Lotusscript code to get the mime content of an image

Function  getMimeofImage( imagePath As String,targetFilePath As String) As Boolean
'************************************************************************************************************ 
'@Purpose     :   To create mime equivalent of an image file in a text format and export the same to a target file
'************************************************************************************************************

'mark the flow of control moving inside the current function
getMimeofImage=False

'declare variables and objects necessary for further manipulation
Dim session As New notessession
Dim currDB As NotesDatabase
Dim tempDoc As NotesDocument
Dim stream As NotesStream
Dim mimeEntity As NotesMimeEntity
Dim imageSize As Long

'initiation
'handler errors in case of abrupt termination
On Error Goto mimeErrHandler

'set handle for the current database
Set currDb=session.CurrentDatabase
'create a temporary document
Set tempDoc=currDb.CreateDocument

'create a stream object
Set stream = session.CreateStream
If Not stream.Open(imagePath) Then
Error 1404, "Cannot open file " & imagePath & " for processing."
Exit Function
End If

imageSize = stream.Bytes

Set tempDoc=currDB.CreateDocument
Set mimeEntity = tempDoc.CreateMIMEEntity
If Right(Lcase(imagePath), 4) = ".gif" Then
Call mimeEntity.SetContentFromBytes(stream, "image/gif", ENC_NONE)
Else
Call mimeEntity.SetContentFromBytes(stream, "image/jpeg", ENC_NONE)
End If
Call mimeEntity.EncodeContent(ENC_BASE64)

Call stream.Close


Set stream=Nothing
Set stream=session.CreateStream
Call stream.Open(targetFilePath)
If stream.Bytes <> 0 Then
Call stream.Truncate
End If
' Call stream.WriteText()

Call stream.WriteText(|<?xml version='1.0'?><document xmlns='http://www.lotus.com/dxl' version='8.5' maintenanceversion='1.0' replicaid='652577AF00410F29' form='dxlManipulations'><noteinfo noteid='94e' unid='8F605FA904982F43652577EB00207375' sequence='1'><created><datetime>20101130T112427,09+0530</datetime></created><modified><datetime>20101130T112427,10+0530</datetime></modified><revised><datetime>20101130T112427,09+0530</datetime></revised><lastaccessed><datetime>20101130T112427,09+0530</datetime></lastaccessed><addedtofile><datetime>20101130T112427,09+0530</datetime></addedtofile></noteinfo><updatedby><name>CN=Karthikeyan A/O=Maargasystems</name></updatedby><item name='rt'><richtext><pardef id='1'/><par def='1'><picture width='183px' height='62px'><gif>|+mimeEntity.ContentAsText+|</gif></picture></par></richtext></item><item name='TestField'><text>3</text></item></document>|)
' Call stream.WriteText()

Call stream.Close

'mark the flow of control moving out of the current function
getMimeofImage=True
Exit Function
mimeErrHandler:
Print "Error ***" & Error & "*** occured on line ***" & Cstr(Erl) & "*** with error number ***"   _
& Cstr(Err) & "*** in Method ""CreateMIMEEntity"" "
Exit Function
End Function

Hope this helps :)