Lotus Notes Adapter 6.0 | webMethods Lotus Notes Adapter Documentation | webMethods Lotus Notes Adapter Installation and User’s Documentation | Lotus Notes-to-webMethods Communications | Setting Up the Domino Server for Outbound Transactions | Write Shared Agent Code | Using Sample Shared Agent Code in Java
 
Using Sample Shared Agent Code in Java
*To implement the sample shared agent code in Java
1. Open the Lotus Notes Designer.
2. Open a database.
3. Click Shared Code, then click Agents.
4. Click the New Agents tab and enter a name for the new agent, then close the dialog box.
5. In the Agent window, select Java from the drop-down menu.
6. Copy and paste the following sample code.
import lotus.domino.*;//STANDARD DOMINO CLASSES
import java.io.*;//INPUT OUTPUT CLASSES
import java.util.*;//UTILITIES PACKAGES
import com.wm.app.b2b.client.*;
import com.wm.data.*;

public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
//SETUP MAIN OBJECTS
Session oSession = getSession();
AgentContext oAgentContext = oSession.getAgentContext();
Database oDatabase = oAgentContext.getCurrentDatabase();

//CALLING VendorDB:getVendorList
Context c= new Context();
c.connect("localhost:5555", "Administrator", "manage");
IData results = c.invoke("VendorDB", "getVendorList", null);

//CREATE AGENT OUTPUT CLASS
PrintWriter oPrint = getAgentOutput();


//GET WEB DOCUMENT
Document oWebDocument = oAgentContext.getDocumentContext();
//SETUP DATE OBJECT FOR TIME STAMP
DateTime oDate = oSession.createDateTime("Today");

oDate.setNow();
//VARIABLES
Double vLoop = new Double(0);
String vHTML = new String("");
String vUNID = new String("");
int vLoop1= 5


//******** PROCESS SELECTED DOCUMENTS ******************

vHTML = vHTML + "<FONT Face=verdana SIZE=4><B>List of
Vendors</B></FONT><BR><BR>;
vHTML = vHTML + "<TABLE STYLE=\"font:8ptVerdana\">";
vHTML = vHTML +
"<TR><TD><B>Name</B></TD>
<TD><B>Company</B></TD>
<TD><B>Status</B></TD></TR>";


if (results!=null)
{
IDataCursor _cursor = results.getCursor();
IData[] _vendor= IDataUtil.getIDataArray(_cursor, "Vendors");
IDataCursor _vendCursor= null
if (_vendor.length >0)
{
for (int i=0; i < _vendor.length; ++i)
{
_vendCursor = _vendor[i].getCursor();
vUNID=IDataUtil.getString(_vendCursor, "Id");
vHTML = vHTML + "<TR><TD>";
vHTML = vHTML + vUNID + "</TD><TD >

<a href=./VendorDetails?OpenForm&Name="+IDataUtil.getString(_vendCursor,
"Name")+">" + IDataUtil.getString(_vendCursor, "Name")+ "</a></TD><TD>";
vHTML = vHTML +IDataUtil.getString(_vendCursor, "Company")+
"<TD><FONTCOLOR=\"red\">"+IDataUtil.getString(_vendCursor,
"Status")+"</FONT><BR>";
vHTML = vHTML + "</TD></TR>";
} //end-for
} //end-if(_vendor)
_vendCursor.destroy();
_cursor.destroy();
} //end-if
// PROCESS DOCUMENT
vHTML = vHTML + "</TABLE>";
oPrint.println(vHTML);
} catch(Exception e)
{
e.printStackTrace();
}
}
}
--------------------------------------------------------------------------------------------------------------------------------------------
7. Save your changes and the code will compile.
8. Work with your Lotus Domino application developer to ensure that the shared agent is executed according to your integration needs. You may also need to set up the Domino Server to put in place the mechanisms to initiate the events that the shared agent will use to start the service.