public interface BindingStrategy
Definition of an interface for objects that are responsible of the binding of form fields to model objects.
The main purpose of a form is to gather user input. This input must be stored somewhere so that it can be accessed by the application in an appropriate and convenient way. Applications typically use different ways of storing (and further processing of) user input. An obvious way is to create specialized Java bean classes whose properties correspond to the fields provided by the form. That way the data entered into the form can be directly transfered into Java objects. However, this is only one example, and applications may have completely different requirements.
The purpose of this interface is to serve as an abstraction between form
objects and specific data models used by applications. When a form is asked
to read the data entered by the user or to populate its fields from the
application's model it delegates to a BindingStrategy
. So it can be
independent on the concrete data model (technology) used by the application.
This interface defines low-level methods for reading and writing properties
from and to the data model. These are called by the Form
class when
access to the model is needed. All methods defined by this interface
do not throw checked exceptions (depending on the concrete API or technology
a concrete implementation interacts with there will be different types of
exceptions). If something goes wrong, an implementation should throw a
FormRuntimeException
.
Modifier and Type | Method and Description |
---|---|
Object |
readProperty(Object model,
String propertyName)
Reads the value of the specified property from the given model object.
|
void |
writeProperty(Object model,
String propertyName,
Object value)
Writes the specified value of a property of the given model object.
|
Object readProperty(Object model, String propertyName)
FieldHandler
of the
corresponding form field.model
- the model objectpropertyName
- the name of the property in questionvoid writeProperty(Object model, String propertyName, Object value)
model
- the model objectpropertyName
- the name of the property in questionvalue
- the value to be written into this propertyCopyright © 2016 The JGUIraffe Team. All rights reserved.