01: /*
02: * $Id$ $Revision$ $Date$
03: *
04: * ==============================================================================
05: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
06: * use this file except in compliance with the License. You may obtain a copy of
07: * the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14: * License for the specific language governing permissions and limitations under
15: * the License.
16: */
17: package wicket.extensions.ajax.markup.html.autocomplete;
18:
19: import java.io.Serializable;
20:
21: import wicket.Response;
22:
23: /**
24: * A renderer used to generate html output for the {@link AutoCompleteBehavior}.
25: * <p>
26: * Helper implementations of this interface may abstract the implementation specific
27: * details. Direct implementations of this interface should only be used when
28: * total control is required.
29: * <p>
30: * The autocompletion value is supplied via an attribute on the first html element
31: * named <code>textvalue</code>, if no attribute is found the innerHtml property
32: * of the first element will be used instead.
33: *
34: * For example:
35: *
36: * <pre>
37: * new IAutoCompleteRenderer() {
38: * void renderHead(Response r) { r.write("<ul>"); }
39: *
40: * void render(Object o, Response r) {
41: * // notice the textvalue attribute we define for li element
42: * r.write("<li textvalue=\""+o.toString()+"\"><i>"+o.toString()+"</i></li>";
43: * }
44: *
45: * void renderFooter(Response r) { r.write("</ul>"); }
46: * }
47: * </pre>
48: *
49: * @since 1.2
50: *
51: * @author Igor Vaynberg (ivaynberg)
52: * @author Janne Hietamäki (jannehietamaki)
53: *
54: */
55: public interface IAutoCompleteRenderer extends Serializable {
56: /**
57: * Render the html fragment for the given completion object. Usually the
58: * html is written out by calling {@link Response#write(CharSequence)}.
59: *
60: * @param object
61: * completion choice object
62: * @param response
63: * @param criteria
64: */
65: void render(Object object, Response response, String criteria);
66:
67: /**
68: * Render the html header fragment for the completion. Usually the
69: * html is written out by calling {@link Response#write(CharSequence)}.
70: * @param response
71: */
72: void renderHeader(Response response);
73:
74: /**
75: * Render the html footer fragment for the completion. Usually the
76: * html is written out by calling {@link Response#write(CharSequence)}.
77: * @param response
78: */
79: void renderFooter(Response response);
80:
81: }
|