How to Use the Auto-Complete Component
The autoComplete
component allows users to do real time auto-completion using AJAX
interactions. The component uses managed beans to configure the
advanced
properties as well as the retrieve the resultant completion data.
The
tag library for
the autoComplete component can be accessed using the
declaration:
<%@taglib prefix="ui" uri="http://java.sun.com/blueprints/ui/14"%>
An example of the JSF autoComplete component's use is as follows:
<ui:autoComplete size="40"
maxlength="100" id="cityField"
completionMethod="#{ApplicationBean.completeCity}"
value="#{SessionBean.city}" required="true" ondisplay="function(item) {
return extractCity(item); }"
onchoose="function(item) { return chooseCity(item); }"/>
JSP
Tag Attributes
The Rating component supports
the following attributes.
- id - The component identifier for this component. This
value must be unique within the closest parent component that is a
naming container.
- accesskey - Access key that, when pressed, transfers focus to
this element.
- completionMethod - Method binding expression which points to a
method taking a FacesContext and a prefix String, and returning a
String[] which will be displayed as completion results for the given
prefix.
- onchoose - JavaScript code which is given a String item that has
been chosen by the user and should be set in the given text
field. This is optional; if not set the text will be set in the
auto-complete text field, but this can be used to do something more
advanced, like split the string up into subparts and set these subparts
on different text fields (for example).
- text - The text to be initially displayed in this input field.
- title - Advisory title information about markup elements generated
for this component.
- value - The current value of this component.
- valueChangeListener - MethodBinding representing a value change
listener method that will be notified when a new value has been set for
this input component. The expression must evaluate to a public
method that takes a ValueChangeEvent parameter, with a return type of
void.
- converter - Converter instance registered with this component.
- dir - Direction indication for text that does not inherit
directionality. Valid values are "LTR" (left-to-right) and "RTL"
(right-to-left).
- disabled - Flag indicating that this element must never receive
focus or be included in a subsequent submit.
- alt - Alternate textual description of the element rendered
by this component.
- immediate - Flag indicating that, if this component is activated
by the user, notifications should be delivered to interested listeners
and actions immediately (that is, during Apply Request Values phase)
rather than waiting until Invoke Application phase.
- lang - Code describing the language used in the generated markup
for this component.
- maxlength - Javascript code executed when this element loses
focus.
- onblur - Javascript code executed when this element loses focus.
- onchange - Javascript code executed when this element loses focus
and its value has been modified since gaining focus.
- onclick - Javascript code executed when a pointer button is
clicked over this element.
- ondblclick - Javascript code executed when a pointer button
is double clicked over this element.
- ondisplay - JavaScript code which is given a String item that has
been returned from the server, and it is given a chance to massage this
string before it is placed into the completion display for the user.
- onfocus - Javascript code executed when this element receives
focus.
- onkeydown - Javascript code executed when a key is pressed down
over this element.
- onkeypress - Javascript code executed when a key is released over
this element.
- onmousedown - Javascript code executed when a pressed down over
this element.
- onmousemove - Javascript code executed when a pointer button is
moved away from this element.
- onmouseover - Javascript code executed when a pointer button is
moved onto this element.
- onmouseup - Javascript code executed when a pointer button is
released over this element.
- onselect - Javascript code executed when text within this element
is selected by the user.
- readonly - Flag indicating that this component will prohibit
changes by the user. The element may receive focus unless it has
also been disabled.
- rendered - Flag indicating whether or not this component should
be rendered (during Render Response Phase), or processed on any
subsequent form submit.
- required - Flag indicating that the user is required to provide a
submitted value for this input component.
- size - The number of characters used to determine the width of
this field.
- style - CSS style(s) to be applied when this component is
rendered.
- styleClass - Space-separated list of CSS style class(es) to be
applied when this element is rendered. This value must be passed
through as the "class" attribute on generated markup.
- binding - Binding to the component in a page bean.
© Sun Microsystems 2006. All of the material in The
Java BluePrints Solutions Catalog is copyright-protected
and may not be published in other works without express
written permission from Sun Microsystems.