Tip

Photo With Link In The Java

Photo with link in the Java.

Prepare the following form with the:
1) Name field, which is Editable Listbox with a list of emploiees names:
2) $$QuerySaveAgent field which starts the PhotoLinkAget on save action
The Java code of this agent is below:

| import java.io.*; |
| import lotus.notes.*; |
| |
| public class PhotoLinkAgent extends AgentBase { |
| |
| public void NotesMain() { |
| |
| try { |
| Session session = getSession(); |
| AgentContext ac = session.getAgentContext(); |
| Document doc = ac.getDocumentContext(); |
| |
| |
| // Collect information from the current document |
| String msg = doc.getItemValueString("Name"); |
| // Substitute emty space " " with " , " and change position |
| of First and Last names |
| int len = msg.length(); |
| int k = msg.indexOf(" "); |
| String str = " , "; |
| String msg01 = msg.substring(0, k); |
| String msg02 = msg.substring(k+1, len); |
| String msg1 = msg02 + str + msg01; |
| |
| // Print HTML and JavaScript |
| PrintWriter out = getAgentOutput(); |
| String js = "\"alert('This is " + msg + " photo')\""; |
| out.println("<body onLoad=" + js + " bgcolor=\"EAEAF4\">"); |
| out.println("<a href |
| = 'http://www.desl.lv/names.nsf/People/" + msg1 + |
| "?OpenDocument'><IMG SRC = '/TipsByPavels.nsf/" + msg + |
| ".jpg?OpenImageResource'></a>"); |
| out.println("<h1>" + msg + "</h1>"); |
| out.println("</body>"); |
| } catch (Exception e) { |
| e.printStackTrace(); |
| } |
| } |
| } |



The red part of the program substitutes blanck space " " between First and
Last names (collected from the Name field) with " , " and change their
positions (as it is in the Person form of the names.nsf database).
3) All the employees photos must be saved in Resources/Images of the same
database with names as First Last.jpg.
When opened the form in web will look like this:

(Embedded image moved to file: pic05885.pcx)
Selecting an employee and clicking on the Submit button the next
code-generated form is presented:

(Embedded image moved to file: pic09494.pcx)
Closing the Microsoft Internet Explorer box you have an opportunity to
click on the photo to link to the Person document of this employee in NAB
database:

(Embedded image moved to file: pic05197.pcx)

- pic05885.pcx
- pic09494.pcx
- pic05197.pcx

This was first published in November 2000

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.