-
1. Re: New bug in RF 4.5.3 autocomplete
michpetrov Mar 11, 2015 12:44 PM (in response to edilmar)You haven't explained what the bug is. In any case the change to autocomplete in 4.5.3 was RF-10964. "minChars" is the value of how many characters the user has to type in before the search is executed, but suggestions shouldn't be accepted if the number wasn't reached (that was the fix to the issue). You probably need to set minChars to the length of the typed value.
-
2. Re: New bug in RF 4.5.3 autocomplete
edilmar Mar 11, 2015 1:48 PM (in response to michpetrov)In 4.5.3 when I type a code or description and ENTER, the autocomplete do nothing.
I think when you change the RF code to refactory the problem in [RF-10964] autocomplete delete key behavior creates inconsistent state - JBoss Issue Tracker
my kind of control using ENTER to run the search stopped to work.
And after I changed my code like your suggestion:
autocomplete.options.minChars = input.value.length;
my interface became worst, because I use ENTER like a shortcut to filter button for all the components.
Then, when I am into an autocomplete and press ENTER, the code to search autocomplete runs but the code to filter button runs too after.
In versions <= 4.5.2, when I am into an autocomplete and press ENTER, just the code to search autocomplete runs.
-
3. Re: New bug in RF 4.5.3 autocomplete
edilmar Mar 11, 2015 2:22 PM (in response to edilmar)If I change the default minChars to 5 in component, it works fine with normal behaviour that doesn't need to press ENTER.
But this is a big problem because when the user types a CODE, not a DESCRIPTION, I want that CODE=1 works, not CODE=00001, that is a bad interface behaviour.
I implemented this code in 2011, when I submitted this message in this forum: RF4 rich:autoComplete with ENTER to start search
-
4. Re: New bug in RF 4.5.3 autocomplete
michpetrov Mar 12, 2015 5:07 AM (in response to edilmar)If you look at Autocomplete.js there is a "ajaxSuccess" function, all the fix did was changing
updateItemsList.call(_this, _this.value, event.componentData && event.componentData[_this.id]);
to
if (_this.options.minChars <= _this.value.length) { updateItemsList.call(_this, _this.value, event.componentData && event.componentData[_this.id]); }
you need to make sure the check passes. If there are additional methods being executed then I assume there's another error in your code.
-
5. Re: New bug in RF 4.5.3 autocomplete
edilmar Mar 12, 2015 4:08 PM (in response to michpetrov)I think this changing was the cause of my problem because I use minChars=100 to start the search just when the user press ENTER, not when the user press minChars characters. The "if" above is a big problem for me. I am thinking about what to do to solve my problem.
-
6. Re: New bug in RF 4.5.3 autocomplete
edilmar Mar 13, 2015 11:25 AM (in response to edilmar)Hi,
I solved the problem creating an oncomplete call:
<h:outputText styleClass="fontDefLabels" value="Search city:"/><br/>
<rich:autocomplete id="cidade" value="#{t.cidadeAtual}"
mode="cachedAjax" minChars="100" showButton="true" autofill="false"
autocompleteMethod="#{t.cidadeLookup}"
onkeypress="return enterToAutoComplete('formCad:cidade', 3, event);"
oncomplete="return afterEnterToAutoComplete('formCad:cidade');"
>
<f:converter converterId="cidadeConverter"/>
</rich:autocomplete>
and these are my JS functions:
function enterToAutoComplete(objName, minChars, evtKeyPress) {
if (isEnter(evtKeyPress)) {
var input = getComponent(objName);
var autocomplete = input.rf.component;
var codigo = Number(autocomplete.value);
if (!isNaN(codigo))
minChars = 1;
autocomplete.options.minChars = minChars;
autocomplete.isFirstAjax = true;
autocomplete.__updateState(evtKeyPress);
return false;
}
else
return true;
}
function afterEnterToAutoComplete(objName) {
var input = getComponent(objName);
var autocomplete = input.rf.component;
autocomplete.options.minChars = 100;
return true;
}
It would be nice Michal if next versions of rich:autocomplete have a new property something like "hotkey=XXX" and if I'd configure minChars="5" and hotkey="13", both conditions would be used to start the suggestions.