1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.myfaces.custom.suggestajax;
20
21 import java.io.IOException;
22
23 import javax.faces.context.FacesContext;
24 import javax.faces.el.MethodBinding;
25 import javax.faces.render.Renderer;
26
27 import org.apache.myfaces.component.LocationAware;
28 import org.apache.myfaces.component.html.ext.HtmlInputText;
29 import org.apache.myfaces.custom.ajax.api.AjaxComponent;
30 import org.apache.myfaces.custom.ajax.api.AjaxRenderer;
31
32
33
34
35
36
37
38
39
40
41
42
43 public abstract class AbstractSuggestAjax extends HtmlInputText
44 implements AjaxComponent, LocationAware
45 {
46 public static final String COMPONENT_TYPE = "org.apache.myfaces.SuggestAjax";
47 public static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.SuggestAjax";
48
49 private MethodBinding _suggestedItemsMethod;
50
51 public Object saveState(FacesContext context)
52 {
53 Object[] values = new Object[4];
54 values[0] = super.saveState(context);
55 values[1] = saveAttachedState(context, _suggestedItemsMethod);
56
57 return values;
58 }
59
60 public void restoreState(FacesContext context, Object state)
61 {
62 Object values[] = (Object[])state;
63 super.restoreState(context, values[0]);
64 _suggestedItemsMethod = (MethodBinding) restoreAttachedState(context, values[1]);
65 }
66
67 public void encodeAjax(FacesContext context)
68 throws IOException
69 {
70 if (context == null) throw new NullPointerException("context");
71 if (!isRendered()) return;
72 Renderer renderer = getRenderer(context);
73 if (renderer != null && renderer instanceof AjaxRenderer)
74 {
75 ((AjaxRenderer) renderer).encodeAjax(context, this);
76 }
77 }
78
79 public void decodeAjax(FacesContext context)
80 {
81
82 }
83
84 public void encodeChildren(FacesContext context) throws IOException
85 {
86 super.encodeChildren(context);
87 }
88
89 public void setSuggestedItemsMethod(MethodBinding suggestedItemsMethod)
90 {
91 _suggestedItemsMethod = suggestedItemsMethod;
92 }
93
94
95
96
97
98
99
100
101 public MethodBinding getSuggestedItemsMethod()
102 {
103 return _suggestedItemsMethod;
104 }
105
106
107
108
109
110
111
112
113
114 public abstract Integer getMaxSuggestedItems();
115
116
117
118
119
120
121
122
123
124 public abstract String getCharset();
125
126
127
128
129
130
131
132
133
134 public abstract String getJavascriptLocation();
135
136
137
138
139
140
141
142
143 public abstract String getImageLocation();
144
145
146
147
148
149
150
151
152 public abstract String getStyleLocation();
153
154
155 }