HTTP jQuery Report Tool JavaAgent

/**
 * Copyright 2013 Dököll Solutions, Inc.
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
 *
 * @AppName: DöcuContent.nsf
 * Program: HTTPjQueryReportToolJavaAgent | JQueryReportToolJavaAgent.java
 * jQuery Report data for Xpage, to be read by JavaBean
 * Created: 2013.12.19.11.59.PM
 */


import java.io.PrintWriter;

import lotus.domino.AgentBase;
import lotus.domino.Database;
import lotus.domino.Document;
import lotus.domino.Session;
import lotus.domino.View;

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

public class JQueryReportToolJavaAgent extends AgentBase {
	 final String GotoPage =
	 "http://localhost/docucontent.nsf/";
	 //button code...
	public void NotesMain() {
		try {
			// Session
			Session session = this.getSession();
			// Output using PrintWriter
			PrintWriter printWriter = this.getAgentOutput();
			// ...
			Database database = session.getDatabase("", "docucontent.nsf");
			System.out.println("database obtained..." + database);
			// ensure database is not null
			if (database != null) {
				// ...
				View uLogs = database.getView("UserAppLogsViewListings");
				System.out.println("View obtained..." + uLogs);
				if (database.isFTIndexed()) {
					System.out.println("database is indeed indexed for searching...");
					// ensure view is not null
					if (uLogs != null) {
						// grab first doc
						Document doc = uLogs.getFirstDocument();
						//String/Int object(s) declaration to collect records
						String strUserName = null;
						String strUserNumber = null;
						String strPageID = null;
						String strUserIP = null;
						int c = 0;
						//prepare HTML page to build jQuery report
						//TODO: Ensure code is up to snuff for actual Servers
						printWriter.println("<html>");
						printWriter.println("<head>");
						printWriter.println("<title>jQuery Report</title>");
						printWriter.println("<meta charset='utf-8'>");
						printWriter.println("<meta name='viewport' content='width=device-width, initial-scale=1'> ");
						printWriter.println("<link rel='stylesheet'  href='/docucontent.nsf/mobile/app/tree/css/themes/default/jquery.mobile-1.2.0.css' />  ");
						printWriter.println("<link rel='stylesheet' href='/docucontent.nsf/mobile/app/tree/docs/_assets/css/jqm-docs.css'/>");
						printWriter.println("<script src='/docucontent.nsf/mobile/app/tree/js/jquery.js'></script>");
						printWriter.println("<script src='/docucontent.nsf/mobile/app/tree/docs/docs/_assets/js/jqm-docs.js'></script>");
						printWriter.println("<script src='/docucontent.nsf/mobile/app/tree/js/jquery.mobile-1.2.0.js'></script>");
						printWriter.println("</head>");
						printWriter.println("<body>");
						
						printWriter.println("<div align='left'>");
						printWriter.println("<div data-role='content' align='left'>");
						printWriter.println("<div class='content-secondary'>");
						printWriter.println("<ul data-role='listview' data-theme='d' data-divider-theme='d'>");
						printWriter.println("<li data-theme='a'>jQuery Login Data Report</li>");
						//Scan view for all documents
						while (doc != null) {
							c += 1;
							// Retrieve contents spit out HTML
							// TODO: Mix and Play jQuery with Xpages functionality
							strUserName = doc.getItemValueString("SearchText");
							strUserNumber = doc
									.getItemValueString("itemNumber");
							strPageID = doc.getItemValueString("PageID");
							strUserIP = doc.getItemValueString("UserIP");
							printWriter.println("<table border='1'><tr>");
		
							
							printWriter.println("<li data-role='list-divider'>" + strUserName + "<span class='ui-li-count'>" + " " + strUserNumber+ "</span></li>"
									+ "<li><a href="+GotoPage + uLogs +"/"+ doc.getUniversalID() + "?EditDocument" +"><h3>"+ strPageID +"</h3><p><strong>"+ strUserIP 
									+"</strong></p><p><a href="+GotoPage + uLogs +"/"+ doc.getUniversalID() + "?EditDocument" +">"+doc.getUniversalID()+"</a></p><p class='ui-li-aside'><strong>"
									+ c + "</strong></p></a></li></ul></div></div></div>");

							doc = uLogs.getNextDocument(doc);
						
						}
					} else {
						System.out.println("database not indexed for searching...");
					}
					//recycle for memory...
					uLogs.recycle();
				}
				// ...
				database.recycle();
			}
			// ...
			session.recycle();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}





Use this XSnippet to load a jQuery report to your browser, info that can be used within Xpages form via iFrame tags

Brief Instructions:
(1) Download Döcu Content V2 App from the following URL: http://www.openntf.org/internal/home.nsf/release.xsp?action=openDocument&documentId=086FCFC1D0560B8586257C410033D4DF
(2) Create JavaAgent in this App
(3) Go to Agent Properties and give it full permissions (3rd option)
(4) Edit the Agent's Alias into 'javaagentjqueryreportdatatool.html'
(5) Run the report in your browser as such: http://localhost/docucontent.nsf/javaagentjqueryreportdatatool.html
(6) Watch this Youtube for more info: http://youtu.be/_uShPNpCmII

Note: This item may still need additional testing, but first results are promising, equiped to run on servers, just update GotoPage...

Java
Köll S Cherizard
December 20, 2013 12:21 AM
Rating
9

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...