From issues at jboss.org Thu Jan 2 23:47:33 2014 Content-Type: multipart/mixed; boundary="===============2791955663658184354==" MIME-Version: 1.0 From: Brian Leathem (JIRA) To: richfaces-issues at lists.jboss.org Subject: [richfaces-issues] [JBoss JIRA] (RF-13305) Autocomplete: i must press button twice for popup window Date: Thu, 02 Jan 2014 23:47:33 -0500 Message-ID: In-Reply-To: JIRA.12509249.1383274376000@jira02.app.mwc.hst.phx2.redhat.com --===============2791955663658184354== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable [ https://issues.jboss.org/browse/RF-13305?page=3Dcom.atlassian.jira.p= lugin.system.issuetabpanels:all-tabpanel ] Brian Leathem updated RF-13305: ------------------------------- Sprint: 4.3.5.Sprint 2 = > Autocomplete: i must press button twice for popup window > -------------------------------------------------------- > > Key: RF-13305 > URL: https://issues.jboss.org/browse/RF-13305 > Project: RichFaces > Issue Type: Feature Request > Security Level: Public(Everyone can see) = > Affects Versions: 4.3.4 > Reporter: alexey plotnikov > Assignee: Luk=C3=A1=C5=A1 Fry=C4=8D > Fix For: 4.3.5 > > > All described here https://community.jboss.org/thread/233971 > I try repeat: > I have this autocomplete component: > {code} > = > = > = > = > = >
= > minChars=3D"0" var=3D"s" fetchValue=3D"#{s.re= alName}" id=3D"provider-suggestion" = > autofill=3D"false" = > onselectitem=3D"autocompleteChangeProvider(ev= ent.target)" style=3D"display: inline;" = > layout=3D"table" value=3D"#{autocomplete.prov= iderName}" > = > = > = > = > = > = > = > = > = > = > = > alt=3D""/> = > onclick=3D"#{rich:component('provider-suggestion= ')}.hidePopup();#{rich:component('provider-suggestion')}.setValue('');autoc= ompleteChangeProvider(null);" = > alt=3D"#{messages['pages.clear']}" title=3D"#{me= ssages['pages.clear']}"/> = > = >
= > {code} > as you can see, i don't use showButton=3D"true", because i need another f= unctionality, i need erase input text before show popup window. > I use JavaScript function "autocompleteChangeProvider" for extract select= ed id. > I use separate button(/img/cancel.png) for erase input text, as you can s= ee this function just use Richfaces API. > = > And problem: > if autocomplete.providerName not null and not empty(in rich:autocomplete)= and user clicks on cancel button(img/cancel.png), then after that, if user= clicks on show button(/img/arrow.png) popup not showing, user must clicks = twice on this button. > *This problem shows if i use showButton from rich:autocomplete instead my= show button.* > I think i found a solution of this problem: > Autocomplete.js has this code: > {code} > var onChangeValue =3D function (event, value, callback) { = > selectItem.call(this, event); = > = > // value is undefined if called from AutocompleteBase onChange = > var subValue =3D (typeof value =3D=3D "undefined") ? this.__getSu= bValue() : value; = > var oldValue =3D this.value; = > this.value =3D subValue; = > = > if ((this.options.isCachedAjax || !this.options.ajaxMode) && = > this.cache && this.cache.isCached(subValue)) { = > ... = > } else { = > if (event.keyCode =3D=3D rf.KEYS.RETURN || event.type =3D=3D = "click") { = > this.__setInputValue(subValue); = > } = > if (subValue.length >=3D this.options.minChars) { = > if ((this.options.ajaxMode || this.options.lazyClientMode= ) && oldValue !=3D subValue) { = > callAjax.call(this, event, callback); = > } = > } else { = > if (this.options.ajaxMode) { = > clearItems.call(this); = > this.__hide(event); = > } = > } = > } = > }; = > {code} > for show popup this must be true: = > {code} > oldValue !=3D subValue > {code} > but in this part of code = > oldValue is ''(empty string) and subValue is ''(empty string), > so this condition = > {code} > oldValue !=3D subValue > {code} > return false! > = > i replace this code by this: > {code} > var onChangeValue =3D function (event, value, callback) { = > selectItem.call(this, event); = > = > // value is undefined if called from AutocompleteBase onChange = > var subValue =3D (typeof value =3D=3D "undefined") ? this.__getSu= bValue() : value; = > var oldValue =3D this.value; = > this.value =3D subValue; = > = > if ((this.options.isCachedAjax || !this.options.ajaxMode) && = > this.cache && this.cache.isCached(subValue)) { = > ... = > } else { = > if (event.keyCode =3D=3D rf.KEYS.RETURN || event.type =3D=3D = "click") { = > this.__setInputValue(subValue); = > } = > if (subValue.length >=3D this.options.minChars) { = > if ((this.options.ajaxMode || this.options.lazyClientMode= ) && (oldValue !=3D subValue || (oldValue =3D=3D=3D '' && subValue =3D=3D= =3D ''))) { = > callAjax.call(this, event, callback); = > } = > } else { = > if (this.options.ajaxMode) { = > clearItems.call(this); = > this.__hide(event); = > } = > } = > } = > = > }; = > {code} > so, than oldValue=3D'' and subValue=3D=3D'' callAjax.call will be called = and popup will be showing. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrato= rs For more information on JIRA, see: http://www.atlassian.com/software/jira --===============2791955663658184354==--