Skip to main content
This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal

Notes/Domino 6 and 7 Forum

Notes/Domino 6 and 7 Forum


  

PreviousPrevious NextNext

RE: Why can't you ... (WAS: Database access from another class - Java)
~Dan Zekpone 2.Oct.03 01:42 PM a Web browser
General All Releases Windows 2000


OK, see how you go with this... Taking your original example, I worked up some skeleton classes thus. One, "JavaAgent", is the agent code. The other, "DomGUI" is the equivalent of your MyWindow class... some of the original code has been taken out for brevity. Notice the NotesThread calls in the sendToAll() method: they are key to the Domino interfaces / classes being accessible in sendToAll().

JAVAAGENT:
import lotus.domino.*;

public class JavaAgent extends AgentBase {
private Session session;
private AgentContext ac;
private Database db;
private String myString;
private DomGUI myWin;

public void NotesMain() {
try {
session = getSession();
ac = session.getAgentContext();
db = ac.getCurrentDatabase();
Document doc = ac.getDocumentContext();

if(doc!=null) {
myString = doc.getFirstItem("e_mail").getText();
} // end if
myWin = new DomGUI(session, db);
while (!myWin.isClosed) {
Thread.sleep(250);
} // end while
} catch(Exception e) {
e.printStackTrace();
} // end try catch
} // end NotesMain method
} // end JavaAgent class

DOMGUI:
import lotus.domino.*;
import java.awt.*;
import java.awt.event.*;

class DomGUI extends Frame implements ActionListener {
public boolean isClosed = false;
private Button btnPerson;
private Button btnSend;
private Session session;
private Database db;
private View view;

DomGUI(Session parentSession, Database currentDb) {
super("Mailing");
try {
this.session = parentSession;
this.db = currentDb;;
view = db.getView("MyView");
// enable window events
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
} catch(Exception e) {
e.printStackTrace();
} // end try catch

setLayout(new BorderLayout());
btnSend = new Button("Send to all");
btnSend.addActionListener(this);
add(BorderLayout.EAST, btnSend);
btnPerson = new Button("Send to a person");
btnPerson.addActionListener(this);
add(BorderLayout.WEST, btnPerson);
setSize(500,500);
setVisible(true);
} // end constructor

public void sendToAll() {
NotesThread.sinitThread();
// do view stuff here
NotesThread.stermThread();
} // end sendToAll method

// necessary to implement ActionListener
public void actionPerformed (ActionEvent e) {
if (e.getSource() == btnSend) {
sendToAll();
dispose();
isClosed = true;
} // end if
} // end method

protected void processWindowEvent (WindowEvent e) {
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
dispose();
isClosed = true;
} else {
super.processWindowEvent(e);
} // end if else
} // end method
} // end DomGUI class

--
Hope this is of use. Like I said before, thi is fairly new to me -- as is Java itself -- so if my code contains glaring horrors, my apologies. The thread sleeping is a bit of a cludge, but it works, and makes sense in the context of a Notes agent running in the foreground in any case.

--
http://www.benpoole.com




Database access from another class ... (~Joseph Brenite... 30.Sep.03)
. . RE: Database access from another cl... (~Delores Dwonic... 30.Sep.03)
. . . . RE: Database access from another cl... (~Joseph Brenite... 30.Sep.03)
. . . . . . Why can't you ... (WAS: Database ac... (~Delores Dwonic... 30.Sep.03)
. . . . . . . . RE: Why can't you ... (WAS: Databas... (~Dan Zekpone 1.Oct.03)
. . . . . . . . . . RE: Why can't you ... (WAS: Databas... (~Joseph Brenite... 2.Oct.03)
. . . . . . . . . . . . RE: Why can't you ... (WAS: Databas... (~Dan Zekpone 2.Oct.03)
. . . . . . . . . . . . . . Additional comment re loop (~Delores Dwonic... 2.Oct.03)
. . . . . . . . . . . . . . It works ;) (~Joseph Brenite... 2.Oct.03)
. . . . . . . . . . . . . . RE: Why can't you ... (WAS: Databas... (~Naomi Nimkitex... 2.Oct.03)
. . . . . . . . . . . . . . . . Thanks Joe, that's useful to know! ... (~Delores Dwonic... 2.Oct.03)


Document Options






  Document options
Print this pagePrint this page

Search this forum

Forum views and search


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

Member Tools


RSS Feeds

 RSS feedsRSS
All forum posts RSS
All main topics RSS