Fixing ignored onbegin attribute of autocomplete

Version 1

    I want to use status for autocomplete component, but in Richfaces 4 this attribute is missing.

    So, i decide to call start()/stop() methods from Javascript API of status component.

    If we read this doc, we must call start() method in "onbegin" attribute of autocomplete component, but this method is ignored!

    To fix "onbegin" ignoring we must edit Autocomplete.js, find next code:

    {code:java}

    ...

    var callAjax = function(event, callback) {

     

            rf.getDomElement(this.id + ID.VALUE).value = this.value;

     

            var _this = this;

            var _event = event;

            var ajaxSuccess = function (event) {

                updateItemsList.call(_this, _this.value, event.componentData && event.componentData[_this.id]);

                if (_this.options.lazyClientMode && _this.value.length != 0) {

                    updateItemsFromCache.call(_this, _this.value);

                }

                if (_this.items.length != 0) {

                    if (callback) {

                        (_this.focused || _this.isMouseDown) && callback.call(_this, _event);

                    } else {

                        _this.isVisible && _this.options.selectFirst && selectItem.call(_this, _event, 0);

                    }

                } else {

                    _this.__hide(_event);

                }

            };

     

            var ajaxError = function (event) {

                _this.__hide(_event);

                clearItems.call(_this);

            };

     

            this.isFirstAjax = false;

            //caution: JSF submits inputs with empty names causing "WARNING: Parameters: Invalid chunk ignored." in Tomcat log

            var params = {};

            params[this.id + ".ajax"] = "1";

            rf.ajax(this.id, event, {parameters: params, error: ajaxError, complete:ajaxSuccess});

        };

    ...

    {code}

     

    and edit as below:

    {code:java}

    ...

    var callAjax = function(event, callback) {

     

            rf.getDomElement(this.id + ID.VALUE).value = this.value;

     

            var _this = this;

            var _event = event;

            var ajaxSuccess = function (event) {

                updateItemsList.call(_this, _this.value, event.componentData && event.componentData[_this.id]);

                if (_this.options.lazyClientMode && _this.value.length != 0) {

                    updateItemsFromCache.call(_this, _this.value);

                }

                if (_this.items.length != 0) {

                    if (callback) {

                        (_this.focused || _this.isMouseDown) && callback.call(_this, _event);

                    } else {

                        _this.isVisible && _this.options.selectFirst && selectItem.call(_this, _event, 0);

                    }

                } else {

                    _this.__hide(_event);

                }

            };

     

            var ajaxError = function (event) {

                _this.__hide(_event);

                clearItems.call(_this);

            };

     

            this.isFirstAjax = false;

            //caution: JSF submits inputs with empty names causing "WARNING: Parameters: Invalid chunk ignored." in Tomcat log

            var params = {};

            params[this.id + ".ajax"] = "1";

            var parameters_extended = {parameters: params, error: ajaxError, complete:ajaxSuccess};

            if (this.options.onbegin != undefined) {

                parameters_extended.begin = this.options.onbegin;

            }

            rf.ajax(this.id, event, parameters_extended);

        };

    ...

    {code}

    and redeploy your application.