suggestionbox always dies with stackOverflow error
zipito Sep 9, 2009 12:54 AMGood day community.
I'm trying to implement simple SuggestionBox using richfaces. And it always dies when any data could be outputed.
Additional problem anytime I pressKey in the textbox I'm getting 2 calls to mine autocomplete method: one with actual search string, and another with null string.
Mine code is following:
The Facelets template
<?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:rich="http://richfaces.org/rich" xmlns:a4j="http://richfaces.org/a4j" > <head> </head> <body> <h:form> <h:inputText id="selectSprGeography" style="width:200;"/> <rich:suggestionbox height="150" width="200" for="selectSprGeography" usingSuggestObjects="true" suggestionAction="#{sprGeographyComponent.autocomplete}" var="result" fetchValue="#{result.description}" tokens="," > <h:column> <h:outputText value="#{result.fullDescription}"/> </h:column> </rich:suggestionbox> </h:form> </body> </html>
And the sprGeographyComponent
package com.uniqa.ui.components.spr.geography; import org.springframework.stereotype.Controller; import org.springframework.context.annotation.Scope; import org.springframework.beans.factory.annotation.Autowired; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.uniqa.dao.intf.spr.geography.ISprGeographyDAO; import com.uniqa.persistence.spr.geography.SprGeography; import javax.faces.event.ValueChangeEvent; import java.util.List; import java.util.ArrayList; @Controller("sprGeographyComponent") @Scope("conversation.access") public class SprGeographyComponent { @Autowired protected ISprGeographyDAO sprGeographyDAO; Logger logger = LoggerFactory.getLogger(SprGeographyComponent.class); private List<SprGeography> currentData = new ArrayList<SprGeography>(); public List<SprGeography> autocomplete(Object data) { String search = (String )data; logger.info("searching for " + search + " " + data.getClass().getCanonicalName()); if (search != null) { //currentData = sprGeographyDAO.search(search); currentData = sprGeographyDAO.findByDescription(search); } return currentData; } public List<SprGeography> getCurrentData() { return currentData; } }
Any help would be great.
Ah yeah. I'm using Spring and MyfacesOrchestra for providing persistence between requests. (Seam seems too hard for mine development computer)