|
||||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||
java.lang.Object | +--org.sapia.gumby.view.View
A View (the V of MVC) is a kind of Scope that allows associating user interface components to a
model (the M of MVC). Such associations are materialized by Binding instances. The whole process
goes as follows:
Components are registered with the view at creation time (this can be done through XML configuration, by using
gumby:Register tags).
Then, Binding instances are mapped to these components (through their ID) - this can also be
done through XML configuration. A Binding is meant to bind part(s) of the model to a given UI components, and
vice-versa - the Binding interface specifies callbacks corresponding to the different use-cases.
Once bindings have been set up, the model (which is an arbitrary, application-specific object) is assigned to the view.
When this is done for the first time, the view calls the onBind() method of all its bindings.
It is up to applications to trigger the different operations corresponding to a given MVC lifecycle; more precisely, applications are in charge of implementing the C in MVC.
The following situations can arise:
fireUpateModel() on the View. This internally calls the updateModel() method
of all Bindings registered with the view (typically, the bindings assign the input data to the model).
Then the listener is in charge of actually handling the newly updated model (for example by performing an SQL
update with the model's new data.
setModel() on the View. Then, internally,
the onChanged() method of all bindings is called; the bindings should then update their corresponding
UI components accordingly.
fireUpdate() on it. The view then calls onUpdated
on all the Bindings that it holds.
Note that developpers are responsible for performant event-handling code: long-running operations can freeze the user interface, a characteristic that is often blamed on Swing, but is in fact the result of poor code.
Binding| Constructor Summary | |
|---|---|
View(RenderContext context)
|
|
| Method Summary | |
|---|---|
Object |
acquire(String name)
Returns the object that is mapped to the given name. |
void |
addBinding(Binding binding)
|
void |
fireUpdated()
Internally calls the onUpdate() method of
all bindings held by this instance. |
void |
fireUpdated(String id)
Internally calls the onUpdated() method of
the binding corresponding to the given identifier. |
void |
fireUpdateModel()
Internally calls the updateModel() method of
all bindings held by this instance. |
void |
fireUpdateModel(String id)
Internally calls the updateModel() method of
the binding corresponding to the given identifier. |
Object |
get(String name)
|
RenderContext |
getContext()
|
Object |
getModel()
|
void |
put(String name,
Object o)
|
void |
removeBinding(String id)
Removes the Binding corresponding to the given
identifier from ths instance. |
void |
setModel(Object model)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public View(RenderContext context)
| Method Detail |
public RenderContext getContext()
RenderContext.
public Object acquire(String name)
throws IllegalArgumentException
name - a name.
Object.
IllegalArgumentException - if no such object could be found.public Object get(String name)
get in interface Scopename - the name of the object to retrieve.
Object corresponding to the given
name, or null if no such object exists.Scope.get(java.lang.String)
public void put(String name,
Object o)
put in interface Scopename - the name under which to keep the object.o - an Object.Scope.put(java.lang.String, java.lang.Object)public void setModel(Object model)
model - an arbitratry Object.public Object getModel()
public void addBinding(Binding binding)
binding - a Binding.public void removeBinding(String id)
Binding corresponding to the given
identifier from ths instance.
id - an binding identifier.public void fireUpdated(String id)
onUpdated() method of
the binding corresponding to the given identifier.
id - the identifier of a Binding held within
this instance.Binding.onUpdated(View, Object)public void fireUpdated()
onUpdate() method of
all bindings held by this instance.
Binding.onUpdated(View, Object)public void fireUpdateModel(String id)
updateModel() method of
the binding corresponding to the given identifier.
id - the identifier of a Binding held within
this instance.Binding.updateModel(View, Object)public void fireUpdateModel()
updateModel() method of
all bindings held by this instance.
Binding.updateModel(View, Object)
|
||||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||