Tip

Simple Web Agent To Display View Data Dynamically

Ever wanted to show your view data on the web in a fashion other than using your view or coding your view columns to represent HTML (or xml)? Well, here is a simple agent to show your data in a web page, based on a query. (More for beginners.)
Function printPMList()
	
	On Error Goto listError
	
	Dim session As New notessession
	Dim db As NotesDatabase 
	Dim view As NotesView
	Dim doc As NotesDocument
	Dim doc2 As notesdocument
	Dim productList( 1 To 500 ) As Variant
	Dim currentProduct1 As Variant
	Dim currentProduct2 As Variant
	Dim currentProduct3 As Variant
	Dim currentProduct4 As Variant
	Dim currentProduct5 As Variant
	Dim query As String
	
	counter% = 1
	Set db = session.CurrentDatabase
	Set view = db.GetView( "ProductMV" )
	Set doc2 = session.DocumentContext
	Set doc = view.GetFirstDocument   
	query = doc2.PassValue(0)
	
	Print "<html>"
	Print "<body bgcolor = #000000>""
	Print "<b>"<font size = 4 face=""Arial, Helvetica, sans-serif"" color = ""#F7DC00"">"Product Managers:  " + Cstr(query) + " List</font>"</b>"<hr>""
	Print "<br>"<a href = ""javascript:history.back(-1)""><font size = 2 face=""Arial, Helvetica, sans-serif"" color = ""#69C028"">"Back To Product Managers</font>"</a>""	
	Print "<br>"</center>"<Table width = 700 Cellspacing =0 Cellpadding=2 Border = 3>""
	Print "<TR>""
	Print "<TD WIDTH = 100 TD COLSPAN = 2 Border = 3>Name</TD>""
	Print "<TD WIDTH = 500 TD COLSPAN = 3>"<b>"<font size = 2 face=""Arial, Helvetica, sans-serif"" color = ""#69C028"">"Product Manager</font>"</b>"</TD>""
	Print "</TR>""	
	Print "<TR>""
	Print "<TD WIDTH = 100>"<b>"<font size = 2 face=""Arial, Helvetica, sans-serif"" color = ""#69C028"">"Vendor</font>"</b>"</TD>""
	Print "<TD WIDTH = 25>"<b>"<font size = 2 face=""Arial, Helvetica, sans-serif"" color =""#69C028"">"Vendor Code</font>"</b>"</TD>""
	Print "<TD WIDTH = 100>"<b>"<font size = 2 face=""Arial, Helvetica, sans-serif"" color = ""#69C028"">"Vendor Name</font>"</b>"</TD>""
	Print "<TD WIDTH = 100>"<b>"<font size = 2 face=""Arial, Helvetica, sans-serif"" color = ""#69C028"">"Vendor Phone</font>"</b>"</TD">""
	Print "<TD WIDTH = 100>"<b>"<font size = 2 face=""Arial, Helvetica, sans-serif"" color = ""#69C028"">"Vendor E-mail</font>"</b>"</TD>""
	Print "</TR>"	
	While Not ( doc Is Nothing )         
		currentProduct1 = doc.ColumnValues( 0 )
		currentProduct2 = doc.ColumnValues( 1 )
		currentProduct3 = doc.ColumnValues( 2 )
		currentProduct4 = doc.ColumnValues( 3 )
		currentProduct5 = doc.ColumnValues( 4 )
		productList( counter% ) = currentProduct1
		If (Left(Cstr(productList(counter%)),1)  = query) Then
			Print "<TR>""
			Print "<TD WIDTH = 100>"<font size = 2 face=""Arial, Helvetica, sans-serif"" color = ""#F7DC00"">""+ Cstr(productList(counter%))+ "</font>"</TD>""
			Print "<TD WIDTH = 10>"<font size = 2 face=""Arial, Helvetica, sans-serif"" color = ""#F7DC00"">""+ Cstr(currentProduct2)+ "</font>"</TD>""
			Print "<TD WIDTH = 100>"<font size = 2 face=""Arial, Helvetica, sans-serif"" color = ""#F7DC00"">""+ Cstr(currentProduct3)+ "</font>"</TD>""
			Print "<TD WIDTH = 100>"<font size = 2 face=""Arial, Helvetica, sans-serif"" color = ""#F7DC00"">""+ Cstr(currentProduct4)+ "</font>"</TD>""
			Print "<TD WIDTH = 100>""+ "<a href = mailto:"+ Cstr(currentProduct5) + ">"" + "<font size = 2 face=""Arial, Helvetica, sans-serif"" color = ""#69C028"">""Cstr(currentProduct5) + "</a>"</font>"</TD>""
			Print "</TR>""
		End If 
		Set doc = view.GetNextDocument( doc )
		counter% = counter% + 1
	Wend  
	Print "</Table>""
	Print "<font size = 2 face=""Arial, Helvetica, sans-serif"" color = ""#F7DC00"">" Current Time " + Cstr(Now) + "</font>"<br>""
	Print "</center>"<hr>"<center>""
	Print "<font size = 1 face=""Arial, Helvetica, sans-serif"" color = ""#69C028"">"Home</font>"<font size = 1 face=""Arial, Helvetica, sans-serif"" color =  ""#F7DC00"">" | </font>""
	Print "<font size = 1 face=""Arial, Helvetica, sans-serif"" color = ""#69C028"">"About Us</font>"<font size = 1 face=""Arial, Helvetica, sans-serif"" color =  ""#F7DC00"">" | </font>""
	Print "<font size = 1 face=""Arial, Helvetica, sans-serif"" color = ""#69C028"">"Services </font>"<font size = 1 face=""Arial, Helvetica, sans-serif"" color =  ""#F7DC00"">" | </font>""
	Print "<font size = 1 face=""Arial, Helvetica, sans-serif"" color = ""#69C028"">"Locations</font>"<font size = 1 face=""Arial, Helvetica, sans-serif"" color =  ""#F7DC00"">" | </font>""
	Print "<font size = 1 face=""Arial, Helvetica, sans-serif"" color = ""#69C028"">"Merchandise </font><font size = 1 face=""Arial, Helvetica, sans-serif"" color =  ""#F7DC00"">" | </font>""
	Print "<font size = 1 face=""Arial, Helvetica, sans-serif"" color = ""#69C028"">"Contact Us</font>"<font size = 1 face=""Arial, Helvetica, sans-serif"" color =  ""#F7DC00"">" | </font>""
	Print "<font size = 1 face=""Arial, Helvetica, sans-serif"" color = ""#69C028"">"Frequent Buyer's Club</font>"|"	
	Print "</center>""
	Print "<center>""
	Print "<font size = 1 face=""Arial, Helvetica, sans-serif"" color = ""#69C028"">"Specials</font>"<font size = 1 face=""Arial, Helvetica, sans-serif"" color =  ""#F7DC00"">" | </font>""
	Print "<font size = 1 face=""Arial, Helvetica, sans-serif"" color = ""#69C028"">"Employment</font>"<font size = 1 face=""Arial, Helvetica, sans-serif"" color =  ""#F7DC00"">" | </font>""
	Print "<font size = 1 face=""Arial, Helvetica, sans-serif"" color = ""#69C028"">"Site Map </font>"|"
	Print "</center>""	
	Print "<br><center>""
	Print "<font size = 1 face=""Arial, Helvetica, sans-serif"" color = ""#F7DC00"">"Legal Terms and Conditions</font>"</center>""
	Print "<center>"<font size = 1 face=""Arial, Helvetica, sans-serif"" color = ""#F7DC00"">"? 2000 TruckPro, Inc. All Rights Reserved</font>"</center>"" 
	Print "</body>""
	Print "</html>""
		
listError:
	Print Error()
End Function

This was first published in February 2001

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.