This sample is only to teach you how to create your first wire within a composite application. This is targeted for new users who have no experience in composite applications and want to understand the basic concept of a wire and how it works between two notes objects. The finished database is also supplied as an attachment. When completed you will have a view passing the value of a column over to a document window.
Steps
1. From the menu click File -> Application -> New. (Shortcut is CTRL-N).
2. In the new Application dialog box enter in the following information.
- Title: My First Wire
- File Name: My First Wire.nsf
- Template: - Blank Composite Application -
You can leave the other options as default. It should look like this. If it does then click OK.
2. The database will open and you will get a blank screen. For the moment we can ignore this. Close the database and reopen it in designer.
3. Go to "Composite Applications -> Wiring Properties" section and click "New Wiring Properties".
4. Enter the name "My Wire Properties" and click OK.
5. With "My Wire Properties" selected click "Open File".
6. The Wiring Properties Editor should now show up. On the Properties tab Click "Add". Then enter in the following.
- Name: field1
- Type: String
- Title: Field 1 Changed
- Click on "Allow Publishing".
This is the property that we are going to pass to the wire.
7. Click the Actions tab and press "Add" then enter in the following information.
Action Details
- Name: myAction
- Title: Display Field 1 information
- Action Input Parameter
- Name: field1
- property: String
8. Close the Property Broker Editor. You should see a "Save Resource" dialog. Click Yes.
9. Your wiring properties are now saved to the disk. You need to refresh them into the database. To do this click the refresh button. Select the correct WSDL file (normally already selected by default) and click Open.
10. Select forms section in designer and click New Form.
11. On the form create a text field called "Field1".
12. From the create menu select "Action -> Action..."
13. Set the Action to LotusScript. Then open the Action properties and give it the name "Display Field 1 Details". Make sure "Include action in Action bar" and "Include in Action menu" are not selected.
14. Select the third tab on the action properties (propeller cap). Set the "Composite Settings" action name to "myAction". This tells the property broker that if "myAction" is triggered it will run this Action.
15. For the moment we aren't going to write any code (we leave that for the end). Close the form. You will be prompted to save the form for the Form name. Call it "MyForm" and click OK.
16. Expand the views section and click on the "(Untitled)". This will open the view for editing.
17. Select the first column, open the properties and give it a name of "Field 1". Set the column to display a Field and set it to "Field1".
18. On the properties of the field column select the last tab (looks like propeller cap). In the bottom of the tab set the "Composite Settings" set the Property to "field1" in the drop down list. You have now set up this column to send the value of the selected column in the view to the property broker when the user selects a different document.
19. Save and close the view. When prompted for the name call it "myView".
20. Now go back to Lotus Notes and open the application (CTRL-O). You will be greeted with a blank screen. Select the actions menu and select "Edit Application". This will open the Application Editor.
21. Expand the Component Pallette if it is not already by clicking on the bar on the right. Right click in the Component Pallette (not on an item) and select the menu item "Add Components -> Add NSF Component".
22. On the new NSF Component dialog box click "Browse...". A locate Object should appear. Select the following options.
- Kind of object: View
- Application: - Current database -
- View: myView
Click OK.
23. You will be returned to the new NSF component dialog box. You will see that the "Notes URL" is filled out.. Fill out the remaining details.
- Component Name: View Component
- Category: General
Click OK.
24. You need to create another NSF component by right clicking in the component pallette and select the menu item "Add Components -> Add NSF Component".
25. On the new NSF Component dialog box click "Browse...". A locate Object should appear. Select the following options.
- Kind of object: Form
- Application: - Current database -
- View: myForm
Click OK.
26. You will be returned to the new NSF component dialog box. You will see that the "Notes URL" is filled out.. Fill out the remaining details.
- Component Name: Form Component
- Category: General
Click OK.
27. Drag the "View Component" and "Form Component" to the center area so that they are displayed. You drag the Form Component near the bottom of the area so that both appear as shown.
28. Right click "View Component" on the left hand side and select "Wiring".
29. In the Wiring view drag the "Field 1 Changed" to the "Display Field 1 information". You have now created the connection of the view to the form in your composite application. Close the
30. Close the wiring view. You will be asked to save. Click Yes.
31. Close the composite application editor. You will be asked to save. Click yes.
32. You are now back in your composite application. Everything is ready to go! However your action doesn't have any code in it so nothing will happen. We will add code to that, but before we do lets create a few documents. To do that you need to click on the view section of the composite application and select "Create -> myForm" from the menu. Create a few documents and save them. So it looks like something below.
33. Go back to Designer and edit the form "myForm" and select the action "Display Field 1 Details". We are going to enter in code into the agent.
34. Enter in the following code. Save and close the form. (See further down for explanation of code).
Dim session As New NotesSession
Dim dataBase As NotesDatabase
Dim propertyBroker As NotesPropertyBroker
Dim field1 As NotesProperty
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = workspace.CurrentDocument
Set propertyBroker = session.GetPropertyBroker
If Not propertyBroker Is Nothing Then
Set field1 = propertyBroker.getProperty("field1")
Dim doc As NotesDocument
Set doc = uidoc.Document
doc.SaveOptions = "0"
uidoc.FieldSetText "Field1", field1.Values(0)
End If
35. Your application is complete! Now open the application and select a document. It should update the other window with the value of the selected document.
Explanation of the Code
There are a few ways to interact with the Property broker but this is the most basic. Here is an explanation of each part of the code.
First we set up the variables we are going to use.
Dim session As New NotesSession
Dim dataBase As NotesDatabase
Dim propertyBroker As NotesPropertyBroker
Dim field1 As NotesProperty
We make a connection to the current document which is the "form component" window.
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = workspace.CurrentDocument
Now make a connection to the propertyBroker. This is the core section to interact with the wiring system.
Set propertyBroker = session.GetPropertyBroker
We check to ensure that the property broker is working correctly before we run any other code.
If Not propertyBroker Is Nothing Then
End If
We get the value of "field1" from the property broker which was passed in by the "View component".
Set field1 = propertyBroker.getProperty("field1")
These next three lines are just to tell the "Form component" that we don't want to save it as a document. This is to stop the "Do you want to save" popping up if we close the application.
Dim doc As NotesDocument
Set doc = uidoc.Document
doc.SaveOptions = "0"
Because the last lines interacted with the backend document it would eras e anything entered into the UI document, so this line has to come after them. This will display the "field1" in the "Form component".
uidoc.FieldSetText "Field1", field1.Values(0)
Download
Download the sample here: My+First+Wire.zip