Skip to main content
 
developerWorks
AIX and UNIX
Information Mgmt
Lotus
New to Lotus
Products
How to buy
Downloads
Live demos
Technical library
Training
Support
Forums & community
Events
Rational
Tivoli
WebSphere
Java™ technology
Linux
Open source
SOA and Web services
Web development
XML
My developerWorks
About dW
Submit content
Feedback



developerWorks  >  Lotus  >  Forums & community  >  Notes/Domino 4 and 5 Forum

Notes/Domino 4 and 5 Forum

developerWorks

  


How to convert LotusScript to Java
Larry A. Walsh 17.May.00 02:20 PM a Web browser
Domino Designer -- Agents 5.0.3 Windows 95/98

I created a FWForm class that will provide all the function that is needed to create and submit a form.
I do a getfield, setField, and new FWForm. This function works in LotusScript and all but copyallitems
work in Java. Thanks for your help.

Problem:
How to pass the current document (AgentContext) to the function.

Sample Agent Code:
import lotus.domino.*;
import java.io.*;
import java.util.*;
import com.law.fwform.*;

public class JavaAgent extends AgentBase {

public void NotesMain() {

try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
PrintWriter pw = getAgentOutput();
Database db = agentContext.getCurrentDatabase();
Document doc = agentContext.getDocumentContext();


// Start of API Code
String FormServer = db.getServer(); // Name of the server this archive resides on.
String FormDrawer = db.getFilePath(); // Path and filename of this database.
String FormView = "$FWFormID"; // Name of hidden view in this database that the form blank resides in (don't change).
String FormId = doc.getItemValueString("FormTitle"); // Name of the form blank exactly as it appears in the form blank view.
String ctext = doc.getItemValueString("cname");

// Web Submit code start here


// Check for web login user's name if anonymous post message
String user = doc.getItemValueString("Remote_User");
// String user = doc.getItemValueString("CN=Larry Walsh/OU=LNM3");
String cUser = null;


if ( user == null) {
// System.out.println(" Unknown User name.. Login again to the IBM Forms.<p>");
pw.println ( "<h3>ErrorMsg 1: <font color=00008b><strong>Unknown User name.. Login again to the IBM Forms.</strong><font color=0000ff>" );
return ;
}
// Check to see if user name is hierachical
Name na = session.createName(user);


// Then set Remote_User to the correct name format for notes ids use addreviated, http use common name

if (na.isHierarchical())
{
cUser = na.getAbbreviated();
} else {
cUser = na.getCommon();
}



// Create FormWave document
FWForm newForm = new FWForm(FormServer, FormDrawer, FormView, FormId, pw);

// copy all Items from one document to another
// I tried the following
// boolean flag1 = newForm.InitFWForm(doc);
// String flag1 = newForm.InitFWForm(doc);
// pw.println ( "<h3> Copy all items Format - boolean flag1 = newForm.InitFWForm(doc) <font color=00008b><strong>" + flag1 + "</strong><font color=0000ff>" );


} catch(Exception e) {
PrintWriter ptw = getAgentOutput();
ptw.println ( "<h3> FormWave Submit Error:<font color=00008b><strong>" + e + "</strong><font color=0000ff><br>" );
e.printStackTrace();
}
}
}

Sample FWFrom Class:
package com.law.fwform;

import lotus.notes.*;
import java.io.*;
import java.util.*;

public class FWForm {

private Document blankForm;

public FWForm(String formServerName,
String formDBName,
String formViewName,
String formId,
PrintWriter pw) throws NotesException, FWException {
Session s = Session.newInstance();


Database formDrawerDB = s.getDatabase(formServerName, formDBName);
if (!formDrawerDB.isOpen()) {
throw new FWException("FormDrawer database \""+ formDBName +
"\" on Server \"" + formServerName +
"\" did not open.");
}

View blankBox = formDrawerDB.getView(formViewName);
if (blankBox == null) {
throw new FWException("View \"" + formViewName + "\" was not found.");
}

blankForm = blankBox.getDocumentByKey(formId, true);
if (blankForm == null) {
throw new FWException("Form \""+formId+"\" was not retrieved.");
}

} // FWForm constructor


// Problem area...........


/*
public String InitFWForm() throws FWException {
return "";
} // FWForm.InitFWForm()
*/

// public boolean InitFWForm() throws NotesException, FWException {
public String InitFWForm() throws NotesException, FWException {
Document cdoc = blankForm;

if (cdoc.hasItem("_FWAttribute")) {
String GetAttribute = cdoc.getItemValueString("_FWAttribute");
String GetStatus = cdoc.getItemValueString("_FWStatus");
if ((GetAttribute == "FRM") && (GetStatus == "BLANK")) {
return GetAttribute + " - 1 - " + GetStatus;
}}
return "BBB";


} // FWForm.InitFWForm()


}// class FWForm






Sample LotusScript:
Function InitFWForm(copydoc As NotesDocument) As Integer
If copydoc.HasItem("_FWAttribute") Then
GetAttribute = copydoc.GetItemValue("_FWAttribute")
GetStatus = copydoc.GetItemValue("_FWStatus")
If GetAttribute(0) = "FRM" And GetStatus(0) = "BLANK" Then
Forall i In Me.FWDoc.Items
Call Me.FWDoc.RemoveItem(i.Name)
End Forall
Call copydoc.CopyAllItems(Me.FWDoc, False)

InitFWForm = True
Else
InitFWForm = False
APIErrMsg = "API1N500E"
Exit Function
End If
Else
InitFWForm = False
APIErrMsg = "API1N400E"
Exit Function
End If

End Function






  Document options
Print this pagePrint this page

 Search this forum

  Forum views and search
Date (threaded)
Date (flat)
With excerpt
Author
Category
Platform
Release
Advanced search


 RSS feedsRSS
All forum posts RSS
All main topics RSS
More Lotus RSS feeds

 Resources
Forum use and etiquette
Native Notes Access
Web site Feedback

  Lotus Support
Lotus Support
Product support pages index
Search knowledge base (Technotes)
Search support downloads
Lotus Support RSS

 Wikis
IBM Composite Applications
IBM Mashup Center
IBM Connections
IBM Docs
IBM Forms
IBM Mobile Connect
IBM Sametime
IBM SmartCloud for Social Business
IBM Web Experience Factory
Lotus Domino
Lotus Domino Designer
Lotus Expeditor
Lotus Foundations
Lotus iNotes
Lotus Instructor Community Courseware
Lotus Notes
Lotus Notes & Domino Application Development
Lotus Notes Traveler
Lotus Protector
Lotus Quickr
Lotus Symphony
IBM Web Content Manager
WebSphere Portal

 Lotus Forums
Notes/Domino 9.0
Notes/Domino 8.5 + Traveler
Notes/Domino XPages development forum
Notes/Domino 8
Notes/Domino 6 and 7
Notes/Domino 4 and 5
IBM Connections
IBM Forms
IBM Mobile Connect
IBM Sametime
IBM SmartCloud Notes
IBM SmartCloud Meetings
IBM Web Content Manager
Lotus Domino Document Manager
Lotus e-learning
Lotus Enterprise Integration
Lotus Expeditor
Lotus Protector
Lotus Quickr
Lotus SmartSuite
Lotus Symphony
Lotus Symphony Developer Toolkit Support
Lotus Workflow