Issue with suggestionbox in ui repeat -urgent pls help
valatharv Sep 30, 2009 1:01 PMI posted it in seam forum but there is no response, may be it is related to richfaces...
I am trying to use suggestionbox in ui repeat but suggestionAction is never called.
Please suggest, why suggestionAction="#{itemLinesBean.autocomplete}" is not called in ui repeat, I tested various scenarios but it doesn't work in ui repeat...
Any suggestion will be of great help... I am stuck on this and can't proceed..
XHTML
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
 xmlns:s="http://jboss.com/products/seam/taglib"
 xmlns:ui="http://java.sun.com/jsf/facelets"
 xmlns:f="http://java.sun.com/jsf/core"
 xmlns:h="http://java.sun.com/jsf/html"
 xmlns:a="http://richfaces.org/a4j"
 xmlns:rich="http://richfaces.org/rich"
 xmlns:c="http://java.sun.com/jstl/core"
 template="layout/template.xhtml">
<ui:define name="body">
<h:messages globalOnly="true" styleClass="message" errorClass="errors" infoClass="info" id="globalMessages"/>
<h:form id="proj" styleClass="edit">
//THIS WORKS FINE
<h:inputText value="#{itemLinesBean.cell}" id="text1" />
 <rich:suggestionbox id="suggestionBoxId1" for="text1" tokens=",[]"
 suggestionAction="#{itemLinesBean.autocomplete}" var="result"
 fetchValue="#{result.itemName}"
 nothingLabel="No items found" columnClasses="center"
 usingSuggestObjects="true">
 <h:column>
 <h:outputText value="#{result.itemName}" />
 </h:column>
 </rich:suggestionbox>
<rich:panel id="reagentPanel">
<table><thead>...</thead>
 <ui:repeat value="#{projHome.reg}" var="info" >
 <tbody>
 <td>
 <s:decorate id="type" template="layout/edit.xhtml">
 <h:inputText id="type" required="true" value="#{info.type}"/>
 </s:decorate>
 </td>
 <td>
 //NOT WORKING, suggestionAction EVENT IS NOT FIRED <h:inputText value="#{itemLinesBean.cell}" id="text" />
 <rich:suggestionbox id="suggestionBoxId" for="text" tokens=",[]"
 suggestionAction="#{itemLinesBean.autocomplete}" var="result"
 fetchValue="#{result.itemName}"
 nothingLabel="No cells found" columnClasses="center"
 usingSuggestObjects="true">
 <h:column>
 <h:outputText value="#{result.itemName}"/>
 </h:column>
 </rich:suggestionbox>
 </td>
 ....
 </tbody>
 </ui:repeat>
</table>
</rich:panel>
<div class="actionButtons" align="center">
 <h:commandLink id="add" action="#{projHome.addreg}"
 value="Add More regs"/>
</div>
<div class="actionButtons">
 <h:commandLink id="save" action="#{projHome.persist}"..>Save</h:commandLink>
 ...
</div>
</h:form>
</ui:define>
</ui:composition>
Corresponding bean
@Name("itemsBean")
public class ItemsBean {
 public List<Item> autocomplete(Object suggest) {
 System.out.println("ItemsBean.autocomplete() Entered.... CHECK.......");
 String pref = (String)suggest;
 ArrayList<Item> result = new ArrayList<Item>();
 Iterator<Item> iterator = getItems().iterator();
 while (iterator.hasNext()) {
 Item elem = ((Item) iterator.next());
 if ((elem.getItemName() != null && elem.getItemName().toLowerCase().indexOf(pref.toLowerCase()) == 0) || "".equals(pref))
 {
 result.add(elem);
 }
 }
 return result;
 }
} 
     
    