OverviewSince 3.1 ace:autoCompleteEntry is a text input component that displays a list of suggested possible values, for the current input, as the user types. It provides different built-in filtering modes to generate a list of suggestions, and it also supports custom filtering modes for more specific and/or complex filtering requirements. It works by binding a list of standard SelectItem objects to the component, and it is also possible to bind a list of arbitrary data objects. The component also supports various options to control its behaviour in detail.
Getting StartedIn its simplest form, ace:autoCompleteEntry is set up by nesting a list of SelectItem's inside the component's tag, as in the following code snippet. <ace:autoCompleteEntry id="autoComplete" value="#{autoCompleteEntryBean.selectedText}"> <f:selectItems value="#{autoCompleteEntryBean.items}"/> </ace:autoCompleteEntry> The 'label' property of the SelectItem objects will be used to match the possible results with the input that the user has typed so far. In the case above, the default matching mode will be applied, which is 'startsWith'. A more complex example is shown below and involves using arbitrary data objects (POJOs) and the ability to nest arbitrary components in each row. In this case, it is necessary to specify the list of data objects in the listValue attribute of the component. It is also necessary to give a name for the variable that will be used to represent each object in the markup in the listVar attribute, and one must also tell the component according to which property the filtering should be done in the filterBy attribute. Then, a facet named 'row' is used to nest any arbitrary components and markup, using the variable to reference different properties of the data object. <ace:autoCompleteEntry id="autoCompleteFacet" value="#{autoCompleteEntryFacetBean.selectedText}" listVar="city" listValue="#{autoCompleteEntryFacetBean.cities}" filterBy="#{city.name}"> <f:facet name="row"> <h:panelGrid columns="3"> <h:graphicImage library="css/images" name="house.png"/> <h:outputText value="#{city.name}" /> <h:outputText value="#{city.country}" /> </h:panelGrid> </f:facet> </ace:autoCompleteEntry>
Attributes
The filterMatchMode attribute specifies how the different options will be evaluated to match the current input. The possible values are "contains", "exact", "startsWith", "endsWith" and "none". The default value is "startsWith". If "none" is used, the component will take the list of items as it is and display the first number of rows specified by the rows attribute. This is useful in situations where the application needs to dynamically generate the list of items after some more custom or complex filtering. The listValue attribute is used to bind a list of items that the component will use to present as options when rendering via a facet. They can be either SelectItems or POJOs. The listVar attribute is used to refer to an individual item when rendering via a facet. The filterBy attribute is a ValueExpresssion that specifies the property of the item (using listVar) according to which the filtering should be done, when rendering via a facet. The caseSensitive attribute specifies whether the filtering done by the component should be case sensitive or not. The direction attribute forces the list of options to appear either "up" or "down". The default is "auto", where the component finds if there's enough space to display the list below the text field, otherwise it tries to display it above it. Client Behavior Events
JavaScript APIsICEfaces 3.xThe client side component object is exposed through the global variable name specified in the widgetVar attribute. ICEfaces 4+The "widgetVar" attribute on the ACE components has been removed in ICEfaces 4 and in its place a new "ice.ace.instance()" client JavaScript object lookup API has been introduced. The reason for this change is to enable lazy-initialization of the ACE component JavaScript objects to improve runtime performance and reduce browser memory use. var widget = ice.ace.instance('frm:componentId);
Keyboard and ARIA SupportThe following ARIA roles are supported: textbox. Facet RenderingIt is possible to customize the way in which the option items are displayed by means of the 'row' facet. You can add any arbitrary content, as in the following example. <ace:autoCompleteEntry id="autoCompleteFacet" value="#{autoCompleteEntryFacetBean.selectedText}" rows="10" width="300" filterMatchMode="startsWith" listVar="city" listValue="#{autoCompleteEntryFacetBean.cities}" filterBy="#{city.name}" label="Cities of the World:" labelPosition="left"> <f:facet name="row"> <h:panelGrid columns="3" width="100%" columnClasses="col10,col50,col25"> <h:graphicImage value="resources/css/images/house.png" alt="House"/> <h:outputText value="#{city.name}" /> <h:outputText value="#{city.country}" /> </h:panelGrid> </f:facet> </ace:autoCompleteEntry> LabelsThis component supports built-in labels. The text specified in the label attribute will be rendered next to the main input field of this component. The position specified by labelPosition will determine where this label is going to be rendered; the possible values are left, right, top, bottom, none and inField (to render the label in the field itself). Required IndicatorThe requiredIndicator attribute specifies the text to be displayed next to the main input field when this component is marked as required. When, this component is not marked as required, then the text specified in the optionalIndicator is going to be rendered. The indicatorPosition attribute determines where this indicator text is going to the rendered; the possible values are left, right, top, bottom, labelLeft, labelRight, and none. Required StylingThen this component is marked as required, the main input field receives the CSS class ui-state-required, otherwise, it receives the CSS class ui-state-optional. When this component is marked as invalid by the app, it will be rendered with the CSS class ui-state-error. These CSS classes can be used to add custom styling to this component, in order indicate its current state in a more visual way. CSS ClassesThe following markup represents the basic HTML structure of the component and the CSS classes it uses. <!-- Root container --> <div class="[user defined classes]"> <span> <!-- Text field --> <input class="ui-inputfield ui-widget ui-state-default ui-corner-all ui-state-optional" style="[user defined styles]" /> <!-- List of options --> <span> <div class="ui-widget ui-widget-content ui-corner-all"> <div> <!-- Individual option --> <div class="ui-widget-content">Option</div> </div> </div> </span> </span> </div> Additionally, the informal class name can be added when using the component in facet mode to components and elements that are rendered for display purposes but that are not part of the value that is submitted to the server. Known IssuesNone. Other NotesThe autocomplete functionality can be done entirely in the client side if the clientSide attribute is set to true. Client-side mode can be faster, as no round trips to the server need to be made. However, if the list of possible results is too large, the browser might become slower, since the entire list has to be stored in the client as HTML nodes. It is recommended not to use lists of more than 1000 items when using the client-side mode. |
AutoCompleteEntry
© Copyright 2021 ICEsoft Technologies Canada Corp.