1 /*
2 * Angkor Web Framework
3 *
4 * Distributable under LGPL license.
5 * See terms of license at gnu.org.
6 */
7
8 package com.tirsen.angkor;
9
10
11 /***
12 * Base class useful for implementing controllers.
13 *
14 * <!-- $Id: Controller.java,v 1.6 2002/10/13 13:37:26 tirsen Exp $ -->
15 * <!-- $Author: tirsen $ -->
16 *
17 * TODO resolve error-handling
18 * currently this is performed during render phase
19 * setting up the models should be performed during parse phase
20 * during parse phase we can send all errors to the application
21 * which can decide upon passing the user to an error page
22 * how to load the models during parse phase?
23 * when navigating to a new page an event should be sent to that page
24 * ie. when changing the target of a named component link events should
25 * be sent (they should be queued up to the next parse phase), the controller
26 * adds a listener for this event (which probably could be performed by the
27 * base class Controller with an abstract template method createModels() throws Exception)
28 * @author Jon Tirsén (tirsen@users.sourceforge.net)
29 * @version $Revision: 1.6 $
30 */
31 public abstract class Controller extends AbstractViewFactory
32 {
33 private Application application;
34 private transient View view;
35
36 public Controller(Application application)
37 {
38 this.application = application;
39 }
40
41 public Application getApplication()
42 {
43 return application;
44 }
45
46 /***
47 * This method is called by the framework at any time and any number of times during
48 * the render phase.
49 * To decrease memory usage and optimize serialization the view is transient and
50 * referred using a weak reference. This implies that the createView method can be
51 * called at any time recreating the view. The createView method thus need to be able to
52 * completely restore the view and it's link to actualy persistent conversational state such
53 * as the models which should be kept in a non-transient field.
54 */
55 public View getView()
56 {
57 if (view == null) view = createView();
58 return view;
59 }
60
61 public String getDisplayName()
62 {
63 return "untitled";
64 }
65
66 public abstract View createView();
67 }
This page was automatically generated by Maven