Richfaces suggestionbox Error on retrieving #{rich:componen
gurleyc1 Dec 11, 2009 3:27 PMI am having an issue with my suggestionbox. I try to call the following method when the user clicks the down arrow:
<h:panelGrid columns="2" border="0" cellpadding="0" cellspacing="0"> <h:inputText style="margin:0px;" id="input_field" > </h:inputText> <h:graphicImage value="/images/icons/arrow_dwn.png" onclick="#{rich:component('suggestion_box')}" alt="" /> </h:panelGrid>
The problem is that the component is null ( I am assuming at least because I took out the method call and still get a null pointer exception).
The entire class is included below if it is necessary:
<!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: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">
<ui:composition>
function printObjectsSelected(output, sgcomponent){
output.innerHTML=sgcomponent.getSelectedItems().pluck('code');
}
<h:form id="form">
<a4j:queue />
<a4j:outputPanel id="panel_lookupWidget">
<h:panelGrid columns="2" width="400px">
<h:outputText styleClass="outputText" value="Input a code to search for" />
<h:panelGrid columns="2" border="0" cellpadding="0" cellspacing="0">
<h:inputText style="margin:0px;" id="input_field" >
</h:inputText>
<h:graphicImage value="/images/icons/arrow_dwn.png" onclick="#{rich:component('suggestion_box')}"
alt="" />
</h:panelGrid>
<h:outputText styleClass="outputText" id="objects" style="font-weight:bold" />
</h:panelGrid>
<rich:suggestionbox height="200" width="200" ajaxSingle="true"
usingSuggestObjects="true" frequency="1"
suggestionAction="#{lookupWidgetBean.autocomplete}" var="item"
for="input_field" fetchValue="#{wdc.code}" id="suggestion_box">
<h:column>
<h:outputText styleClass="outputText" value="#{item.code}" />
</h:column>
<h:column>
<h:outputText styleClass="outputText" value="#{item.description}" />
</h:column>
</rich:suggestionbox>
</a4j:outputPanel>
</h:form>
</ui:composition>
The backing bean calls a database to retrieve the code and description, and puts it in a list that is returned during the 'autocomplete' method. The suggestion box for some reason works just fine without the richfaces method call, its just the down arrow link naturally does not work. The constructor in my bean populates my list of objects, and the autocomplete does the filtering...these two methods work fine. Please let me know if you see I am missing something.