KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openuss > presentation > enhydra > framework > designer > PageDesignerFactory


1 /**
2  * Title: OpenUSS - Open Source University Support System
3  * Description: Page Designer Factory for Presentation
4  * Copyright: Copyright (c) B. Lofi Dewanto
5  * Company: University of Muenster
6  * @author B. Lofi Dewanto
7  * @version 1.0
8  */

9 package org.openuss.presentation.enhydra.framework.designer;
10
11 import com.lutris.appserver.server.httpPresentation.*;
12
13 import java.lang.reflect.*;
14
15 import java.util.*;
16
17 import org.enhydra.xml.xmlc.html.*;
18
19
20 /**
21  * Page Designer Factory for the presentation objects in Enhydra.
22  *
23  * @author B. Lofi Dewanto
24  * @version 1.0
25  */

26 public class PageDesignerFactory {
27     // Static variables
28
private static String JavaDoc DESIGN_SUFFIX = "Designer";
29
30     /**
31      * Design the page with its respective designer.
32      */

33     public static void design(Object JavaDoc page, String JavaDoc fullClassName, Object JavaDoc po)
34                        throws Exception JavaDoc {
35         // The name of the designer class is
36
// Page Name Class + Designer
37
// Example:
38
// - Page name : LoginApplicationDetailOfAssistant.java
39
// - Designer name : LoginApplicationDetailOfAssistantDesigner.java
40
String JavaDoc designFullClassName = new String JavaDoc(fullClassName.concat(
41                                                         DESIGN_SUFFIX));
42
43         // Create the page and design it
44
Class JavaDoc objectClass = Class.forName(designFullClassName);
45
46         // Get the constructor
47
Class JavaDoc myPage = Class.forName("java.lang.Object");
48         Class JavaDoc myPo = Class.forName("java.lang.Object");
49         Class JavaDoc[] parameterTypes = new Class JavaDoc[2];
50         parameterTypes[0] = myPage;
51         parameterTypes[1] = myPo;
52
53         Constructor objectConstructor = objectClass.getConstructor(
54                                                 parameterTypes);
55
56         // Create the object with the constructor
57
Object JavaDoc[] initArgs = new Object JavaDoc[2];
58         initArgs[0] = page;
59         initArgs[1] = po;
60
61         BasePageDesigner designer = (BasePageDesigner) objectConstructor.newInstance(
62                                             initArgs);
63
64         // Design the page...
65
try {
66             designer.designPage();
67         } catch (Exception JavaDoc ex) {
68             // Error on design, just ignore
69
System.out.println("Error on design the page: " + designer +
70                                " - " + ex);
71         }
72     }
73 }
Popular Tags