KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > validation > BindingResult


1 /*
2  * Copyright 2002-2006 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.springframework.validation;
18
19 import java.util.Map JavaDoc;
20
21 import org.springframework.beans.PropertyEditorRegistry;
22
23 /**
24  * General interface that represents binding results. Extends the
25  * {@link Errors interface} for error registration capabilities,
26  * allowing for a {@link Validator} to be applied, and adds
27  * binding-specific analysis and model building.
28  *
29  * <p>Serves as result holder for a {@link DataBinder}, obtained via
30  * the {@link DataBinder#getBindingResult()} method. BindingResult
31  * implementations can also be used directly, for example to invoke
32  * a {@link Validator} on it (e.g. as part of a unit test).
33  *
34  * @author Juergen Hoeller
35  * @since 2.0
36  * @see DataBinder
37  * @see Errors
38  * @see Validator
39  * @see BeanPropertyBindingResult
40  * @see DirectFieldBindingResult
41  * @see MapBindingResult
42  */

43 public interface BindingResult extends Errors {
44
45     /**
46      * Prefix for the name of the BindingResult instance in a model,
47      * followed by the object name.
48      */

49     String JavaDoc MODEL_KEY_PREFIX = BindingResult.class.getName() + ".";
50
51
52     /**
53      * Return the wrapped target object, which may be a bean, an object with
54      * public fields, a Map - depending on the concrete binding strategy.
55      */

56     Object JavaDoc getTarget();
57
58     /**
59      * Return a model Map for the obtained state, exposing a BindingResult
60      * instance as '{@link #MODEL_KEY_PREFIX MODEL_KEY_PREFIX} + objectName'
61      * and the object itself as 'objectName'.
62      * <p>Note that the Map is constructed every time you're calling this method.
63      * Adding things to the map and then re-calling this method will not work.
64      * <p>The attributes in the model Map returned by this method are usually
65      * included in the {@link org.springframework.web.servlet.ModelAndView}
66      * for a form view that uses Spring's <code>bind</code> tag in a JSP,
67      * which needs access to the BindingResult instance. Spring's pre-built
68      * form controllers will do this for you when rendering a form view.
69      * When building the ModelAndView instance yourself, you need to include
70      * the attributes from the model Map returned by this method.
71      * @see #getObjectName()
72      * @see #MODEL_KEY_PREFIX
73      * @see org.springframework.web.servlet.ModelAndView
74      * @see org.springframework.web.servlet.tags.BindTag
75      * @see org.springframework.web.servlet.mvc.SimpleFormController
76      */

77     Map JavaDoc getModel();
78
79     /**
80      * Return the underlying PropertyEditorRegistry.
81      * @throws UnsupportedOperationException if the BindingResult
82      * does not support a PropertyEditorRegistry
83      */

84     PropertyEditorRegistry getPropertyEditorRegistry();
85
86     /**
87      * Mark the specified disallowed field as suppressed.
88      * <p>The data binder invokes this for each field value that was
89      * detected to target a disallowed field.
90      * @see DataBinder#setAllowedFields
91      */

92     void recordSuppressedField(String JavaDoc fieldName);
93
94     /**
95      * Return the list of fields that were suppressed during the bind process.
96      * <p>Can be used to determine whether any field values were targeting
97      * disallowed fields.
98      * @see DataBinder#setAllowedFields
99      */

100     String JavaDoc[] getSuppressedFields();
101
102     /**
103      * Add a custom {@link ObjectError} or {@link FieldError} to the errors list.
104      * <p>Intended to be used by cooperating strategies such as {@link BindingErrorProcessor}.
105      * @see ObjectError
106      * @see FieldError
107      * @see BindingErrorProcessor
108      */

109     void addError(ObjectError error);
110
111     /**
112      * Resolve the given error code into message codes for the given field.
113      * <p>Calls the configured {@link MessageCodesResolver} with appropriate parameters.
114      * @param errorCode the error code to resolve into message codes
115      * @param field the field to resolve message codes for
116      * @return the resolved message codes
117      */

118     String JavaDoc[] resolveMessageCodes(String JavaDoc errorCode, String JavaDoc field);
119
120 }
121
Popular Tags