JavaAgent Reads view Spits out Data via HTML Tags

/**
 * Created: 2013.12.08.6.49.PM
 * HTTPHTMLDataJavaAgent
 * HTML data for Xpage to be read by JavaBean
 */

import lotus.domino.*;
import java.io.PrintWriter;
import java.util.Vector;

/**
 * @author Dököll Solutions, Inc.
 * @version 2013.12.08.6.49.PM
 * 
 */

public class JavaAgent extends AgentBase {
	// final String GotoPage =
	// "http://localhost/docucontent.nsf/xpbycategorylist.xsp";
	// button code...
	public void NotesMain() {
		try {
			// Session
			Session session = this.getSession();
			// Output using PrintWriter
			PrintWriter printWriter = this.getAgentOutput();
			// ...
			Database database = session.getDatabase("", "docucontent.nsf");
			// ensure database is not null
			if (database != null) {
				// ...
				View uLogs = database.getView("UserAppLogsViewListings");
				if (database.isFTIndexed()) {
					System.out.println("DB Indexed for searching...");
					// ensure view is not null
					if (uLogs != null) {
						// grab first doc
						Document doc = uLogs.getFirstDocument();
						// Declare String objects to be used for field values
						String strUserName = null;
						String strUserNumber = null;
						String strPageID = null;
						String strUserIP = null;
						int c = 0;
						// Loop through docs
						// printWriter.println("<table border='20' cellpadding='10'><tr>");
						printWriter.println("<table border='1'><tr>");
						printWriter
								.println("<th span='5' border='0'>User Login Data</th><th span='5' border='0'>User Login Data</th><th span='5' border='0'>User Login Data</th><th span='5' border='0'>User Login Data</th><th span='5' border='0'>User Login Data</th></tr>");
						while (doc != null) {
							c += 1;
							// Retrieve contents spit out HTML
							// TODO: Add jQuery functionality
							strUserName = doc.getItemValueString("SearchText");
							strUserNumber = doc
									.getItemValueString("itemNumber");
							strPageID = doc.getItemValueString("PageID");
							strUserIP = doc.getItemValueString("UserIP");
							// printWriter.println("<table border='20' cellpadding='10'><tr>");
							printWriter.println("<table border='1'><tr>");
							// printWriter.println("<th span='5' border='0'>User Login Data</th><th span='5' border='0'>User Login Data</th><th span='5' border='0'>User Login Data</th><tr>");
							printWriter.println("<tr><td width='50'>" + c
									+ "</td>" + " " + "<td width='150'>"
									+ strUserName + "</td>" + " " + "<td>"
									+ strUserNumber + "</td>" + " " + "<td>"
									+ strPageID + "</td>" + " " + "<td>"
									+ strUserIP + "</td>" + "<br>");
							// Get next document from the view
							doc = uLogs.getNextDocument(doc);
							printWriter.println("</table></tr>");
						}
					} else {
						System.out.println("DB not Indexed...");
					}
					// conserve mem...
					uLogs.recycle();
				}
				// ...
				database.recycle();
			}
			// ...
			session.recycle();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}





Use this Program to add records from view to HTML tags and show to browser; info that can be used in Xpages iFrame...

Java
Köll S Cherizard
December 16, 2013 11:16 PM
Rating
2

All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.



No comments yetLogin first to comment...