Java Boolean to Hide/Show Controls on Xpages - ViewEntryCollection


/**
	 * 
	 * Method: SecurityAccessOkay() Created from Copy: 2013.09.10.38.08.PM
	 * Security Access boolean for Xpages Controls (Hide/Show)
	 * 
   * Updated: 2013.09.14.12.51.AM, added instructions to connect to view documents
	 */
	// links control, items on form vanish if Security access is N0
        // plug class name .SecurityAccessOkay() to buttons or other controls
	public boolean SecurityAccessOkay() {

		// let's add a try catch here, grab errors near the end
		try {

			// BEGIN DEBUG
			System.out.println("BEGIN DEBUG | SecurityAccessOkay started... ");
			Database database = (Database) FacesContext.getCurrentInstance()
					.getApplication().getVariableResolver().resolveVariable(
							FacesContext.getCurrentInstance(), "database");
			System.out.println("LoginBeanSQL.java | SecurityAccessOkay Connected to " + database);
			// Find the view in question
			View view = database.getView("SecurityAccessView");
			System.out.println("LoginBeanSQL.java | SecurityAccessOkay Connected to " + view);
			//determine database state for searching
			if (database.isFTIndexed())				
				database.updateFTIndex(false);
		    else 
		    	database.updateFTIndex(true);

			//Collect entries based on search criteria in VIEWACCESS = username101
			ViewEntryCollection vec =
			      view.getAllEntriesByKey(VIEWACCESS, false);
			      System.out.println("LoginBeanSQL.java | ViewEntryCollection Counts Obtained...");
			      System.out.println("LoginBeanSQL.java | ViewEntries " + vec.getCount() + " Account(s) for username101");
				  System.out.println("LoginBeanSQL.java | ViewEntryCollection completed successfully...");

				 //make boolean available to the XP component 'rendered'
				  if (vec.getCount() > 0) {

					  // Boolean true
					  System.out.println("BEGIN DEBUG | SecurityAccessOkay releasing access to controls... ");
				return true;
				  // END DEBUG
				  }

			    } catch(NotesException e) {
			      System.out.println(e.id + " " + e.text);
			      e.printStackTrace();

		} catch (Exception e) {

			e.printStackTrace();
		}

		// message if unsuccessful
		System.out
				.println("LoginBeanSQL.java | ViewEntryCollection completed, but no records available...");
		System.out
		.println("LoginBeanSQL.java | ViewEntryCollection, user does not have access to see component...");
		return false;
	}
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...