01: /**
02: * Title: OpenUSS - Open Source University Support System
03: * Description: Page Designer Factory for Presentation
04: * Copyright: Copyright (c) B. Lofi Dewanto
05: * Company: University of Muenster
06: * @author B. Lofi Dewanto
07: * @version 1.0
08: */package org.openuss.presentation.enhydra.framework.designer;
09:
10: import com.lutris.appserver.server.httpPresentation.*;
11:
12: import java.lang.reflect.*;
13:
14: import java.util.*;
15:
16: import org.enhydra.xml.xmlc.html.*;
17:
18: /**
19: * Page Designer Factory for the presentation objects in Enhydra.
20: *
21: * @author B. Lofi Dewanto
22: * @version 1.0
23: */
24: public class PageDesignerFactory {
25: // Static variables
26: private static String DESIGN_SUFFIX = "Designer";
27:
28: /**
29: * Design the page with its respective designer.
30: */
31: public static void design(Object page, String fullClassName,
32: Object po) throws Exception {
33: // The name of the designer class is
34: // Page Name Class + Designer
35: // Example:
36: // - Page name : LoginApplicationDetailOfAssistant.java
37: // - Designer name : LoginApplicationDetailOfAssistantDesigner.java
38: String designFullClassName = new String(fullClassName
39: .concat(DESIGN_SUFFIX));
40:
41: // Create the page and design it
42: Class objectClass = Class.forName(designFullClassName);
43:
44: // Get the constructor
45: Class myPage = Class.forName("java.lang.Object");
46: Class myPo = Class.forName("java.lang.Object");
47: Class[] parameterTypes = new Class[2];
48: parameterTypes[0] = myPage;
49: parameterTypes[1] = myPo;
50:
51: Constructor objectConstructor = objectClass
52: .getConstructor(parameterTypes);
53:
54: // Create the object with the constructor
55: Object[] initArgs = new Object[2];
56: initArgs[0] = page;
57: initArgs[1] = po;
58:
59: BasePageDesigner designer = (BasePageDesigner) objectConstructor
60: .newInstance(initArgs);
61:
62: // Design the page...
63: try {
64: designer.designPage();
65: } catch (Exception ex) {
66: // Error on design, just ignore
67: System.out.println("Error on design the page: " + designer
68: + " - " + ex);
69: }
70: }
71: }
|