View Javadoc

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.faces.context.FacesContext;
24  import javax.faces.el.MethodBinding;
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   * <p>
31   * A tag that defines an autosuggest control complete with Ajax binding.<br/>
32   * This allows you to do real time autocompletion via asynchronous
33   * server requests. Note, this control is experimental and it is currently
34   * located in the MyFaces sandbox and can be subject to
35   * alteration in the immediate future. So use it with care.
36   * </p>
37   * 
38   * @JSFComponent
39   *   name = "s:inputSuggestAjax"
40   *   class = "org.apache.myfaces.custom.suggestajax.inputsuggestajax.InputSuggestAjax"
41   *   tagClass = "org.apache.myfaces.custom.suggestajax.inputsuggestajax.InputSuggestAjaxTag"
42   *   tagHandler = "org.apache.myfaces.custom.suggestajax.inputsuggestajax.InputSuggestAjaxTagHandler"
43   *   
44   * @author Gerald Muellan (latest modification by $Author: skitching $)
45   * @author Martin Marinschek
46   *
47   * @version $Revision: 673833 $ $Date: 2008-07-03 16:58:05 -0500 (Thu, 03 Jul 2008) $
48   */
49  
50  public abstract class AbstractInputSuggestAjax extends SuggestAjax
51  {
52      public static final String COMPONENT_TYPE = "org.apache.myfaces.InputSuggestAjax";
53      public static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.InputSuggestAjax";
54  
55      public AbstractInputSuggestAjax()
56      {
57          super();
58  
59          setRendererType(DEFAULT_RENDERER_TYPE);
60  
61          // it makes absolutely no sense to have two autocompletes active at the same time
62          // ensure to disable the browser one - this has nothing to do with the
63          // autocomplete attribute this component provides
64          setAutocomplete("off"); // NON-NLS
65      }
66  
67      public void encodeChildren(FacesContext context) throws IOException
68      {
69          super.encodeChildren(context);
70      }
71  
72      /**
73       * If false, the input field is not automatically populated with the first suggested value. 
74       * 
75       * Default: true
76       * 
77       * @JSFProperty
78       *   defaultValue = "true"
79       * @return
80       */
81      public abstract Boolean getAutoComplete();
82  
83      /**
84       * Method which gets a suggested Object as an argument and returns a 
85       * calculated String label. With this attribute it is possible to 
86       * achieve the same mechanism as it can be found at select menues 
87       * with the label/value pair.
88       * 
89       * @JSFProperty
90       *   methodSignature = "java.lang.Object"
91       *   returnSignature = "java.lang.String"
92       *   stateHolder = "true"
93       * @return
94       */
95      public abstract MethodBinding getItemLabelMethod();
96  }