*** urgent *** UIDocument class is not support to Java

I have a button in my form to run java agent. This agent is to trigger stored procedure in AS400 and return result set back to the document via jdbc on-line. I can get data back from AS400 and replace them to fields in the form. But since java has no uidocument class, the results set can not refresh to the document window immediately. (so far,I have to close window and click refresh to see the changes) Is anyone know the solution or has better alternative ?

Subject: *** urgent *** UIDocument class is not support to Java

Be careful about “urgent” – it gives bad taste to your post.

I assume you can launch your agent from a formula button and as the last action (PostedCommand?) refresh the document. (and you of course use getDocumentContext() to access document you call the agent from?)

Else you can always programmatically re-open the document so that you do not need to do it manually.

Subject: *** urgent *** UIDocument class is not support to Java

Thank you all for prompt response. I would like to post my solution and sample code for your reference. We use LotusScript for a button to get the key that user entered, create a background doc contains this key field then pass the noteid to javaagent. Javaagent perform AS400 connection to trigger stored procedure and fetch data into this background doc. Once lotusscript got control, it open this background doc and display fields to uidocument. Don’t forget to remove this background doc at the end.LotusScript sample -

    Dim nid As String

......

Set db= session.CurrentDatabase

Set uidoc = workspace.CurrentDocument

Set ndoc = db.CreateDocument

    ndoc.key= uidoc.FieldGetText("dspKey") 

Call ndoc.Save(True, True)

nid = ndoc.NoteID

    Set ndoc = Nothing

    Set agent = db.GetAgent("javaAgent")

agent.RunOnServer(nid)

    Set doc = db.GetDocumentByID(nid)

    Call uidoc.FieldSetText("A", doc.A(0))

    .......

    doc.Remove(True)

** pay special attention to Set ndoc = Nothing, if not, LS complier will treat doc and ndoc as the same object and skip to re-locate doc.

javaAgent need jt400.jar and j2ee.jar be installed in the server. And change notes.ini javauserclasses to include above jar files.

Sample code -

String noteid = ag.getParameterDocID();

Document doc = database.getDocumentByID(noteid);

String strCon = “jdbc:as400://as400/libr”;

String JDBCDriverName = “com.ibm.as400.access.AS400JDBCDriver”;

Class.forName(JDBCDriverName);

Connection con = DriverManager.getConnection(strCon, uid, pwd);

con.setAutoCommit(false);

if (con != null) {

String qry = “Select * from table”;

Statement stmt = con.createStatement();

ResultSet rs = stmt.executeQuery(qry);

while(rs.next()) {

   doc.replaceItemValue("A",rs.getString("A"));

Subject: Encapsulate your Java into your own class and use Lotus Script

Nin Hao Lingchi,

它不难做使用R6 。 (For our non Chinese reading folks: use Babelfish to translate it).

Try the new LotusScript to Java Bridge. So your agent runs as Lotus Script but calls an Java Class that does the AS400 work.

See the Domino Designer Help for LS2J.

:slight_smile: Hope that helps!