[richfaces-issues] [JBoss JIRA] Created: (RF-4320) Hi All, I have created a suggestionbox using richfaces which consists nationalitylist, but the problem is when I click on any letter only the first one in the is getting selected not the one which am trying to select.

Samala Swathi (JIRA) jira-events at lists.jboss.org
Thu Aug 28 06:47:38 EDT 2008


Hi All, I have created a suggestionbox using richfaces which consists nationalitylist, but the problem is when I click on any letter only the first one in the is getting selected not the one which am trying to select.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

                 Key: RF-4320
                 URL: https://jira.jboss.org/jira/browse/RF-4320
             Project: RichFaces
          Issue Type: Bug
         Environment: Windows XP
            Reporter: Samala Swathi


This is nationality.xhtml
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:rich="http://richfaces.org/rich">

    <h:form id="suggestionbox_form">

            
            <h:inputText value="" id="text" />
            
            <rich:suggestionbox id="suggestionBoxId" for="text" 
                suggestionAction="#{capitalsBean.autocomplete}" var="result"
                fetchValue="#{result.countryName}" 
                nothingLabel="No capitals found" columnClasses="center">
                <h:column>
                    <h:outputText value="#{result.countryName}" />
                </h:column>
                 
            </rich:suggestionbox>  
                
    </h:form>

</ui:composition>

This is the action class capitalsBean.java

package com.manam.sakana.session;

import java.io.IOException;
import java.io.Serializable;
import java.net.URL;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import javax.faces.FacesException;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import javax.persistence.EntityManager;

//import org.apache.commons.digester.Digester;
//import org.apache.commons.digester.xmlrules.DigesterLoader;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.xml.sax.SAXException;

import com.manam.sakana.entity.NationalityList;

@Name("capitalsBean")
public class CapitalsBean   {
	private String nationality;
	private ArrayList<NationalityList> nationalityList = new ArrayList<NationalityList>();
	@In EntityManager entityManager;
	
	public List autocomplete(Object suggest) {
		 String pref = (String)suggest;
        System.out.println("Received Letters " +pref);
        ArrayList<NationalityList> result = new ArrayList();
        Iterator iterator = getAllData().iterator();
        while (iterator.hasNext()) {
        	
            NationalityList elem = ((NationalityList) iterator.next());
            if ((elem.getCountryName() != null && elem.getCountryName().toLowerCase().indexOf(pref.toLowerCase()) == 0) || "".equals(pref))
            {
            	result.add(elem);
            }
        }
        return result;
    }
	public ArrayList<NationalityList> getAllData(){
		  ArrayList<NationalityList> tempList2 = new ArrayList<NationalityList>();
		  ArrayList<NationalityList> nationalityList = new ArrayList<NationalityList>();
          tempList2 = (ArrayList<NationalityList>)entityManager.createQuery("from NationalityList order by id").getResultList();
        
		if(tempList2!=null)
          {
			for(NationalityList nationality : tempList2)
              {
				nationalityList.add(nationality);
              }
          }
        
          return nationalityList;
      }
	public String getNationality() {
		return nationality;
	}
	public void setNationality(String nationality) {
		this.nationality = nationality;
	}
	public ArrayList<NationalityList> getNationalityList() {
		return nationalityList;
	}
	public void setNationalityList(ArrayList<NationalityList> nationalityList) {
		this.nationalityList = nationalityList;
	}
	
   

}



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the richfaces-issues mailing list