public class ViewController extends Controller
A controller class that handles application logic for a view. In most cases a FormController will be sufficient to handle the logic for a form. Some more complex views may require their own controllers as well, in which case you might use a ViewController to handle Action dispatch on the view.
Controllers form a hierarchy similar to UI components. E.g. A controller has a parent controller, and events that are not
consumed by the child will propagate to the parent. See FormController
for a more details discussion of the Controller hierarchy.
Modifier and Type | Class and Description |
---|---|
static class |
ViewController.DidSetViewEvent
Event that is fired when a "view" is set in a view controller.
|
static class |
ViewController.DidUnSetViewEvent
Event that is fired when a "view" is unset from a view controller.
|
static interface |
ViewController.ViewDecorator |
Controller.CreateObjectRequest<T>, Controller.ObjectFactory
Constructor and Description |
---|
ViewController(Controller parent)
Creates a new ViewController with the given parent controller.
|
Modifier and Type | Method and Description |
---|---|
void |
addViewDecorator(ViewController.ViewDecorator decorator) |
<T extends Entity> |
createViewContext(Class<T> type,
T entity) |
protected Component |
decorateView(Component view) |
void |
deinitialize()
Callback called when the view is deinitialized (i.e.
|
Entity |
getNearestViewModel()
Crawls up controller hierarchy until it finds a controller with an attached view model.
|
String |
getTitle() |
Component |
getView()
Gets the view associated with this controller.
|
static ViewController |
getViewController(ActionEvent evt) |
static ViewController |
getViewController(Component cmp)
Gets the ViewController associated with this component.
|
Entity |
getViewModel()
Gets the ViewModel.
|
void |
initController()
Callback called when the view is initialized (i.e.
|
void |
removeViewDecorator(ViewController.ViewDecorator decorator) |
void |
setTitle(String title) |
void |
setView(Component view)
Sets the view associated with this controller.
|
actionPerformed, addAction, addAction, addActionListener, addActions, addActions, addEventListener, addLookup, addLookup, addObjectFactory, createObjectWithFactory, createViewNode, dispatchEvent, extendAction, extendAction, fillSlot, getAction, getActions, getActionsNode, getApplicationController, getFormController, getFormController, getInheritedAction, getInheritedActions, getParent, getSectionController, getSingleActionsNode, getViewController, getViewNode, initControllerActions, isStarted, lookup, lookupEntity, onStartController, onStopController, parentLookup, parentLookupEntity, refresh, removeActionListener, removeEventListener, setParent, start, startController, withLookup, withLookupEntity, withParentLookup, withParentLookupEntity
public ViewController(Controller parent)
Creates a new ViewController with the given parent controller.
parent
- public void setTitle(String title)
public String getTitle()
public void addViewDecorator(ViewController.ViewDecorator decorator)
public void removeViewDecorator(ViewController.ViewDecorator decorator)
public void setView(Component view)
Sets the view associated with this controller.
view
- public static ViewController getViewController(Component cmp)
Gets the ViewController associated with this component. This will return the "nearest" view controller found in the view hierarchy. I.e. If the cmp has no view controller, then it will look in the parent container, and it’s parent, if necessary, all the way up to the Form.
cmp
- Component whose ViewController we wish to retrieve.public static ViewController getViewController(ActionEvent evt)
public Component getView()
Gets the view associated with this controller.
public void initController()
Callback called when the view is initialized (i.e. made visible)
public void deinitialize()
Callback called when the view is deinitialized (i.e. removed from display hierarchy).
public Entity getViewModel()
Gets the ViewModel.
public Entity getNearestViewModel()
Crawls up controller hierarchy until it finds a controller with an attached view model.
public <T extends Entity> ViewContext<T> createViewContext(Class<T> type, T entity)
Copyright © 2022. All Rights Reserved.