01: /*
02: ItsNat Java Web Application Framework
03: Copyright (C) 2007 Innowhere Software Services S.L., Spanish Company
04: Author: Jose Maria Arranz Santamaria
05:
06: This program is free software: you can redistribute it and/or modify
07: it under the terms of the GNU Affero General Public License as published by
08: the Free Software Foundation, either version 3 of the License, or
09: (at your option) any later version. See the GNU Affero General Public
10: License for more details. See the copy of the GNU Affero General Public License
11: included in this program. If not, see <http://www.gnu.org/licenses/>.
12: */
13:
14: package org.itsnat.core.domutil;
15:
16: import org.w3c.dom.Element;
17:
18: /**
19: * Used by {@link ElementLabel} objects to render the associated value.
20: *
21: * @author Jose Maria Arranz Santamaria
22: * @see ElementLabel#setElementLabelRenderer(ElementLabelRenderer)
23: * @see org.itsnat.core.ItsNatDocument#createDefaultElementLabelRenderer()
24: */
25: public interface ElementLabelRenderer {
26: /**
27: * Renders as markup the specified value into the specified element of the label.
28: *
29: * <p>The specified element must be used to render the value below, usually
30: * as a text node.</p>
31: *
32: * <p>Default implementation renders the specified value inside the first text node found below the
33: * specified content element.</p>
34: *
35: * @param label the target label.
36: * @param value the value to render.
37: * @param elem the DOM element to render the value inside. This element
38: * is a hint, if provided, should be obtained by calling {@link ElementLabel#getParentElement()}.
39: * @param isNew true if this is the first time the markup is rendered. Default implementation ignores this parameter.
40: */
41: public void renderLabel(ElementLabel label, Object value,
42: Element elem, boolean isNew);
43:
44: /**
45: * Unrenders the label markup. This method is called <i>before</i> the markup
46: * is removed.
47: *
48: * <p>Default implementation does nothing.</p>
49: *
50: * @param label the target label.
51: * @param elem the DOM element used to render the label. This element
52: * is a hint, if provided, should be obtained by calling {@link ElementLabel#getParentElement()}>.
53: */
54: public void unrenderLabel(ElementLabel label, Element elem);
55: }
|