3 Replies Latest reply on Dec 14, 2009 9:09 AM by Nick Belaevski

    Richfaces suggestionbox Error on  retrieving #{rich:componen

    Chris Gurley Newbie

      I 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.

        • 1. Re: Richfaces suggestionbox Error on  retrieving #{rich:componen
          Nick Belaevski Master

          Hi,

           

          What NPE is happenning? Please post stack trace.

          • 2. Re: Richfaces suggestionbox Error on  retrieving #{rich:componen
            Chris Gurley Newbie
            java.lang.NullPointerException
                 at org.apache.el.lang.FunctionMapperImpl$Function.writeExternal(FunctionMapperImpl.java:123)
                 at java.io.ObjectOutputStream.writeExternalData(Unknown Source)
                 at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
                 at java.io.ObjectOutputStream.writeObject0(Unknown Source)
                 at java.io.ObjectOutputStream.writeObject(Unknown Source)
                 at java.util.HashMap.writeObject(Unknown Source)
                 at sun.reflect.GeneratedMethodAccessor152.invoke(Unknown Source)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                 at java.lang.reflect.Method.invoke(Unknown Source)
                 at java.io.ObjectStreamClass.invokeWriteObject(Unknown Source)
                 at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
                 at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
                 at java.io.ObjectOutputStream.writeObject0(Unknown Source)
                 at java.io.ObjectOutputStream.writeObject(Unknown Source)
                 at org.apache.el.lang.FunctionMapperImpl.writeExternal(FunctionMapperImpl.java:74)
                 at java.io.ObjectOutputStream.writeExternalData(Unknown Source)
                 at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
                 at java.io.ObjectOutputStream.writeObject0(Unknown Source)
                 at java.io.ObjectOutputStream.writeObject(Unknown Source)
                 at org.apache.el.ValueExpressionImpl.writeExternal(ValueExpressionImpl.java:256)
                 at java.io.ObjectOutputStream.writeExternalData(Unknown Source)
                 at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
                 at java.io.ObjectOutputStream.writeObject0(Unknown Source)
                 at java.io.ObjectOutputStream.writeObject(Unknown Source)
                 at com.sun.facelets.el.TagValueExpression.writeExternal(TagValueExpression.java:128)
                 at java.io.ObjectOutputStream.writeExternalData(Unknown Source)
                 at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
                 at java.io.ObjectOutputStream.writeObject0(Unknown Source)
                 at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)
                 at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
                 at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
                 at java.io.ObjectOutputStream.writeObject0(Unknown Source)
                 at java.io.ObjectOutputStream.writeArray(Unknown Source)
                 at java.io.ObjectOutputStream.writeObject0(Unknown Source)
                 at java.io.ObjectOutputStream.writeArray(Unknown Source)
                 at java.io.ObjectOutputStream.writeObject0(Unknown Source)
                 at java.io.ObjectOutputStream.writeArray(Unknown Source)
                 at java.io.ObjectOutputStream.writeObject0(Unknown Source)
                 at java.io.ObjectOutputStream.writeArray(Unknown Source)
                 at java.io.ObjectOutputStream.writeObject0(Unknown Source)
                 at java.io.ObjectOutputStream.writeArray(Unknown Source)
                 at java.io.ObjectOutputStream.writeObject0(Unknown Source)
                 at java.io.ObjectOutputStream.writeArray(Unknown Source)
                 at java.io.ObjectOutputStream.writeObject0(Unknown Source)
                 at java.io.ObjectOutputStream.writeArray(Unknown Source)
                 at java.io.ObjectOutputStream.writeObject0(Unknown Source)
                 at java.io.ObjectOutputStream.writeArray(Unknown Source)
                 at java.io.ObjectOutputStream.writeObject0(Unknown Source)
                 at java.io.ObjectOutputStream.writeArray(Unknown Source)
                 at java.io.ObjectOutputStream.writeObject0(Unknown Source)
                 at java.io.ObjectOutputStream.writeArray(Unknown Source)
                 at java.io.ObjectOutputStream.writeObject0(Unknown Source)
                 at java.io.ObjectOutputStream.writeArray(Unknown Source)
                 at java.io.ObjectOutputStream.writeObject0(Unknown Source)
                 at java.io.ObjectOutputStream.writeArray(Unknown Source)
                 at java.io.ObjectOutputStream.writeObject0(Unknown Source)
                 at java.io.ObjectOutputStream.writeArray(Unknown Source)
                 at java.io.ObjectOutputStream.writeObject0(Unknown Source)
                 at java.io.ObjectOutputStream.writeArray(Unknown Source)
                 at java.io.ObjectOutputStream.writeObject0(Unknown Source)
                 at java.io.ObjectOutputStream.writeArray(Unknown Source)
                 at java.io.ObjectOutputStream.writeObject0(Unknown Source)
                 at java.io.ObjectOutputStream.writeArray(Unknown Source)
                 at java.io.ObjectOutputStream.writeObject0(Unknown Source)
                 at java.io.ObjectOutputStream.writeArray(Unknown Source)
                 at java.io.ObjectOutputStream.writeObject0(Unknown Source)
                 at java.io.ObjectOutputStream.writeObject(Unknown Source)
                 at com.sun.faces.renderkit.ResponseStateManagerImpl.writeState(ResponseStateManagerImpl.java:244)
                 at javax.faces.render.ResponseStateManager.writeState(ResponseStateManager.java:155)
                 at org.ajax4jsf.application.AjaxStateManager.writeState(AjaxStateManager.java:294)
                 at org.ajax4jsf.application.AjaxStateManager.writeState(AjaxStateManager.java:256)
                 at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:620)
                 at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
                 at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
                 at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
                 at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
                 at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
                 at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                 at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
                 at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
                 at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
                 at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                 at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
                 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
                 at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
                 at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
                 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                 at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
                 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
                 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
                 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
                 at java.lang.Thread.run(Unknown Source)

            It is happening due to the fact that the #{rich:component('suggestion')} is for some reason returning a
            null object....not sure as to why.