提交 0f434883 编写于 作者: K Keith Donald

binding lifecycle per design review

上级 cd9f0bc1
......@@ -15,48 +15,44 @@
*/
package org.springframework.model.ui.config;
import org.springframework.model.binder.Binder;
import org.springframework.model.binder.BindingResults;
/**
* A SPI interface that lets you configure a {@link Binder}, then execute it.
* Hides details about the source of binder field values.
* A SPI interface that lets you configure a BindingLifecycle for a model, then execute it.
* Hides details about the source of submitted field values.
* @author Keith Donald
* @since 3.0
* @param <M> the type of model to bind to
* @param <M> the type of model this lifecycle is for
*/
public interface BinderExecutor<M> {
public interface BindingLifecycle<M> {
/**
* Configure the model object to bind to.
* Optional operation.
* If not called, the model be a new instance of <M> created by invoking it's default constructor.
* @param model the model
*/
void setModel(M model);
/**
* Configure a bindable field.
* @param fieldPath the field path, typically a domain object property path on the model object in format &lt;prop&gt;[.nestedProp]
* @return a builder for the field model configuration
*/
FieldModelConfiguration field(String fieldPath);
// TODO allow injection of pre-created BindingRules
/**
* Execute the bind operation.
* @return the binding results
* Execute this binding lifecycle.
* The steps are:
* <ul>
* <li>Get a PresentationModel for model M.</li>
* <li>Bind submitted values to the PresentationModel</li>
* <li>Validate the PresentationModel</li>.
* <li>Commit changes to M if no bind and validation errors occur.</li>
* </ul>
* @throws IllegalStateExeption if no model was set and no default constructor was found on M.
*/
BindingResults bind();
void execute();
// TODO return validation results
/**
* Execute the validate operation.
* If executing the lifecycle produced errors.
*/
void validate();
boolean hasErrors();
/**
* The model that was bound to.
* Get the model instance this lifecycle executed against.
*/
M getModel();
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册