8 Replies Latest reply on Feb 16, 2016 12:52 PM by Sudha Raj

    rich:autocomplete is not working

    Sudha Raj Newbie

      I am working on richfaces migration from 3.3 to 4.2. I am stuck with the replacement of rich:suggestionbox tag with rich:autocomplete tag.

       

      Richfaces 3.3 code, (It is working code)

       

      <rich:suggestionbox for="officerSrch" minChars="2" nothingLabel="No managers found"

                                      suggestionAction="#{batchProcessor.searchOfficers}" fetchValue=""

                                      var="o" eventsQueue="officerQueue"

                                      height="270" width="480">  

                          <a4j:support event="onselect" action="#{accountLookupAction.add(o)}" reRender="params"/>                   

                          <h:column>

                              <f:facet name="header">

                                  <h:outputText value="Employee ID"/>

                              </f:facet>

                              <h:outputText value="#{o.employeeId}"/>

                          </h:column>

                          <h:column>

                              <f:facet name="header">

                                  <h:outputText value="First Name"/>

                              </f:facet>

                              <h:outputText value="#{o.firstName}"/>

                          </h:column>

                          <h:column>

                              <f:facet name="header">

                                  <h:outputText value="Last Name"/>

                              </f:facet>

                              <h:outputText value="#{o.lastName}"/>

                          </h:column>

                      </rich:suggestionbox>

       

      I have tried to migrate the above code in richfaces 4 like this,

       

      <rich:autocomplete mode="cachedAjax" minChars="2" nothingLabel="No managers found"

                                 autocompleteMethod="#{batchProcessor.searchOfficers}" fetchValue=""

                                 var="o" eventsQueue="officerQueue" id="officerSrch"

                                 height="270" width="480">

                     <h:column>

                              <f:facet name="header">

                     <h:outputText value="Employee ID"/>

                       </f:facet>

                  <h:outputText value="#{o.employeeId}"/>

               </h:column>

               <h:column>

                <f:facet name="header">

                     <h:outputText value="First Name"/>

                       </f:facet>

                  <h:outputText value="#{o.firstName}"/>

               </h:column>

               <h:column>

                <f:facet name="header">

                     <h:outputText value="Last Name"/>

                       </f:facet>

                  <h:outputText value="#{o.lastName}"/>

               </h:column>

               </rich:autocomplete>

       

      But it is not working. Can anyone please guide me to convert the above code to richfaces 4?

        • 1. Re: rich:autocomplete is not working
          Michal Petrov Master

          What does "not working" mean? Describe what you're doing, what you expect to happen and what is actually happening. (nothingLabel, eventQueue, width and height are not valid attributes in RichFaces 4)

          • 2. Re: rich:autocomplete is not working
            Sudha Raj Newbie

            Michal, Thank you for the response. Yesterday when I have posted this question, I was not sure how to replace rich:suggestionbox to rich:autocomplete. Today I have found the way to modify that.

             

            <rich:suggestionbox for="officerSrch" minChars="2" nothingLabel="No managers found"

                                            suggestionAction="#{batchProcessor.searchOfficers}" fetchValue=""

                                            var="o" eventsQueue="officerQueue"

                                            height="270" width="480">  

             

            to

             

            <rich:autocomplete id="officerSrch" minChars="2" nothingLabel="No managers found" mode="cachedAjax"

              autocompleteMethod="#{batchProcessor.searchOfficers}" fetchValue="" layout="table"

              var="o" eventsQueue="officerQueue" style="height:20px;background:url('img/magnifying-glass.png') no-repeat center right;vertical-align:middle;"

              height="270" width="480">

             

             

            rich:autocomplete is not supporting <a4j:ajax> I am currently trying to fix that and also the header field is not displaying in the suggestions. The following screenshot taken from richfaces 3.3.

             

             

            The following screenshot taken from richfaces 4

             

            I am trying to figure it out. If you have any suggestions please let me know.

            • 3. Re: rich:autocomplete is not working
              Michal Petrov Master

              Headers are not working yes, we have an issue filed for that (I think) I'll look into it; a4j:ajax should be working though. As for the styling, if you look at the code you'll see @style is applied to the parent span, if you want to change the input you need to use either @styleClass (which puts the class on the parent element), or @inputClass.

              • 4. Re: rich:autocomplete is not working
                Sudha Raj Newbie

                Michal,

                 

                I am working on the ajax functionality. I will take care of the look and feel issue. I have another issue, I couldn,'t use the mouse to go up and down of the values in the autocomplete. I can go through only with up and down arrow in the keyboard. Do you have any idea to fix this issue? I am using richfaces version 4.3.7.Final

                • 5. Re: rich:autocomplete is not working
                  Michal Petrov Master

                  Can you upgrade to 4.5? There's been a number of fixes and enhancements to autocomplete in the current branch.

                  • 6. Re: rich:autocomplete is not working
                    Sudha Raj Newbie

                    Michal,

                     

                    I have started working with richfaces 4.5.10.Final version. Do you know which version of facelet and jsf are compatible with this richfaces version 4.5.10.Final? Currently I am using JSF 2.1.28 and Facelet 1.1.15.B1. Also I am using Seam 2.3.@@

                     

                    Thank you so much for the help. I have tried the following combinations

                     

                    1) Richfaces 4.5.13 with JSF 2.2.6

                    2) Richfaces 4.5.13 with JSF 2.2.7

                    3) Richfaces 4.5.13 with JSF 2.2.10

                    4) Richfaces 4.5.13 with JSF 2.2.12

                     

                    I have received the following error message when I have try to access the application.

                     

                    15:32:18,875 ERROR [org.jboss.seam.exception.Exceptions] (http-/127.0.0.1:8080-5) handled and logged exception: javax.servlet.ServletException: (class: org/richfaces/view/facelets/AutocompleteHandler$1$2, method: applyMetadata signature: (Ljavax/faces/view/facelets/FaceletContext;Ljava/lang/Object;)V) Bad access to protected data

                    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:606) [jboss-jsf-api_2.1_spec-2.1.28.Final-redhat-1.jar:2.1.28.Final-redhat-1]

                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]

                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]

                    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83) [jboss-seam-2.3.0.Final.jar:2.3.0.Final]

                    at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60) [jboss-seam-2.3.0.Final.jar:2.3.0.Final]

                    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) [jboss-seam-2.3.0.Final.jar:2.3.0.Final]

                    at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40) [jboss-seam-2.3.0.Final.jar:2.3.0.Final]

                    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) [jboss-seam-2.3.0.Final.jar:2.3.0.Final]

                    at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90) [jboss-seam-2.3.0.Final.jar:2.3.0.Final]

                    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) [jboss-seam-2.3.0.Final.jar:2.3.0.Final]

                    at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64) [jboss-seam-2.3.0.Final.jar:2.3.0.Final]

                    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) [jboss-seam-2.3.0.Final.jar:2.3.0.Final]

                    at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45) [jboss-seam-2.3.0.Final.jar:2.3.0.Final]

                    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) [jboss-seam-2.3.0.Final.jar:2.3.0.Final]

                    at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158) [jboss-seam-2.3.0.Final.jar:2.3.0.Final]

                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]

                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]

                    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:231) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]

                    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]

                    at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]

                    at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]

                    at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169) [jboss-as-web-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]

                    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]

                    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]

                    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]

                    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]

                    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]

                    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]

                    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:926) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]

                    at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_11]

                     

                    Can you please guide me which version of JSF I can use with Richfaces 4.5.13 or 4.5.10?

                     

                    Thanks.

                    • 7. Re: rich:autocomplete is not working
                      Michal Petrov Master

                      You need to use at least 2.1.28 or 2.2.6, Facelets are integrated in JSF 2 so you don't need the other jar. Seam might not be compatible with RichFaces 4.5 though.

                      • 8. Re: rich:autocomplete is not working
                        Sudha Raj Newbie

                        Michal,

                         

                        Thank you so much for your help. I have upgraded to 4.5.13.Final version. rich:autocomplete component is working as expected other than the header.

                         

                        Also rich:autocomplete is passing only String value (not object). I have passed the String and updated coding in my application. Here is the solution, It will be helpful for someone

                         

                        <rich:autocomplete mode="cachedAjax" minChars="2" autofill="false" selectFirst="false"

                          autocompleteMethod="#{batchProcessor.searchOfficers}" id="officerSrch" layout="table" fetchValue="#{o.employeeId}"

                          value="#{accountLookupAction.empId}" var="o" eventsQueue="officerQueue" height="270" width="480"> 

                          <h:column>

                        <f:facet name="header">

                        <h:outputText value="Employee ID"/>

                        </f:facet>  

                        <h:outputText value="#{o.employeeId}"/>

                        </h:column>

                        <h:column>

                        <f:facet name="header">

                        <h:outputText value="First Name"/>

                        </f:facet>

                        <h:outputText value="#{o.firstName}"/>

                        </h:column>

                        <h:column>

                        <f:facet name="header">

                        <h:outputText value="Last Name"/>

                        </f:facet>

                        <h:outputText value="#{o.lastName}"/>

                        </h:column>

                        <a4j:ajax event="selectitem" listener="#{accountLookupAction.addOfficer()}" render="params"/>

                        </rich:autocomplete>