|
|||||||||
| Home >> All >> org >> scopemvc >> controller >> [ basic overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.scopemvc.controller.basic
Class BasicController

java.lang.Objectorg.scopemvc.controller.basic.BasicController
- All Implemented Interfaces:
- org.scopemvc.core.Controller
- public abstract class BasicController
- extends java.lang.Object
- implements org.scopemvc.core.Controller
- extends java.lang.Object
Full implementation of Controller that adds:
- support for a View to notify its parent Controller when its bound model object is replaced with another (implemented completely in SwingView) via the CHANGE_MODEL_CONTROL_ID ControlID. Note that the PropertyView that a top-level Controller owns must not have a Selector set: this is only allowed for child Controllers that are delegated by a parent to handle a subview and associated submodel that is part of the parent model: the binding will be handled by the parent in this case.
-
ControlException handling
by using
ViewContext.showError(java.lang.String, java.lang.String)55 .
To implement a subclass of BasicController:
-
implement a constructor to set up the Controller's initial
model and View, and to create any child Controllers it may
need.
setModelAndView(java.lang.Object, org.scopemvc.core.View)55 may be useful here. -
implement
doHandleControl(org.scopemvc.core.Control)55 to recognise the ID of incoming Controls and respond to them appropriately. For example:protected void doHandleControl(Control inControl) throws ControlException { if (inControl.matchesID(FOO_CONTROL_ID)) { doFoo(inControl.getParameter()); } else if (inControl.matchesID(BAR_CONTROL_ID)) { doBar(inControl.getParameter()); } } - if necessary, implement a startup() method for the Controller to take its initial action (if your application calls startup() on this Controller).
-
Internal:
if using a View that can dynamically change its bound model,
ensure the View sends the appropriate CHANGE_MODEL_CONTROL_ID Control
to inform the parent Controller of the change. This is fully
implemented in SwingView and
is not needed for ServletView
with the default implementation in
org.scopemvc.view.servlet.xml.XSLPage.
- Version:
- $Revision: 1.9 $ $Date: 2002/01/26 09:46:20 $
| Field Summary | |
static java.lang.String |
CHANGE_MODEL_CONTROL_ID
An internal Control calls changeModel(). |
private java.util.LinkedList |
children
|
static java.lang.String |
EXIT_CONTROL_ID
A convenience Control that can be used when a Controller wants to exit. |
static java.lang.String |
HIDE_VIEW_CONTROL_ID
ID of common Control that is handled by BasicController to hide the current view. |
private static org.apache.commons.logging.Log |
LOG
|
private java.lang.Object |
model
|
private BasicController |
parent
|
private org.scopemvc.core.View |
view
|
| Constructor Summary | |
BasicController()
Construct subclasses by either using a passed model object and View, or creating new ones. |
|
| Method Summary | |
void |
addChild(BasicController inChild)
|
protected void |
bindModelToView(org.scopemvc.core.View inView,
java.lang.Object inModel)
|
private void |
changeModel(java.lang.Object inParameter)
Respond to CHANGE_MODEL_CONTROL_ID to keep the controller's model in sync with the currently shown model if it is changed as a submodel of a model managed by a parent controller. |
protected void |
doHandleControl(org.scopemvc.core.Control inControl)
Override this to recognise Controls that this Controller can handle. |
java.util.List |
getChildren()
This supports ScopeServlet. |
java.lang.Object |
getModel()
|
org.scopemvc.core.Controller |
getParent()
|
org.scopemvc.core.Controller |
getTopParent()
Convenience method. |
org.scopemvc.core.View |
getView()
|
void |
handleControl(org.scopemvc.core.Control inControl)
Application writers see doHandleControl(org.scopemvc.core.Control) 55 . |
protected void |
handleControlException(org.scopemvc.core.ControlException inException)
Called by handleControl(org.scopemvc.core.Control) 55 when a
Control throws a
ControlException. |
protected void |
hideView()
|
protected void |
hideView(org.scopemvc.core.View inView)
|
protected void |
passControlToParent(org.scopemvc.core.Control inControl)
Feed a Control to the parent Controller up the chain of command. |
void |
removeChild(BasicController inChild)
|
void |
setModel(java.lang.Object inModel)
Sets the model object that this Controller links to its View. |
void |
setModelAndView(java.lang.Object inModel,
org.scopemvc.core.View inView)
Change to both a new model object and new View, binding the two together properly. |
protected void |
setParent(BasicController inParent)
Hook this Controller into the chain of responsiblity as a child of the passed Controller. |
void |
setView(org.scopemvc.core.View inView)
Sets the View that this Controller links to its model object. |
protected void |
showError(java.lang.String inErrorTitle,
java.lang.String inErrorMessage)
Convenience to show an error using the current ViewContext. |
protected void |
showView()
|
protected void |
showView(org.scopemvc.core.View inView)
|
void |
shutdown()
Can be called by a parent to shutdown and remove this from the chain of responsibility. |
void |
startup()
Call this after creating the Controller to make it perform its initial action. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
LOG
private static final org.apache.commons.logging.Log LOG
HIDE_VIEW_CONTROL_ID
public static final java.lang.String HIDE_VIEW_CONTROL_ID
- ID of common Control that is handled by BasicController
to hide the current view.
- See Also:
- Constant Field Values
CHANGE_MODEL_CONTROL_ID
public static final java.lang.String CHANGE_MODEL_CONTROL_ID
- An internal Control calls changeModel().
This is an internal Control to keep Controller's model
in sync with the currently shown model in its View.
This occurs when a parent controller modifies its model
when that contains the submodel managed by a child
controller.
This is fully implemented by the concrete impl of
SwingView. ServletView doesn't need it.
- See Also:
- Constant Field Values
EXIT_CONTROL_ID
public static final java.lang.String EXIT_CONTROL_ID
A convenience Control that can be used when a Controller wants to exit. For an application Controller this means exitting the application, but for a sub-controller it probably means just an exit from that local area of functionality. This impl causes this Control to propogate up the chain of responsibility so that if unhandled the application will exit.
The parameter of this Control is the Controller that issued it (ie the one that's shutting down), or null if just issued by
this. The default impl here propogates the Control up, changing the shutdown Controller as it goes up, until it meets the top of the Controller tree at which pointViewContext.exit()55 is called: for Swing this does System.exit and for Servlets it is ignored. If you use this Control, recognise it at some parent of the Controller that can issue it, and take appropriate action.- See Also:
- Constant Field Values
parent
private BasicController parent
children
private java.util.LinkedList children
model
private java.lang.Object model
view
private org.scopemvc.core.View view
| Constructor Detail |
BasicController
public BasicController()
Construct subclasses by either using a passed model object and View, or creating new ones. Use
setModel(java.lang.Object)55 andsetView(org.scopemvc.core.View)55 orsetModelAndView(java.lang.Object, org.scopemvc.core.View)55 . Never show a View on construction: initialisation should set the application up without actually starting it by showing a View. An initial startup action implemented in startup() can show a View when called after construction.Throw a ControlException from subclasses if something goes wrong.
| Method Detail |
getChildren
public final java.util.List getChildren()
- This supports ScopeServlet.
addChild
public final void addChild(BasicController inChild)
removeChild
public final void removeChild(BasicController inChild)
setParent
protected final void setParent(BasicController inParent)
- Hook this Controller into the chain of responsiblity as a child
of the passed Controller. See
addChild(org.scopemvc.controller.basic.BasicController)55
getParent
public final org.scopemvc.core.Controller getParent()
- Specified by:
getParentin interfaceorg.scopemvc.core.Controller
bindModelToView
protected void bindModelToView(org.scopemvc.core.View inView, java.lang.Object inModel)
setModel
public final void setModel(java.lang.Object inModel)
- Sets the model object that this Controller links to its View.
If you need to set both the View and model then use
setModelAndView(java.lang.Object, org.scopemvc.core.View)55 rather than calling setModel and setView separately.- Specified by:
setModelin interfaceorg.scopemvc.core.Controller
getModel
public final java.lang.Object getModel()
- Specified by:
getModelin interfaceorg.scopemvc.core.Controller
setView
public final void setView(org.scopemvc.core.View inView)
- Sets the View that this Controller links to its model object.
Unlinks the old View from the
current model object and also hides it, however, doesn't
show the new view.
If you need to set both the View and model object then slightly
more efficient in establishing the binding to use
setModelAndView(java.lang.Object, org.scopemvc.core.View)55 rather than calling setModel() and setView() separately.- Specified by:
setViewin interfaceorg.scopemvc.core.Controller
getView
public final org.scopemvc.core.View getView()
- Specified by:
getViewin interfaceorg.scopemvc.core.Controller
setModelAndView
public final void setModelAndView(java.lang.Object inModel, org.scopemvc.core.View inView)
- Change to both a new model object and new View,
binding the two together properly. Also disconnect
and discard/hide the previous model/View pair.
Slightly more efficient in changing to a new model/view
binding than calling setModel and setView separately.
handleControl
public final void handleControl(org.scopemvc.core.Control inControl)
- Application writers see
doHandleControl(org.scopemvc.core.Control)55 . This base implementation handles- HIDE_VIEW_CONTROL_ID
- the internal CHANGE_MODEL_CONTROL_ID
- EXIT_CONTROL_ID after allowing application code to intercept in doHandleControl. If this Controller has a parent, then hideView and pass it up, else call the ViewContext to do the exit according to context. ***** should get children to hideView too
- Specified by:
handleControlin interfaceorg.scopemvc.core.Controller
doHandleControl
protected void doHandleControl(org.scopemvc.core.Control inControl) throws org.scopemvc.core.ControlException
Override this to recognise Controls that this Controller can handle. Any unhandled Controls are passed up the chain of responsibility to parent Controllers.
protected void doHandleControl(Control inControl) throws ControlException { if (inControl.matchesID(FOO_CONTROL_ID)) { doFoo(inControl.getParameter()); } else if (inControl.matchesID(BAR_CONTROL_ID)) { doBar(inControl.getParameter()); } }If something goes wrong when running some presentation logic, throw a ControlException which results in a call to
handleControlException(org.scopemvc.core.ControlException)55 ).
handleControlException
protected void handleControlException(org.scopemvc.core.ControlException inException)
- Called by
handleControl(org.scopemvc.core.Control)55 when a Control throws a ControlException. This impl uses theshowError(java.lang.String, java.lang.String)55 method.
passControlToParent
protected final void passControlToParent(org.scopemvc.core.Control inControl)
- Feed a Control to the parent Controller up the chain of command.
getTopParent
public final org.scopemvc.core.Controller getTopParent()
- Convenience method.
- Specified by:
getTopParentin interfaceorg.scopemvc.core.Controller
changeModel
private void changeModel(java.lang.Object inParameter)
- Respond to CHANGE_MODEL_CONTROL_ID to keep the
controller's model in sync with the currently shown model
if it is changed as a submodel of a model managed by a
parent controller.
showView
protected final void showView()
showView
protected final void showView(org.scopemvc.core.View inView)
hideView
protected final void hideView()
hideView
protected final void hideView(org.scopemvc.core.View inView)
showError
protected final void showError(java.lang.String inErrorTitle, java.lang.String inErrorMessage)
- Convenience to show an error using the current
ViewContext.
startup
public void startup()
- Call this after creating the Controller to make it perform
its initial action. Default implementation here just calls
showView() if a View is set.
shutdown
public void shutdown()
- Can be called by a parent to shutdown and remove this from
the chain of responsibility. Default impl does this:
- call shutdown() on every child controller
- call hideView()
- setParent(null)
|
|||||||||
| Home >> All >> org >> scopemvc >> controller >> [ basic overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.scopemvc.controller.basic.BasicController