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.
Build your own Domino hit counter (continued)

Take it a stage further. You know what the current values of all your counters are. Therefore, you also know what the next 10, 50 or 100 required numbers will be. The DominoCounter has a separate scheduled agent that prebuilds GIF images for the next so many counter images, so that when a Web client asks for a page counter image, odds are that it already exists, ready to be immediately served up.

Two other specific optimizations are made to enhance performance. Typical Perl agents decode a GIF image of the numbers 0 to 9, then encode a new GIF for the required hit number every time the script is called. The Domino Counter does the GIF decode only once, when you load a new digit style, and stores each decoded digit within a Notes document. Also, GIF is typically a compressed graphic format--but for small images the saving of a few dozen bytes is simply not worth the extra time taken to compress an image, so DominoCounter sends out uncompressed GIFs.

Debugging
Web agent development can be a tricky process, as can the implementation of another person's agent. To track what an agent is doing, it's good practice to add support for a &debug parameter on the URL command line. In the example of DominoCounter, &debug triggers the full text of any error messages (line numbers for Web agents are even less meaningful than for Notes agents!), and will also return timing information to ease agent tuning. Such support is especially important for a byte-serving agent, since otherwise the user will only receive a graphic image.

Don't forget to wrap some HTML around the debug and error information or it'll all come out jumbled on a single line. And consider, at least for the development cycle, adding in some extra debug fields--for example, set a variable to the name of each module within the code and report that variable in the error handling, so that you can track where the code is halting.

Calling an agent from another database
In order to use the page counter from a Notes client under the same conditions as the Web (meaning no write access to the page being counted, and statistics for all clients maintained in the same database) it is essential to call an agent in the DominoCounter database from any other.

There's no direct way either of calling another agent, or to pass parameters and results between one database and another.

The solution is to use the trusty old environment variables beloved by old Notes v2 and v3 programmers, together with some LotusScript. Here's how it's done for DominoCounter.

First, create a text field of type Computed for Display on the form, with a value of:

@Environment( "PageCount")

In the QueryOpen event of the form, call the NotesCounter agent using the LotusScript below:

' QueryOpen Code
Sub QueryOpen(Source As Notesuidocument, Mode As Integer, Isnewdoc As Variant, Continue As Variant)
Dim session As New NotesSession
Dim DomCount As NotesDatabase
Set DomCount=New NotesDatabase("YourServerName","DomCount.nsf")
PageRef$="MyPageIdentifier"

Forall agent In DomCount.agents
If agent.name="NotesCounter" Then
Call session.SetEnvironmentVar( "AccountRef",PageRef$)
Call agent.Run
PageCount = session.GetEnvironmentString( "PageCount" )
End If
End Forall

End Sub


« Previous  ·  1  ·  2  ·  3  ·  4  ·  Next »
Other articles you might like
Home > Internet Technologies > Logging and analysis (8 articles)
   Boost your server performance with HTTrack
   Keeping user credentials in a frameset
   Using probes to monitor your Domino servers
Home > Lotus Technologies > Domino (77 articles)
   More about Domino log files
   Why your log.nsf might not be purging properly
   Sloppy analysis at the core of another Domino vs. SharePoint report
Home > Lotus Technologies > LotusScript (64 articles)
   When the debugger won't debug hidden code that isn't hidden
   What to do if the LotusScript debugger won't single-step over code
   Little known traps about Lotus Notes fields
Home > Lotus Technologies > Application Development (48 articles)
   An application for scanning physical mail and distributing it virtually
   How hide-whens in Rich Text can ruin your whole day (and what to do about it)
   Little known traps about Lotus Notes fields
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 --

Sophisticated Meets Simple For Document Management
Share. Control. Manage.
Documents, emails, and content in the context of how work is done. Native to Lotus Domino. The User Experience unseen for Lotus Domino. Do more with less. Really.

See the possibilities Docova unleashes for Lotus Domino.
-- 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