Search DominoPower's 11,441 Lotus-related article archive 
Home
EasyPrint
News details Click here for the RSS feed's XML code. This is not a browser URL.
Articles-only Click here for the RSS feed's XML code. This is not a browser URL.
Twitter Feed Click here for the Twitter feed.
Implementing dynamic drop-down menus using Domino and Internet Explorer (continued)

Save the form.

Step 5: Create the view containing the raw data
Create a view and name it "lookupvalues".

The view should contain two columns.

Since this article is aimed at experts, I won't go into detail about how to create a view and populate it with data. Instead I'll show you how the finished view should look and you can set it up. It's shown in Figure D.

FIGURE D


The finished view should look like this. Roll over picture for a larger image.

Step 6: Create the agent
Create an agent and name it the following:

WebQueryOpenAgent for demo form

Set the agent to be a "Shared agent".

Set the agent to run "Manually From Agent List".

Set the agent to "Run Once (@commands may be used)".

Set the "run" dropdown to "Lotuscript".

This is shown in Figure E.

FIGURE E


Set up your agent. Roll over picture for a larger image.

This agent is executed when the page is loaded. It goes to the view, grabs the columns, and returns them formatted as a JavaScript array.

Its output goes into a field on the form positioned inside a pair of <script> tags, thereby converting the contents of the view into a client side JavaScript array.

The final output of the agent will be JavaScript code that looks like this (you don't need to type this in anywhere for our demonstration, its just to help understand the agent):

//Array of options for dropdown fields;
var dropdownarray = ;

Here's some p-code to help understand what the agent does:

  1. Set up the various objects needed, clear the variables;
  2. Get the view;
  3. Set up a buffer - we'll put all our output into the buffer;
  4. Add the start of the JavaScript array structure to the buffer;
  5. Iterate through each of the view rows and add them to the buffer, structured as JavaScript array rows;
  6. Add the end of the JavaScript array structure to the buffer;
  7. Put the buffer into the tempJavaScriptarray field on the form.

Here's the code of the agent. Put it into the "Initialize" section of the agent:

Sub Initialize

' builds a JavaScript array of Manufacturers and models
' this gets used at the client for dynamically updating dropdown fields

' Set up required objects
Dim session As New NotesSession
Dim sourcedoc As NotesDocument
Set sourcedoc = session.DocumentContext

Dim sourceDb As NotesDatabase
Dim view As NotesView
Dim entry As NotesViewEntry
Dim vc As NotesViewEntryCollection
Dim tmpbuffer As String
Dim tmpManufacturer As String
Dim tmpmodel As String
Dim i As Integer

Set sourceDb = session.CurrentDatabase
Set view = sourcedb.getView("lookupvalues")
Set vc = view.AllEntries

tmpManufacturer = ""
tmpmodel = ""
tmpbuffer = ""
tmpbuffer = tmpbuffer + {//Array of options for dropdown fields; } + Chr ( 13 )
tmpbuffer = tmpbuffer + {var dropdownarray = [}

For i = 1 To vc.count
Set entry = vc.GetNthEntry( i )

tmpManufacturer = entry.ColumnValues(0)
tmpmodel = entry.ColumnValues(1)

' put a comma and a carriage return to separate array values
If i >1 And i =< vc.count Then
tmpbuffer = tmpbuffer + {,} + Chr ( 13 )
End If

' add each entry
tmpbuffer = tmpbuffer + {['} + tmpManufacturer + {'} + {,}
tmpbuffer = tmpbuffer + {'} + tmpmodel + {'} + {]}

Next i

' close off the array
tmpbuffer = tmpbuffer + {];} + Chr ( 13 )
tmpbuffer = tmpbuffer + Chr(13) + Chr ( 13 ) + Chr ( 13 ) + Chr ( 13 )

' shove the buffer into the field value on the form
sourcedoc.tmpJavaScriptarray = tmpbuffer

End Sub


« Previous  ·  1  ·  2  ·  3  ·  4  ·  5  ·  6  ·  7  ·  Next »
Other articles you might like
Home > Internet Technologies > JavaScript (13 articles)
   Sorting your Domino views with JavaScript
   Give your Domino views life with DHTML
   Using dynamically generated HTML to thwart spam email address harvesting
Home > Internet Technologies > HTML and CSS (15 articles)
   Using a reusable code approach to HTML select option lists
   One reader's opinion on HTML mailing
   Keep lookin' good with Cascading Style Sheets
Get Weekly Email Updates
Subscribe to our regular weekly email newsletter. It's packed with tips, reviews, deep analysis, and the latest news.
 
Recent DominoPower Articles
Application development, William Shatner, and the origin of the universe
Learn Domino Designer 8.5 for free
The (near) future of Sametime, Quickr, Connections, and Symphony
Inside the IBM Innovations lab
Lotusphere 2010: Hot fixes and cool news for Notes, Domino, and LotusLive
Lotusphere 2010: mobility and collaboration
2010: A Lotusphere of change
Latest Lotus Headlines
Xpages not loading? JVM errors? - Solution
How to implement an iCalendar feed into your Notes calendar with XPages
DWA Hotfixes for Domino 8.5.1FP1 - A Gotcha
IBM Adds DB2 to Lotus Foundations SMB Package
SNTT : XPages onclick Ghosts in the machine
Ports used by Lotus Sametime 8.5 servers
Exploring a Domino Date Bug
>> Read all the news
More from the ZATZ journals
Computing Unplugged: The iPad defenders have spoken
David Gewirtz Online: CNN commentary and analysis
OutlookPower: More about disappearing text
-- Advertisement --

Find unused Lotus Notes groups and clean up your address book
Have you ever wanted to get rid of old Lotus Notes groups that were cluttering up your address book, but you weren't sure if they were used? Find Unused Groups can help.

Find Unused Groups will check your ACL, mail, multi purpose and server groups to help you determine if they are used, and who uses them.

Learn how to easily clean up your address book.

-- Advertisement --

Teamstudio Edition 25 has shipped
It's finally here! Now that Teamstudio Edition 25 has shipped, listen to our latest Tool Time audio program to find out what's changed. Updates to all your favorite Teamstudio tools will be discussed.

Plus, you'll get an introduction to Teamstudio Undo (formerly known as Teamstudio Snapper).

Tap here to get started!

ZATZ Home  ·  News  ·  Back Issues  ·  Credits/Trademarks ·  Link To Us
Copyright © 1998-2010, ZATZ Publishing. All rights reserved worldwide.
Editor's Login