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.
Getting started with JavaScript development in Domino (continued)

Figure A shows the JSHeader section of the Domino form being used. This is where all JavaScript to be placed in the HEAD section of an HTML form is placed. This replaces the old technique of using the $$HTMLHead field, but that is still supported. I have placed a small function in the programmer pane in the screenshot.

FIGURE A


This Domino form is using the JSHeader section. Roll over picture for a larger image.

In addition to supporting JavaScript, the Domino Designer client will check the syntax of your JavaScript code as well. Of course, it cannot check logic so we programmers still have a bit of work to do.

Another excellent addition to Domino Designer R5 is a JavaScript object reference for both Web and Notes clients in the Object Browser pane. Figure B demonstrates the Object Browser for the Notes client.

FIGURE B


Domino 5.0 has a nice JavaScript Object Browser. Roll over picture for a larger image.

D.O.M. stands for Document Object Model, and it refers to the object model for the Web or Notes client. The drop-down list under the reference tab allows us to select the Web D.O.M or the Notes D.O.M. Objects in either client consist of such items as fields, dates, browser plug-ins, or the base window object.

Common applications
One of the most common uses of JavaScript is field validation. A common text field can be checked with the following code (the following checks if the field is empty):

if (document.forms[0].fieldName.value == "")
{
alert("Please enter a value for the field.");
}

The validation of data can be used to stop the submission of a form. You don't want to save a document until it has been properly completed, do you?

You can place a validation function in the header (JSHeader) section of the form:

function validate()
{
var doc = document.forms[0];
if (doc.fieldName == "")
{
alert("Please complete the field before submitting.");
}
else
{
doc.submit();
}
}

The function named validate() will only submit the document when the field has been filled. You should use the submit method of the JavaScript document object in the else phrase. Now, you can add a link called submit. The link will reference your validate function, and submit the document if appropriate. Here is the formula for a link field (note: pass-thru HTML is used):

url := "JavaScript: submitdocument()";
"[<a href=\"" + url + "\">]" + "Submit Entry" + "[</a>] "

Another common use is setting default field values; the follow JavaScript code can be added to the JSHeader (or $$HTMLHead section for 4.6 users) section.

var doc = document.forms[0];
doc.firstName = "Denise";
doc.lastName = "Amrich";

The JSHeader or HEAD portion of a form is calculated first when a form is loaded, so our code populates the firstName and lastName fields on our form.


« Previous  ·  1  ·  2  ·  3  ·  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 > 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 > Older Releases > R5 (19 articles)
   More archive fun
   A Notes release in Dilbert-land
   Tips for being more productive with Notes R5 mail
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 --

Struggling with exporting Notes data to spreadsheets? No More!
Try IntelliPRINT, The world's leading Reporting, Dashboards, and Analysis solution for Notes & Domino

  • Don't spend unproductive time maintaining different versions of the same spreadsheet
  • Preserve data integrity and security in multi-user environments
  • Create reports in minutes INSIDE Notes
  • Get freedom from iterative report requests, deliver self-serve capabilities

Experience Reporting, Dashboards, and Analysis INSIDE Notes.

Try IntelliPRINT NOW!

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