alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

/*  $Id: presentationMode.java,v 1.11 2001/04/23 03:15:31 agarcia3 Exp $ 
    webEditor. The new way in content management
    Copyright (C) 2001  Alfredo Garcia

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
*/

package webEditor.interfaces;

import java.io.*;
import java.lang.reflect.*;

import javax.servlet.*;
import javax.servlet.http.*;
import org.w3c.dom.*;

import webEditor.core.*;

/**
 * Presentation Interface; Here we can check the result of the pages
 * @author <a href="mailto:agarcia@mundofree.com">Alfredo Garcia
 */

public class presentationMode {

   /**
    * Initial configuration values
    */
   private configuration initValues;

   /**
    * Presentation management
    */
   private presentation myEditor= null;

   /**
    * Article management
    */
   private article myDocument= null;

    /**
     * Class constructor
     * @param initParam		Initial values
     */
    public presentationMode (configuration initParam) { 
    	// We are going to use the values in the hash table when we
	// create another kind of core object
   	this.initValues = initParam;
    }
    
    /**
     * Interface for the presentation operations
     * @param request		HTTP request
     * @param out		Servlet Output
     * @return void
     */
    public void presentation (HttpServletRequest request, PrintWriter out) 
    throws ServletException, 
    	   IOException {

	this.myEditor = new presentation (this.initValues);
	this.myDocument = new article (this.initValues);

	String opCode = this.initValues.readValue ("HTTP Parameters", "code");
	if (opCode == null) {
		// Default operation mode
		opCode = "showDoc";
	}

try { 
	// We use reflection to invoque the proper method
	Method m = getClass().getMethod(opCode, new Class[] {PrintWriter.class} ); 
	m.invoke(this,new Object[] {out} ); 
} 
catch (Exception e) { 
	out.println ("Code not supported");
} 
    }

   /**
    * Shows the given document
    * @return void
    */
    public void showDoc (PrintWriter out)
	throws ServletException, IOException 
    {
	String outputString = null;
	String docID = this.initValues.readValue ("HTTP Parameters", "docID");
	if (docID != null) {
		Document doc = this.myDocument.docRead (docID);
		outputString = this.myEditor.showDoc (doc, "show");	
	}
	out.println (outputString);
    }

}
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.