1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.apache.myfaces.custom.suggestajax.inputsuggestajax;
20
21 import java.io.IOException;
22
23 import javax.el.MethodExpression;
24 import javax.faces.context.FacesContext;
25
26 import org.apache.myfaces.custom.suggestajax.SuggestAjax;
27
28 /**
29 * Provides an input textbox with "suggest" functionality, using an ajax request to the server.
30 *
31 * @JSFComponent
32 * name = "s:inputSuggestAjax"
33 * class = "org.apache.myfaces.custom.suggestajax.inputsuggestajax.InputSuggestAjax"
34 * superClass = "org.apache.myfaces.custom.suggestajax.inputsuggestajax.AbstractInputSuggestAjax"
35 * tagClass = "org.apache.myfaces.custom.suggestajax.inputsuggestajax.InputSuggestAjaxTag"
36 * tagHandler = "org.apache.myfaces.custom.suggestajax.inputsuggestajax.InputSuggestAjaxTagHandler"
37 *
38 * @author Gerald Muellan (latest modification by $Author: lu4242 $)
39 * @author Martin Marinschek
40 *
41 * @version $Revision: 692186 $ $Date: 2008-09-04 13:24:33 -0500 (Thu, 04 Sep 2008) $
42 */
43
44 public abstract class AbstractInputSuggestAjax extends SuggestAjax
45 {
46 public static final String COMPONENT_TYPE = "org.apache.myfaces.InputSuggestAjax";
47 public static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.InputSuggestAjax";
48
49 public AbstractInputSuggestAjax()
50 {
51 super();
52
53 setRendererType(DEFAULT_RENDERER_TYPE);
54
55 // it makes absolutely no sense to have two autocompletes active at the same time
56 // ensure to disable the browser one - this has nothing to do with the
57 // autocomplete attribute this component provides
58 setAutocomplete("off"); // NON-NLS
59 }
60
61 public void encodeChildren(FacesContext context) throws IOException
62 {
63 super.encodeChildren(context);
64 }
65
66 /**
67 * If false, the input field is not automatically populated with the first suggested value.
68 *
69 * Default: true
70 *
71 * @JSFProperty
72 * defaultValue = "true"
73 * @return
74 */
75 public abstract Boolean getAutoComplete();
76
77 /**
78 * Method which gets a suggested Object as an argument and returns a
79 * calculated String label. With this attribute it is possible to
80 * achieve the same mechanism as it can be found at select menues
81 * with the label/value pair.
82 *
83 * @JSFProperty
84 * methodSignature = "java.lang.Object"
85 * returnSignature = "java.lang.String"
86 * stateHolder = "true"
87 * @return
88 */
89 public abstract MethodExpression getItemLabelMethod();
90 }