2 Replies Latest reply on Nov 3, 2011 7:02 AM by vadivelcit

    Richfaces 4.0 autocomplete

    vadivelcit

      Hi All,

       

           i am using jsf 2.0 and richfaces 4.0.

           i have issue on richfaces 4.0 autocomplete.

       

           step1: click on the submit button without enter any input fields. it will show the error message. pls see the image1

       

           step2: then focus on autocomplete field type any character, it will show the list. But that time all the error

      message will be hide. pls see the image2

       

      i dont want to hide all the error message.

       

      i am using below code:

       

       

                                        <rich:autocomplete


                                                  id="test"  value="#{testBean.company}"

                                                  autocompleteMethod="#{testBean.companyList}"

                                                  fetchValue="#{company.label}"

                                                  var="company" mode="ajax" minChars="1" // here i tried with mode="ajax" and mode="cachedAjax"


                                                            <h:outputText value="#{company.label}" />


                                        </rich:autocomplete>

       


       

           my guess :  both(mode="ajax" and mode="cachedAjax") condition jsf construct the tree, due to ajax call so that all the error message will be hide for all the input fields.

       

      i used mode="client" for this case error message will not be hide. but it wil show the company list without enter any character, i dont want to display all company without enter any  character.

       

      pls, help me..

       

      thanks.

        • 1. Re: Richfaces 4.0 autocomplete
          vadivelcit

          Hi All,

           

          here i will explain the above issue clearly

           

              step1:  When I click on submit button with empty fields, validation is working (which ever field is required). pls see the image1

           

               step2:  Then type on the company field, all the error message will be disappear (company field is <rich:autocomplete>).

          pls see the image2

           

          I want all the error message should be appear, (when I type on the company field).

           

          I used <a4j:regin>. but i didnt get anything.

          • 2. Re: Richfaces 4.0 autocomplete
            vadivelcit

            tis is my code:

             

            <html xmlns="http://www.w3.org/1999/xhtml"

                xmlns:h="http://java.sun.com/jsf/html"

                xmlns:rich="http://richfaces.org/rich"

                xmlns:a4j="http://richfaces.org/a4j">

             

                <h:form id="form-id">

             

                    name<br />

                    <h:inputText id="name" value="#{testBean.name}" required="true"

                        requiredMessage="value is required"/>

                    <rich:message for="name" />

             

                    phone number<br />

                    <h:inputText id="phone-num" value="#{testBean.phoneNumber}" required="true"

                        requiredMessage="value is required"/>

                    <rich:message for="phone-num" />

             

                    company<br />

                    <rich:autocomplete id="com-id" value="#{testBean.company}"

                        autocompleteMethod="#{testBean.companyList}"

                        fetchValue="#{company.label}" var="company" required="true"

                        mode="ajax" minChars="1" requiredMessage="value is required">

                            <h:outputText value="#{company.label}" />

                    </rich:autocomplete>

                    <rich:message for="com-id" />

             

                    Address<br />

                    <h:inputText id="add" value="#{testBean.address}" required="true"

                        requiredMessage="value is required"/>

                    <rich:message for="add" />

             

                    <a4j:commandButton type="submit" action="#{testBean.save}" value="submit" />

             

                </h:form>

             

            </html>

             

            managed bean:

             

             

             

            @ManagedBean

            @ViewScoped

            public class TestBean implements Serializable{

             

                private static final long serialVersionUID = 1L;

                private String name;

                private String phoneNumber;

                private String company;

                private String address;

                private List<String> clist;

             

                public TestBean() {}

             

                public String getName() {

                    return name;

                }

                public void setName(String name) {

                    this.name = name;

                }

                public String getPhoneNumber() {

                    return phoneNumber;

                }

                public void setPhoneNumber(String phoneNumber) {

                    this.phoneNumber = phoneNumber;

                }

                public String getCompany() {

                    return company;

                }

                public void setCompany(String company) {

                    this.company = company;

                }

                public String getAddress() {

                    return address;

                }

                public void setAddress(String address) {

                    this.address = address;

                }

                public List<String> getClist() {

                    return clist;

                }

                public void setClist(List<String> clist) {

                    this.clist = clist;

                }

             

                public List<String> companyList() {       

                    clist = new ArrayList<String>();

                    clist.add("1test1");

                    clist.add("1test2");

                    clist.add("2test1");

                    clist.add("2test2");

                    clist.add("3test1");

                    clist.add("3test2");

                    clist.add("4test1");

                    clist.add("4test2");

                    return clist;

                }

             

                public void save() {

             

                }

            }