diff --git a/org.springframework.context/src/main/java/org/springframework/model/ui/config/BinderExecutor.java b/org.springframework.context/src/main/java/org/springframework/model/ui/config/BinderExecutor.java deleted file mode 100644 index df65534cb8..0000000000 --- a/org.springframework.context/src/main/java/org/springframework/model/ui/config/BinderExecutor.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2004-2009 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -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. - * @author Keith Donald - * @since 3.0 - * @param the type of model to bind to - */ -public interface BinderExecutor { - - /** - * Configure the model object to bind to. - * @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 <prop>[.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 - */ - BindingResults bind(); - - // TODO return validation results - /** - * Execute the validate operation. - */ - void validate(); - - /** - * The model that was bound to. - */ - M getModel(); - -} diff --git a/org.springframework.context/src/main/java/org/springframework/model/ui/config/BindingLifecycle.java b/org.springframework.context/src/main/java/org/springframework/model/ui/config/BindingLifecycle.java new file mode 100644 index 0000000000..a8c376f625 --- /dev/null +++ b/org.springframework.context/src/main/java/org/springframework/model/ui/config/BindingLifecycle.java @@ -0,0 +1,58 @@ +/* + * Copyright 2004-2009 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.model.ui.config; + +/** + * 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 the type of model this lifecycle is for + */ +public interface BindingLifecycle { + + /** + * Configure the model object to bind to. + * Optional operation. + * If not called, the model be a new instance of created by invoking it's default constructor. + * @param model the model + */ + void setModel(M model); + + /** + * Execute this binding lifecycle. + * The steps are: + *
    + *
  • Get a PresentationModel for model M.
  • + *
  • Bind submitted values to the PresentationModel
  • + *
  • Validate the PresentationModel
  • . + *
  • Commit changes to M if no bind and validation errors occur.
  • + *
+ * @throws IllegalStateExeption if no model was set and no default constructor was found on M. + */ + void execute(); + + /** + * If executing the lifecycle produced errors. + */ + boolean hasErrors(); + + /** + * Get the model instance this lifecycle executed against. + */ + M getModel(); + +}