User classes
User Java™ classes can be created in an application using the Domino® or Java™ perspective, and called in JavaScript™ by specifying the fully qualified name. The class must belong to a package (not the default package).
Creating a user class
In the Domino® perspective, go to to create and maintain Java™ classes. In the Java™ perspective, go to Code/Java.
Here is sample Java™ code that you might place in your application.
package pkg1;
public class Class2 {
public String hello() {
return "Hello world!";
}
}The following computed field calls the Java™ function in the user class.
var mc = new pkg1.Class2();
return mc.hello();Using the Java™ design element in the Domino® perspective
For in
the Domino® perspective, you
can choose to create a new Class, Interface,
or Enum element. Creation and maintenance of these
elements is through the standard Eclipse Java™ editor.
In
the Java™ perspective, a package
appears as a normal directory. In the Designer perspective, a package
appears followed by a slash. For example, myClass2.java in
package pkg1 appears as pkg1/myClass2.java in
the Applications Navigator.
Deleting a Java™ design element also deletes the class file. Renaming an element deletes the class file and refactors all elements.
The .classpath for Domino® applications includes Code\Java so
these design elements are automatically compiled. The class file is
stored inside the application and extracted the same way as for XPages.
In the virtual file system, the class file appears separate from the .java file,
under WebContent\WEB-INF\classes. You can see the
class items stored within the note when you look at the fields on
the design note properties (or in NotesPeek).