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.HasCurrentMarkup;
29  import org.apache.myfaces.tobago.internal.taglib.declaration.HasIdBindingAndRendered;
30  import org.apache.myfaces.tobago.internal.taglib.declaration.HasMarkup;
31  import org.apache.myfaces.tobago.model.SuggestFilter;
32  
33  import javax.faces.component.UIInput;
34  
35  /**
36   * Renders a list of suggested texts for a given input field.
37   *
38   * Basic features:
39   * <ul>
40   *   <li>provide a list directly while rendering (not AJAX needed) [todo]</li>
41   *   <li>update by typing (AJAX)</li>
42   *   <li>minimum number of typed characters (to avoid useless requests)</li>
43   *   <li>update delay (useful for optimization)</li>
44   *   <li>filter on client side (useful for optimization) [todo]</li>
45   * </ul>
46   *
47   * @since 2.0.0
48   */
49  @Tag(name = "suggest")
50  @UIComponentTag(
51      uiComponent = "org.apache.myfaces.tobago.component.UISuggest",
52      uiComponentBaseClass = "org.apache.myfaces.tobago.internal.component.AbstractUISuggest",
53      uiComponentFacesClass = "javax.faces.component.UIComponentBase",
54      componentFamily = UIInput.COMPONENT_FAMILY,
55      rendererType = RendererTypes.SUGGEST,
56      isTransparentForLayout = true,
57      allowedChildComponenents = "NONE")
58  public interface SuggestTagDeclaration extends HasIdBindingAndRendered, HasMarkup, HasCurrentMarkup {
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>, a List&lt;org.apache.myfaces.tobago.model.AutoSuggestItem>
65     * or a org.apache.myfaces.tobago.model.AutoSuggestItems.
66     *
67     * @deprecated Please use an <code>&lt;tc:selectItems></code> tag or a list of <code>&lt;tc:selectItem></code> tags
68     * (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 = "300")
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    * Possible values are:
119    * <dl>
120    *   <dt>all</dt>
121    *   <dd>no filtering</dd>
122    *   <dt>prefix</dt>
123    *   <dd>checks if the suggested string starts with the typed text</dd>
124    *   <dt>contains</dt>
125    *   <dd>checks if the typed text is inside of the suggested string</dd>
126    * </dl>
127    * <p/>
128    * The filter will only applied on the client side and
129    * only if server updated (by AJAX) are turned off (<code>update=false</code>);
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"</pre>.
146    */
147   @TagAttribute
148   @UIComponentTagAttribute(type = "boolean", defaultValue = "true")
149   void setUpdate(String update);
150 
151 }