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 = "NONE")
55  public interface SuggestTagDeclaration extends HasIdBindingAndRendered {
56  
57    /**
58     * MethodBinding which generates a list of suggested input values based on
59     * the currently entered text, which could be retrieved via getSubmittedValue() on the UIIn.
60     * The expression has to evaluate to a public method which has a javax.faces.component.UIInput parameter
61     * and returns a List&lt;String&gt;, a List&lt;org.apache.myfaces.tobago.model.AutoSuggestItem&gt;
62     * or a org.apache.myfaces.tobago.model.AutoSuggestItems.
63     *
64     * @deprecated Please use an <code>&lt;tc:selectItems&gt;</code> tag or a list of <code>&lt;tc:selectItem&gt;</code>
65     * tags (TODO: not implemented yet).
66     */
67    @Deprecated
68    @TagAttribute
69    @UIComponentTagAttribute(type = {},
70        expression = DynamicExpression.METHOD_EXPRESSION_REQUIRED,
71        methodSignature = "javax.faces.component.UIInput",
72        methodReturnType = "java.lang.Object")
73    void setSuggestMethod(String suggestMethod);
74  
75    /**
76     * Minimum number of characters to type before the list will be requested.
77     * If the value is 0, there will be send an initial list to the client.
78     * So, if you set <pre>update="false"</pre> this value should be 0.
79     */
80    @TagAttribute
81    @UIComponentTagAttribute(type = "java.lang.Integer", defaultValue = "1")
82    void setMinimumCharacters(String minimumCharacters);
83  
84    /**
85     * Time in milli seconds before the list will be requested (by AJAX).
86     */
87    @TagAttribute
88    @UIComponentTagAttribute(type = "java.lang.Integer", defaultValue = "300")
89    void setDelay(String delay);
90  
91    /**
92     * The maximum number of item to display in the drop down list.
93     */
94    @TagAttribute
95    @UIComponentTagAttribute(type = "java.lang.Integer", defaultValue = "10")
96    void setMaximumItems(String maximumItems);
97  
98    /**
99     * The real size of the result list.
100    * Typically the result list will be cropped (in the backend) to save memory.
101    * This value can be set, to show the user there are more results for the given string.
102    * If the value is -1, no hint will be displayed.
103    */
104   @TagAttribute
105   @UIComponentTagAttribute(type = "java.lang.Integer", defaultValue = "-1")
106   void setTotalCount(String totalCount);
107 
108   /**
109    * TODO: not implemented yet
110    * <p>
111    * Additional client side filtering of the result list.
112    * This is useful when sending the full list initially to the client and
113    * setting <code>update=false</code>.
114    * </p>
115    * <p>
116    * Possible values are:
117    * </p>
118    * <dl>
119    *   <dt>all</dt>
120    *   <dd>no filtering</dd>
121    *   <dt>prefix</dt>
122    *   <dd>checks if the suggested string starts with the typed text</dd>
123    *   <dt>contains</dt>
124    *   <dd>checks if the typed text is inside of the suggested string</dd>
125    * </dl>
126    * <p>
127    * The filter will only applied on the client side and
128    * only if server updated (by AJAX) are turned off (<code>update=false</code>);
129    * </p>
130    */
131   @TagAttribute
132   @UIComponentTagAttribute(
133       type = "org.apache.myfaces.tobago.model.SuggestFilter",
134       defaultValue = "SuggestFilter.ALL",
135       allowedValues = {
136           SuggestFilter.STRING_ALL,
137           SuggestFilter.STRING_PREFIX,
138           SuggestFilter.STRING_CONTAINS})
139   void setFilter(String filter);
140 
141   /**
142    * TODO: not implemented yet
143    * <p>
144    * Should the list be updated while typing (via AJAX). This is the default behaviour.
145    * If you set this value to <code>false</code>, please set the <code>minimumCharacters="0"</code>.
146    * </p>
147    */
148   @TagAttribute
149   @UIComponentTagAttribute(type = "boolean", defaultValue = "true")
150   void setUpdate(String update);
151 
152 }