Showing posts with label diiop. Show all posts
Showing posts with label diiop. Show all posts

3/27/2010

Implement a typical loop routine to the previous diiop sample

The most typical sample of Notes API would be open view, get one document and change/get item value.

I previously posted a simple sample code for the beginner of DIIOP technology and some would want to know how to implement a typical Notes routine as follows.



NABLoop.java
import lotus.domino.* ;

public class NABLoop 
{
 static String host = "xxx.xxxx.com" ; // server address
 static String cName = "notes admin" ; //username
 static String dbname = "names.nsf"; // database (e.g. mail\\hnagashi.nsf)
 static String password = "password" ;  // internet password

  public static void main(String args[]){
     try{
   Session s = NotesFactory.createSession(host,cName,password) ;
   Database db = s.getDatabase("", dbname );

 if(!db.isOpen()){
  db.open();
 }
   View view = db.getView("People");
     Document doc = view.getFirstDocument();
   Document temp = null;
   String title = db.getTitle();
   String uname = s.getUserName();
   
   System.out.println("Session User Name: " + uname );
   System.out.println("ServerName: " + db.getServer());
   System.out.println("Title: " + title);

 while (doc != null)
 {
  System.out.println("User Name: " + doc.getItemValueString("FullName"));
  temp = view.getNextDocument(doc); 
  doc.recycle();   
  doc = null;
  doc = temp;
}

        }catch(NotesException ne){
   System.out.println(ne.id + ne.text);
   ne.printStackTrace() ;
 }catch (Exception e){e.printStackTrace() ;}
  }
}
Hope it helps!

3/15/2010

Some comments on my sample (in the previous post..)

On the previous post, I did not explain the code at all so I added some comments on my sample code.

Following line indicates that this code is a remote access application, thus this application uses NCSO.jar.

Session s = NotesFactory.createSession(host,cName,password) ;

As this is called a "remote" access application, you need to specify host name to connect server.
Local access application is used like this.

Session s = NotesFactory.createSession() ;

What confuses you is that "local" access application may access the server, too.
"local" just means that you use "local" notes client application dll to access Notes object and "remote" just means that application uses remote DIIOP-based procedure call (a.k.a ORB).


Also, some experienced developer saw my code and felt like this...

"Static variable for host name , user name and password in this code looks silly. I will handle this value as an argument value instead, which does not need compilation when I changed the value"

Believe me... I did it intentionally..
When investigating DIIOP issue/remote access application code issue in support scene, I always need to compile the code very frequently. so compilation is not the problem for my investigation. Rather, I wanted to avoid to forget the order of argument value or usage of aplication. That's why I preferred static value in sample code but feel free to change the same as you like.

A sample code for testing DIIOP feature

This summary is not available. Please click here to view the post.