| Package | org.restfulx.components.rx |
| Class | public class RxAutoComplete |
| Inheritance | RxAutoComplete mx.controls.ComboBox |
The idea is this:
You type some stuff into a text-field. Whatever you type up to a given
number of milliseconds (say 500) will be used to create a search query
to the appropriate server-side controller. That controller would typically
return a super thin version of the objects (let's say just the id and
the parameter such as name you were searching on). Once that is
received the component switches to filtering and does the rest of the
search in-memory. When you try a different search same thing happens,
we try to hit the server with the initial search criteria and then
switch to in-memory filtering. When you hit enter the component will
call show method on the object which will hit server-side
controller show action and give you an opportunity to return
a full version of the object and any of it's children using
to_fxml(:include) or something along those lines. If the
object has already been shown then the version from the cache is
returned directly.
<components:RxAutoComplete id="autoComplete"
resource="{Project}" filterFunction="filterProjectsByName"
"/>
private function filterProjectsByName(item:Project):Boolean {
var regexp:RegExp = new RegExp(autoComplete.typedText, "i");
return item.name.search(regexp) != -1;
}
| Property | Defined by | ||
|---|---|---|---|
| alwaysShow : Boolean = false Always invoke show on the model independency of the currently shown status
| RxAutoComplete | ||
| chosenItem : Object
Gets currently chosen item
| RxAutoComplete | ||
| clearTextAfterFind : Boolean Indicates if the search area should be cleared after a specific item has been found/shown
| RxAutoComplete | ||
| customSearchFunction : Function
By default RxAutoComplete will use Rx.models.reload function with metadata in append mode,
which will use the current service provider.
| RxAutoComplete | ||
| enterKeyInvokesSearch : Boolean = true If enter key is hit, invoke search
| RxAutoComplete | ||
| filterCategory : String If provided this indicates which property should be used for filtering/search
| RxAutoComplete | ||
| filterFunction : Function
Client-side filter function.
| RxAutoComplete | ||
| lookupDelay : int = 1500 Indicates how long we should wait for before firing server request
| RxAutoComplete | ||
| lookupMinChars : int = 1 Minimum number of characters that must be provided before server request will be made
| RxAutoComplete | ||
| noResultText : String = "No Results" Text to show if no results are found
| RxAutoComplete | ||
| onServerErrorFunction : Function
Invoked when server responds with an error
| RxAutoComplete | ||
| resource : Object
Get Rx model class this auto complete component is bound to
| RxAutoComplete | ||
| showOnEnter : Boolean = true Indicates if a Rx.models.show operation should be performed on enter
| RxAutoComplete | ||
| typedText : String
Contains currently typed text
| RxAutoComplete | ||
| useManualSearch : Boolean = false If set to true, do not automatically submot queries to the server
| RxAutoComplete | ||
| Method | Defined by | ||
|---|---|---|---|
| RxAutoComplete | |||
|
clearTypedText():void
Clear typed text without triggering dropdown show
| RxAutoComplete | ||
|
close(event:Event = null):void
| RxAutoComplete | ||
|
getStyle(styleProp:String):*
| RxAutoComplete | ||
|
invokeSearch(event:TimerEvent = null):void
Calling this function will force the control to hit the server with the search
| RxAutoComplete | ||
| Method | Defined by | ||
|---|---|---|---|
|
commitProperties():void
| RxAutoComplete | ||
|
keyDownHandler(event:KeyboardEvent):void
| RxAutoComplete | ||
|
textInput_changeHandler(event:Event):void
| RxAutoComplete | ||
|
updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
| RxAutoComplete | ||
| Event | Summary | Defined by | ||
|---|---|---|---|---|
| RxAutoComplete | ||||
| RxAutoComplete | ||||
| RxAutoComplete | ||||
| RxAutoComplete | ||||
| RxAutoComplete | ||||
| alwaysShow | property |
public var alwaysShow:Boolean = falseAlways invoke show on the model independency of the currently shown status
| chosenItem | property |
chosenItem:Object [read-write]Gets currently chosen item
This property can be used as the source for data binding.
Implementation public function get chosenItem():Object
public function set chosenItem(value:Object):void
| clearTextAfterFind | property |
public var clearTextAfterFind:BooleanIndicates if the search area should be cleared after a specific item has been found/shown
| customSearchFunction | property |
public var customSearchFunction:FunctionBy default RxAutoComplete will use Rx.models.reload function with metadata in append mode, which will use the current service provider. If you are unhappy with any part of standard Rx index/reload processing, you can provide your own custom function here to do all the processing
private function customSearchFunction(clazz:Class = null, serviceResponder:ServiceResponder = null,
metadata:Object = null, nestedBy:Array = null):void {
if (online) {
trace("online search, pass through to the service provider");
Rx.services.getServiceProvider(XMLHTTPServiceProvider.ID).index(
clazz, serviceResponder, metadata, nestedBy);
} else {
trace("do custom offline search too");
XRx.air(function(results:Object):void {
serviceResponder.result(new ResultEvent(ResultEvent.RESULT, false, false, results));
}).findAll(clazz, ["name like :name", {':name': "%foo%"}]);
}
}
| enterKeyInvokesSearch | property |
public var enterKeyInvokesSearch:Boolean = trueIf enter key is hit, invoke search
| filterCategory | property |
public var filterCategory:StringIf provided this indicates which property should be used for filtering/search
| filterFunction | property |
public var filterFunction:FunctionClient-side filter function. This should be complemented by the appropriate server-side search action/method.
| lookupDelay | property |
public var lookupDelay:int = 1500Indicates how long we should wait for before firing server request
| lookupMinChars | property |
public var lookupMinChars:int = 1Minimum number of characters that must be provided before server request will be made
| noResultText | property |
public var noResultText:String = "No Results"Text to show if no results are found
| onServerErrorFunction | property |
public var onServerErrorFunction:FunctionInvoked when server responds with an error
| resource | property |
resource:Object [read-write]Get Rx model class this auto complete component is bound to
This property can be used as the source for data binding.
Implementation public function get resource():Object
public function set resource(value:Object):void
| showOnEnter | property |
public var showOnEnter:Boolean = trueIndicates if a Rx.models.show operation should be performed on enter
| typedText | property |
typedText:String [read-write]Contains currently typed text
This property can be used as the source for data binding.
Implementation public function get typedText():String
public function set typedText(value:String):void
| useManualSearch | property |
public var useManualSearch:Boolean = falseIf set to true, do not automatically submot queries to the server
| RxAutoComplete | () | constructor |
public function RxAutoComplete()
| clearTypedText | () | method |
public function clearTypedText():voidClear typed text without triggering dropdown show
| close | () | method |
public override function close(event:Event = null):voidParameters
event:Event (default = null) |
| commitProperties | () | method |
protected override function commitProperties():void
| getStyle | () | method |
public override function getStyle(styleProp:String):*Parameters
styleProp:String |
* |
| invokeSearch | () | method |
public function invokeSearch(event:TimerEvent = null):voidCalling this function will force the control to hit the server with the search
Parametersevent:TimerEvent (default = null) |
| keyDownHandler | () | method |
protected override function keyDownHandler(event:KeyboardEvent):voidParameters
event:KeyboardEvent |
| textInput_changeHandler | () | method |
protected override function textInput_changeHandler(event:Event):voidParameters
event:Event |
| updateDisplayList | () | method |
protected override function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):voidParameters
unscaledWidth:Number |
|
unscaledHeight:Number |
| chosenItemChange | event |
| itemHighlighted | event |
| selectedItemChange | event |
| typedTextChange | event |
| unknownSelectedItem | event |