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  
20  package org.apache.myfaces.tobago.internal.taglib.component;
21  
22  import org.apache.myfaces.tobago.apt.annotation.DynamicExpression;
23  import org.apache.myfaces.tobago.apt.annotation.Tag;
24  import org.apache.myfaces.tobago.apt.annotation.TagAttribute;
25  import org.apache.myfaces.tobago.apt.annotation.UIComponentTag;
26  import org.apache.myfaces.tobago.apt.annotation.UIComponentTagAttribute;
27  import org.apache.myfaces.tobago.component.RendererTypes;
28  import org.apache.myfaces.tobago.internal.taglib.declaration.HasIdBindingAndRendered;
29  import org.apache.myfaces.tobago.model.SuggestFilter;
30  
31  import javax.faces.component.UIInput;
32  
33  /**
34   * Renders a list of suggested texts for a given input field.
35   *
36   * Basic features:
37   * <ul>
38   *   <li>provide a list directly while rendering (not AJAX needed) [todo]</li>
39   *   <li>update by typing (AJAX)</li>
40   *   <li>minimum number of typed characters (to avoid useless requests)</li>
41   *   <li>update delay (useful for optimization)</li>
42   *   <li>filter on client side (useful for optimization) [todo]</li>
43   * </ul>
44   *
45   * @since 2.0.0
46   */
47  @Tag(name = "suggest")
48  @UIComponentTag(
49      uiComponent = "org.apache.myfaces.tobago.component.UISuggest",
50      uiComponentBaseClass = "org.apache.myfaces.tobago.internal.component.AbstractUISuggest",
51      uiComponentFacesClass = "javax.faces.component.UIComponentBase",
52      componentFamily = UIInput.COMPONENT_FAMILY,
53      rendererType = RendererTypes.SUGGEST,
54      allowedChildComponenents = {
55          "org.apache.myfaces.tobago.SelectItems",
56          "org.apache.myfaces.tobago.SelectItem"
57      })
58  public interface SuggestTagDeclaration extends HasIdBindingAndRendered {
59  
60    /**
61     * MethodBinding which generates a list of suggested input values based on
62     * the currently entered text, which could be retrieved via getSubmittedValue() on the UIIn.
63     * The expression has to evaluate to a public method which has a javax.faces.component.UIInput parameter
64     * and returns a List&lt;String&gt;, a List&lt;org.apache.myfaces.tobago.model.AutoSuggestItem&gt;
65     * or a org.apache.myfaces.tobago.model.AutoSuggestItems.
66     *
67     * @deprecated Please use an <code>&lt;tc:selectItems&gt;</code> tag or a list of <code>&lt;tc:selectItem&gt;</code>
68     * tags (TODO: not implemented yet).
69     */
70    @Deprecated
71    @TagAttribute
72    @UIComponentTagAttribute(type = {},
73        expression = DynamicExpression.METHOD_EXPRESSION_REQUIRED,
74        methodSignature = "javax.faces.component.UIInput",
75        methodReturnType = "java.lang.Object")
76    void setSuggestMethod(String suggestMethod);
77  
78    /**
79     * Minimum number of characters to type before the list will be requested.
80     * If the value is 0, there will be send an initial list to the client.
81     * So, if you set <pre>update="false"</pre> this value should be 0.
82     */
83    @TagAttribute
84    @UIComponentTagAttribute(type = "java.lang.Integer", defaultValue = "1")
85    void setMinimumCharacters(String minimumCharacters);
86  
87    /**
88     * Time in milli seconds before the list will be requested (by AJAX).
89     */
90    @TagAttribute
91    @UIComponentTagAttribute(type = "java.lang.Integer", defaultValue = "200")
92    void setDelay(String delay);
93  
94    /**
95     * The maximum number of item to display in the drop down list.
96     */
97    @TagAttribute
98    @UIComponentTagAttribute(type = "java.lang.Integer", defaultValue = "10")
99    void setMaximumItems(String maximumItems);
100 
101   /**
102    * The real size of the result list.
103    * Typically the result list will be cropped (in the backend) to save memory.
104    * This value can be set, to show the user there are more results for the given string.
105    * If the value is -1, no hint will be displayed.
106    */
107   @TagAttribute
108   @UIComponentTagAttribute(type = "java.lang.Integer", defaultValue = "-1")
109   void setTotalCount(String totalCount);
110 
111   /**
112    * TODO: not implemented yet
113    * <p>
114    * Additional client side filtering of the result list.
115    * This is useful when sending the full list initially to the client and
116    * setting <code>update=false</code>.
117    * </p>
118    * <p>
119    * Possible values are:
120    * </p>
121    * <dl>
122    *   <dt>all</dt>
123    *   <dd>no filtering</dd>
124    *   <dt>prefix</dt>
125    *   <dd>checks if the suggested string starts with the typed text</dd>
126    *   <dt>contains</dt>
127    *   <dd>checks if the typed text is inside of the suggested string</dd>
128    * </dl>
129    * <p>
130    * The filter will only applied on the client side and
131    * only if server updated (by AJAX) are turned off (<code>update=false</code>);
132    * </p>
133    */
134   @TagAttribute
135   @UIComponentTagAttribute(
136       type = "org.apache.myfaces.tobago.model.SuggestFilter",
137       defaultValue = "SuggestFilter.ALL",
138       allowedValues = {
139           SuggestFilter.STRING_ALL,
140           SuggestFilter.STRING_PREFIX,
141           SuggestFilter.STRING_CONTAINS})
142   void setFilter(String filter);
143 
144   /**
145    * TODO: not implemented yet
146    * <p>
147    * Should the list be updated while typing (via AJAX). This is the default behaviour.
148    * If you set this value to <code>false</code>, please set the <code>minimumCharacters="0"</code>.
149    * </p>
150    */
151   @TagAttribute
152   @UIComponentTagAttribute(type = "boolean", defaultValue = "true")
153   void setUpdate(String update);
154 
155   /**
156    * The query is the string typed by the user.
157    */
158   @TagAttribute
159   @UIComponentTagAttribute(generate = false, isTransient = true)
160   void setQuery(String query);
161 }