01: /**
02: * Copyright 2006 Webmedia Group Ltd.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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: **/package org.araneaframework.uilib.form;
16:
17: import java.io.Serializable;
18:
19: /**
20: * Interface through which {@link org.araneaframework.uilib.form.FormElement}s
21: * register the error messages produced by failed validation.
22: *
23: * @see org.araneaframework.uilib.form.StandardFormElementValidationErrorRenderer
24: * @see org.araneaframework.uilib.form.LocalFormElementValidationErrorRenderer
25: *
26: * @author Taimo Peelo (taimo@araneaframework.org)
27: * @since 1.1
28: */
29: public interface FormElementValidationErrorRenderer extends
30: Serializable {
31: /**
32: * {@link org.araneaframework.uilib.form.FormElement} property key (see
33: * {@link org.araneaframework.uilib.form.FormElement#getProperty(Object)}) under which validation errors may be stored.
34: */
35: public static final String ERRORS_PROPERTY_KEY = "FormElementValidationErrors";
36:
37: /**
38: * Style class which should be present on all DOM elements which contain the rendered errors.
39: */
40: public static final String RENDERED_FORMELEMENTERROR_STYLECLASS = "aranea-formelementerrors";
41:
42: /**
43: * Called by {@link org.araneaframework.uilib.form.FormElement#addError(String)} to register validation errors.
44: * @param element element which produced the validation error
45: * @param error detailed error message
46: */
47: void addError(FormElement element, String error);
48:
49: /**
50: * Called by {@link org.araneaframework.uilib.form.FormElement#clearErrors()} to clear validation errors.
51: * @param element element which errors should be cleared
52: */
53: void clearErrors(FormElement element);
54:
55: /**
56: * Returns client side script capable of rendering errors in desired format. This should
57: * be in form that can be directly appended to rendered HTML and should be enclosed in
58: * HTML <script> tags.
59: *
60: * When the errors are rendered with some other mechanism, returns <code>null</code> or empty String.
61: *
62: * @return script capable of rendering errors in desired format */
63: String getClientRenderText(FormElement element);
64: }
|