//JavaBean: Keyword.java // // public class Keyword { private String Category; private String Topic; private String BrowserURL; //getters and setters //call this method from the backing bean public Keyword(String Category, String Topic, String BrowserURL) { this.Category = Category; this.Topic = Topic; this.BrowserURL = BrowserURL; } //+++++++++++++++++++++++++++++++++++++++++++++++++++>> //+++++++++++++++++++++++++++++++++++++++++++++++++++>> //Backing Bean: RetrieveNewNoticeBackingBean.java // // public class RetrieveNewNoticeBackingBean { // declare variables final String DB_LOAD = "Docu.nsf/"; // Added Server calls // 2012.03.02.3.44.PM // declare variable for localhost Server final String LOCAL_LOAD = "http://localhost/"; // declare variable for view final String ViewName = "By Category"; // Get Keyword collection public Keyword[] getKeywords() { // Declare Keyword Array Keyword[] keywords = null; try { // 2011.02.10.9.37.AM // get the current database being used // TO DO: Add to URL instead of static value above Database database = (Database) FacesContext.getCurrentInstance() .getApplication().getVariableResolver().resolveVariable( FacesContext.getCurrentInstance(), "database"); //Additional code here as needed View view = database.getView(ViewName); System.out.println("View Obtained..." + view); Document sDoc; Document ndoc; sDoc = (Document) view.getFirstDocument(); System.out.println("Document Obtained..." + sDoc); // Begin initialization of the Keywords Array // load documents count keywords = new Keyword[view.getEntryCount()]; // Run through Keyword document collection int docount = 0; while (sDoc != null) { Keyword keyword = new Keyword(null, null, null); // render document values to variables of // Keyword object keyword.setCategory(sDoc.getItemValueString("Categories")); keyword.setTopic(sDoc.getItemValueString("Subject")); // TO DO: Alternatively, add database object (facesContext) in the place of // LOCAL_LOAD. This works best in a web Browser... keyword.setBrowserURL(LOCAL_LOAD+DB_LOAD+view+"/"+sDoc.getUniversalID() +"?OpenDocument"); // 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 (Exception e) { e.printStackTrace(); } return null; } }