KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > webEditor > interfaces > presentationMode


1 /* $Id: presentationMode.java,v 1.11 2001/04/23 03:15:31 agarcia3 Exp $
2     webEditor. The new way in content management
3     Copyright (C) 2001 Alfredo Garcia
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12     GNU General Public License for more details.
13 */

14
15 package webEditor.interfaces;
16
17 import java.io.*;
18 import java.lang.reflect.*;
19
20 import javax.servlet.*;
21 import javax.servlet.http.*;
22 import org.w3c.dom.*;
23
24 import webEditor.core.*;
25
26 /**
27  * Presentation Interface; Here we can check the result of the pages
28  * @author <a HREF="mailto:agarcia@mundofree.com">Alfredo Garcia</a>
29  */

30
31 public class presentationMode {
32
33    /**
34     * Initial configuration values
35     */

36    private configuration initValues;
37
38    /**
39     * Presentation management
40     */

41    private presentation myEditor= null;
42
43    /**
44     * Article management
45     */

46    private article myDocument= null;
47
48     /**
49      * Class constructor
50      * @param initParam Initial values
51      */

52     public presentationMode (configuration initParam) {
53         // We are going to use the values in the hash table when we
54
// create another kind of core object
55
this.initValues = initParam;
56     }
57     
58     /**
59      * Interface for the presentation operations
60      * @param request HTTP request
61      * @param out Servlet Output
62      * @return void
63      */

64     public void presentation (HttpServletRequest request, PrintWriter out)
65     throws ServletException,
66            IOException {
67
68     this.myEditor = new presentation (this.initValues);
69     this.myDocument = new article (this.initValues);
70
71     String JavaDoc opCode = this.initValues.readValue ("HTTP Parameters", "code");
72     if (opCode == null) {
73         // Default operation mode
74
opCode = "showDoc";
75     }
76
77 try {
78     // We use reflection to invoque the proper method
79
Method m = getClass().getMethod(opCode, new Class JavaDoc[] {PrintWriter.class} );
80     m.invoke(this,new Object JavaDoc[] {out} );
81 }
82 catch (Exception JavaDoc e) {
83     out.println ("Code not supported");
84 }
85     }
86
87    /**
88     * Shows the given document
89     * @return void
90     */

91     public void showDoc (PrintWriter out)
92     throws ServletException, IOException
93     {
94     String JavaDoc outputString = null;
95     String JavaDoc docID = this.initValues.readValue ("HTTP Parameters", "docID");
96     if (docID != null) {
97         Document doc = this.myDocument.docRead (docID);
98         outputString = this.myEditor.showDoc (doc, "show");
99     }
100     out.println (outputString);
101     }
102
103 }
104
Popular Tags