Java Applet/Xpages

Build Applet to Notes Form

And Xpages iFrame

Form Applet

Introduction:

Load Java Applet as a Lotus Notes JavaAgent or Script Library, attach the Applet to a Notes from then write an iFrame tag into Xpages form to load Applet through browser



Disclaimer:

Information contained in the following is presented as is. This tutorial assumes you have basic programming knowledge. All tutorials are based on an Eclipse/Eclipse-based software. Should you need to familiarize yourself with a certain Eclipse environment, prior to continuing this tutorial, please stop now and see a tutorial from this site...



Write JavaAgent Applet, load to Form/Xpages

Full code added below, jump ahead if necessary, areas of interest have been highlighted for your convenience. Below JavaAgent is pretty basic, please use instructions as guide to fully understand how this Applet loads



awt.java



/**

* Created from Copy: 2012.05.01.12.49.PM

* Applet Test to include in Notes Form

* then sucked into Xpages via iFrame

*

*/

import lotus.domino.*;

import java.awt.*;

import java.awt.event.*;


/**

* @author kcherizard

* @version 2012.05.01.12.49.PM

*

*/

public class awt extends AppletBase implements ActionListener {

private static final long serialVersionUID = 1L;

private Button b;

private String text = "Oh My! Get a load of this!";

Graphics g;

public java.awt.TextArea ta;

public Session s;


public void notesAppletInit() {

g = getGraphics();

b = new Button("Get Döcu User");

add(b);

ta = new java.awt.TextArea(15, 30);

add(ta);

setVisible(true);

}


public void paint(Graphics g) {

b.setLocation(0, 0);

ta.setLocation(200, 0);

}


public void notesAppletStart() {

try {

s = this.getSession();

b.addActionListener(this);

} catch (NotesException e) {

text = e.id + " " + e.text;

} catch (Exception e) {

e.printStackTrace();

}

}


public void actionPerformed(ActionEvent e) {

text = "What? I didn’t see anything";

getTheName();

ta.append(text + "\n");

}


public void getTheName() {

try {

if (isNotesLocal()) {

NotesThread.sinitThread();

}

text = "User " + s.getCommonUserName();

} catch (NotesException e) {

text = e.id + " " + e.text;

} catch (Exception e) {

e.printStackTrace();

} finally {

if (isNotesLocal()) {

NotesThread.stermThread();

}

}

}

}





Build Xpages form with an iFrame

Full code added below, jump ahead if necessary, areas of interest have been highlighted for your convenience.



<?xml version="1.0" encoding="UTF-8"?>

<xp:view xmlns:xp="http://www.ibm.com/xsp/core">

<xp:span style="font-weight:bold">Applet from Notes form Embedded as an

iFrame</xp:span>

<xp:br style="font-weight:bold"></xp:br><xp:br></xp:br>



<iframe src="http://localhost/docu.nsf/AppletForm?OpenForm"

width="300" height="300"></iframe>


</xp:view>





The Steps:



JavaAgent

  1. Grab above code, plug it into a JavaAgent

  2. Give the is Agent full permissions

  3. Using code pane, right-click, run the code as Java Applet

  4. Provide your Applet loaded, save and keep code Open



Java Applet

  1. Go to Resources in DDE’s Application Navigator

  2. Add New Applet Resources to your project

  3. Navigate through Domino Directory, find workspace (../Data/workspace)

  4. Double-click the Bin folder to pick up the .class @ left

  5. Select class, choose Add/Replace File(s)

  6. File is now added to Current Libraries pane @ right





Notes Form

  1. Create a new form, enter some text in design pane

  2. Go to DDE’s menu bar, find Create option

  3. Choosing Java Applet loads a ‘Create Java Applet’ pop up

  4. From here you want to Locate the Applet

  5. Select class, choose Add/Replace File(s)

  6. Go to Libraries pane Dropdown to select the class

  7. You have added your Applet to the Form, now What?

  8. Well, right-click on this bad boy to see its properties

  9. Select ‘Applet uses Notes CORBA classes





Cheat Sheet: Java Applet Steps















Cheat Sheet: Notes Form Steps





















Finished Product







Conclusion:

You can now build Applets to your Notes Client and Xpages forms..



TIP: You should leave your JavaAgent open to locate all .class files



Questions, comments, please post a brief message. Thank you for coming...