Döcu Content

Notes Document View BackingBean

Xpages File or Form Element


Navigate Döcu Content App via links on Xpages form, interact with documents viewing page. This tutorial makes use of existing code previously submitted code via, see: http://www.dokollsolutionsinc.com/CutAndPasteAttachment.html/.


Information contained in the following is presented as is. This tutorial assumes you have basic Lotus Notes Configuration and Programming knowledge.



* Copyright 2012 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


Unless required by applicable law or agreed to in writing, software

distributed under the License is distributed on an "AS IS" BASIS,


See the License for the specific language governing permissions and

limitations under the License.

* Program: RetrieveNewNoticeBackingBean.java

* Created from Copy: 2012.

* New Retrieval Bean for Toy Submissions via Xpages



package com.osc.its.bulletin.board.JavaBeans;//...

//java imports

import java.util.Vector;

//faces imports

import javax.faces.context.FacesContext;

//servlet imports

import javax.servlet.http.HttpServletRequest;

//notes imports...

import lotus.domino.Item;

import lotus.domino.View;

import lotus.domino.local.Database;

import lotus.domino.local.Document;


* @author Dököll Solutions, Inc.

* @version 2012.



public class RetrieveNewNoticeBackingBean {

// Declare variable, load view name

final String ViewName = "By Category";

// Get Keyword collection

@SuppressWarnings( { "null", "unchecked" })

public Keyword[] getKeywords() {

// Declare Keyword Array

Keyword[] keywords = null;

try {

// get the current database being used

Database database = (Database) FacesContext.getCurrentInstance()



FacesContext.getCurrentInstance(), "database");

// Get the full URL and join it with the current document

// from Notes back-end

// 2012.

HttpServletRequest req = (HttpServletRequest) FacesContext




//Declare and variable to grab full URL

String baseURL =


req.getRequestURI(), req.getContextPath());

// Find the view in questionView view = database.getView(ViewName);

//load to console for debugging purposes

System.out.println("View Obtained..." + view);


Document sDoc;


Document ndoc;

//grab our first doc

sDoc = (Document) view.getFirstDocument();

//load to console for debugging purposes

System.out.println("Document Obtained..." + sDoc);

// load documents count

keywords = new Keyword[view.getEntryCount()];

// Run through Keyword document collection

int docount = 0;

while (sDoc != null) {

//initialize vector, load items

Vector<Item> itemVector = sDoc.getItems();

//run though and pull off items (attachments) one at a time

for (Item inboundItem : itemVector) {

//ensure item is of type attachment

if (inboundItem.getType() == Item.ATTACHMENT) {

//declare and initialize attachment placeholder

String AttMents = inboundItem.getValueString();

//call Keyword and fill Category, Topic,

BrowserURL, FileName variables...

Keyword keyword = new Keyword(null, null, null,


// render document(s) to variables of Keyword





keyword.setBrowserURL(baseURL + "/" + view +


+ sDoc.getUniversalID() + "?


keyword.setFileName(baseURL + "/" + view + "/"

+ sDoc.getUniversalID() + "/" + "$FILE/"

+ sDoc.getAttachment(AttMents));//

// Send Keyword object into Keywords Array

keywords[docount] = keyword;

// increment counts

docount += 1;// load next doc

ndoc = (Document) view.getNextDocument(sDoc);

sDoc = ndoc;




// return the Array

return keywords;

//catch accordingly

} catch (Exception e) {



// return nothing

return null;



Döcu Content View Documents (Xpages Style)

Get a copy of RetrieveNewNoticeBackingBean.java BackingBean through the above URL, also pick up a copy of the associating JavaBean file: Keyword.java. The file should included Xpages Form to compliment the class files. Follow instructions below to start viewing your document as a list in an Xpage.

Note: You may also need a download of any of the following Döcu Apps: Döcu (docu.nsf), or Döcu Content (docucontent.nsf), available on OpenNTF.org, through the Projects page, you can search by App name: (http://www.openntf.org/Internal/home.nsf/projects.xsp ) or Click our download page: http://www.dokollsolutionsinc.com/. You need to do this to fully complete the instruction below.

Xpages File Instructions, see screenshots for areas of interest

  1. Declare a variable final String GotoPage = "xpbycategorylist.xsp"; for view page

  2. From the above BackingBean, go to public Keyword[] getKeywords()

  3. Change keyword.setBrowserURL(baseURL + "/" + view + "/" +

  4. To keyword.setBrowserURL(baseURL + "/" + GotoPage + "?" + "documentId=" +

  5. Create a New Xpages Form the easy way, by dragging and dropping controls on the page

  6. Call this Xpage 'xpbycategorylist.xsp', use it to Open a Document in this case

  7. DataSource should be based on 'Bulletins' Form in docu.nsf or docucontent.nsf back-end

  8. Set Default property in Form (Bulletins) within the On Web Access section to HTML

  9. Open DDE and fire Xpages Form called xpbycategory, this feeds into xpbycategorylist

  10. Click any row/link under Type in the xpbycategory.xsp Xpage

  11. xpbycategorylist.xsp should now load to Browser with specific document accessed

Screenshots, BackingBean excerpts, Xpages, and Form elements


(1) Declaring variable to hold Xpages Form name

(2) Viewing Documents via Form element

(3) Viewing Documents via Xpages element

(4) Creating Xpages Form to view documents

(5) Connecting to Bulletins Form as DataSource item

(6) Setting property from Notes to HTML

(7) Running Xpages with List of Documents

(8) Clicking link to make available specific Doc

(9) Viewing specific Doc

TIP: You should make a copy of teh Bulletins Form to toggle viewing documents via Form or Xpages depending on security access of your users.


You can now view documents via Xpages using documentId rather than a view/form. This should facilitate setting pages that only certain users need to see, while leaving your main Form design intact.

Questions, comments, please post a brief message on our Contact form on the main site.

Thank you for coming...