8 Replies Latest reply on Apr 20, 2011 9:17 AM by edilmar

    RichFaces4 autocomplete incorrect display

    edilmar

      Hi,

       

      I have an autocomplete component where the user types part of a name and I filter all records from database with this name.

      No problem with the idea, the database table is filtered and many strings "name-code" are returned to navigator.

      However, there are two problems with "autocomplete":

      1) the user types, for example, "ant" and the strings "antenor marin-788"/"antonio pedro-543"/etc should be displayed in the list. However, "autocomplete" displays many lines only with ">". But if I select any line, the right string is displayed fine in the input box.

      2) I don't know if this occurs because of many "autocomplete" components, one after other, but the list of strings is displayed after other "autocomplete", not exactly after your component.

      Below is the image with the two bugs, ">" strings and the list from "Prop. Certificado autocomplete" below "Motorista autocomplete":

      autocompleteWrongDisplay.jpeg

      The browsers used are Firefox4 and Chrome10.

        • 1. RichFaces4 autocomplete incorrect display
          ilya_shaikovsky

          Your list containst not a Strings but some custom objects? In that case toString used to get string representation.

          show the code please.

          • 2. RichFaces4 autocomplete incorrect display
            edilmar

            My list is a List<String>, like this:

             

             

              public List<String> lookupName(String className, String fieldCode, String fieldName, String lookupName) {

                Query q = getEntityManager().createQuery(

                    "SELECT CONCAT(CONCAT(" + fieldName + ",'-')" + "," + fieldCode + ") " +

                    "FROM " + className + " " +

                    "WHERE UPPER(" + fieldName + ") like '" + lookupName.toUpperCase() + "%' " +

                    "ORDER BY 1");

                q.setMaxResults(200);

                List<String> ret = q.getResultList();

                return ret;

              }

             

            Sometimes the autocomplete component displays right, sometimes wrong, it has a unstable behaviour.

            • 3. RichFaces4 autocomplete incorrect display
              nbelaevski

              Edilmar,

               

              Can you please post page code?

              • 4. Re: RichFaces4 autocomplete incorrect display
                edilmar

                Hi,

                 

                Here is the code for autocomplete:

                <a4j:region id="a4j_Proprietario_cidade">

                  <rich:autocomplete id="Proprietario_cidade"

                    value="#{proprietario.entity.cidade}"

                    mode="cachedAjax" minChars="1" status="statusProprietario_cidade"

                    showButton="true" autocompleteMethod="#{proprietario.cidadeLookup}"

                    readonly="false" required="true" requiredMessage="Campo Cidade obrigatório na tabela .">

                    <f:converter converterId="cidadeConverter"/>

                  </rich:autocomplete>

                  <a4j:status id="statusProprietario_cidade" forceId="true">

                    <f:facet name="start">

                      <h:graphicImage value="/imagens/processar.gif"/>

                    </f:facet>

                  </a4j:status>

                </a4j:region>

                 

                The method cidadeLookup calls the generic method lookupName that I wrote before, like this in my controller bean:

                 

                  public List<String> cidadeLookup(String event) {

                      return dao.lookupName("Cidade", "codCidade", "nome", event.toString());

                  }

                This code was the same that I used before with suggestionBox, and it never had problem with it. I just changed the component.

                • 5. Re: RichFaces4 autocomplete incorrect display
                  ilya_shaikovsky

                  code looks fine.

                   

                  need to check precise place where you could reproduce:

                  Sometimes the autocomplete component displays right, sometimes wrong, it has a unstable behaviour.

                  and check in debug which data returned in that cases.

                  • 6. Re: RichFaces4 autocomplete incorrect display
                    edilmar

                    1) solved

                    2) when there are many autocomplete components, one below other, the list of selected items is displayed crazy, like I took about above. Below is other sample image for this, where the user typed in the field "Destinatário", but the list of items was displayed below field "Destino".autocompleteWrongItems.jpeg

                    • 7. Re: RichFaces4 autocomplete incorrect display
                      ilya_shaikovsky

                      could you please check if there are any styles which could affect positioning applied to components or the containers which wraps them?

                       

                      would be great if you able to provide simplified complete page to reproduce that.

                       

                      rf-showcase also contains few autocomplete components on the same page but has no such problem.

                       

                      B.t.w. it works the same in all browsers for you?

                      • 8. Re: RichFaces4 autocomplete incorrect display
                        edilmar

                        I don't have any custom style, only default styles from RichFaces4 components.

                         

                        The behaviour is the same in Firefox4 and Chrome10.

                         

                        The strange is that sometimes if I type slowly, all works fine. But if I type very fast, positioning becomes crazy. I think navigators are not so fast to process the AJAX requests/responses.