12 entries

Translate page




Home > Lotus Notes component advanced development > Running NSF Components in context

Running NSF Components in context

This page introduces two new LS APIs and @Formulas for working with two new features in Composite Applications for 8.0.1.
- NotesUIWorkspace.IsInCompositeApp is a new property to determine if the current database is opened inside a composite app or not. It returns a boolean value of TRUE or FALSE.
- NotesUIWorkspace.GetComponentViewPreference is a new method that returns a variant array of value(s) set for the preference on a particular notes component in the advanced properties dialog in CAE.
- @IsInCompositeApp is similar to the property with the same name above.
- @GetComponentViewPreference is identical to its namesake method above.

Prerequisites

In order to be able to use the GetComponentViewPreference API or @Formula, a page level preference in the advanced page properties for the composite app "com.ibm.notes.enable.preferences = true"needs to be set.



Usage

@IsInCompositeApp: You could use the IsInCompositeApp check in a view or a form or a page to customize the behavior of that particular design element.As an example, we can hide a column in a view or an action from the action bar by simply using @IsInCompositeApp in the infobox properties for that design element like this



IsInCompositeApp:
Similarly,you can use the LotusScript property IsInCompositeApp to decide whether or not to do any property broker related operations. This snippet of code on the PostOpen event of a view decides whether or not to look for a particular property based on if the view is opened as part of a composite application

Sub Postopen(Source As Notesuiview)

Dim ui As New NotesUIWorkspace

If (ui.IsInCompositeApp) Then
Dim session As New NotesSession
Dim pb As NotesPropertyBroker
Set pb = session.GetPropertyBroker

If pb.HasProperty("CanonicalName") Then
Print "Found the property."
Else
Print "oops! no such property."
End If

End If

End Sub

+GetComponentViewPreference($prefID) / @GetComponentViewPreference($prefID) : Like mentioned at the beginning, in order for this LotusScript method or @Formula to work, you need a page level preference "com.ibm.notes.enable.preferences" set to "true" on the parent page containing our notes component. For the purpose of our discussion, this is the preference I'll refer to "com.ibm.notes.filterBy" which is set to "ContractorRegion"



The OnSelect event of the 'AllByCompany' view does the following:

  • query for the value set against this preference
  • look up for a field with the same name as the return value above (ContractorRegion)
  • publish the value of that field for the currently selected document in that view.
Here is the snippet:

Dim ui As New NotesUIWorkspace
Dim db As NotesDatabase
Dim var,value As Variant
Dim s As New NotesSession
Dim doc As NotesDocument
Dim pb As NotesPropertyBroker

Set db = s.CurrentDatabase
Set doc = db.GetDocumentByID(Source.CaretNoteID)

If (ui.IsRunningInsideComposite) Then
var = ui.GetComponentViewPreference("com.ibm.notes.filterBy")

If Not Isnull(var(0)) And Not (doc Is Nothing) Then
Print "got a value of " +var(0)+ " from GetComponentViewPreference"
value = doc.GetItemValue(var(0))
Else
value = Null
End If

If Not Isnull(value(0)) Then
Set pb = s.GetPropertyBroker
Call pb.SetPropertyValue("ManagerPart",value(0))
Call pb.Publish()
Else
Print "got null value for Manager name"
End If

  • Reading Multi-value preferences using GetComponentViewPreference:+The procedure is identical, except that when specifying multiple values for the preference in the advanced properties dialog in CAE, use a semi-colon separated list:


Advantages

Using either of these APIs will enable you to use the same Notes component in one or more composite applications with different behavior in each instance.



This Version: 0 May 27, 2008 11:12:16 AM by Robert F Harwood  
Originally Added: Version 1 May 19, 2008 2:07:28 PM by Robert F Harwood, Niklas Heidloff