13 Replies Latest reply on Mar 8, 2007 10:23 PM by sergeysmirnov

    SuggestionBox not showing. ResourceNotFoundException suspect

    damianharvey

      Hi,

      I have a SuggestionBox component that is returning values from the server (checked using Firebug), however nothing gets displayed. There is no 'drop-down' component rendered under the h:outputText

      Here is my code:

       <h:inputText id="unLocode" value="#{scheduleDateHome.instance.unLocode}"/>
       <rich:suggestionbox for="unLocode" suggestionAction="#{unLocodeAutoComplete.suggest}" var="unLocodes" fetchValue="#{unLocodes.name}">
       <h:column>
       <h:outputText value="#{unLocodes.locode}"></h:outputText>
       </h:column>
       </rich:suggestionbox>
      


      When I first call the component there is an exception that I suspect is causing the drop-down not to render:
      org.ajax4jsf.framework.resource.ResourceNotFoundException: Resource not registered : org.richfaces.renderkit.html.GradientA


      Can someone tell me how to fix this error? Is it the cause of the non-rendering?

      I can post the content of the AJAX response if it would help (but it is large-ish).

      Thanks,

      Damian.

        • 1. Re: SuggestionBox not showing. ResourceNotFoundException sus
          james_hays

          I had this issue as well. I had to rework my web.xml file to put things in a correct order. If I remember correctly, there was an incompatibility when load sequence of the filters was out of whack. Here's my web.xml that fixed that issue.

          <?xml version="1.0" ?>
          <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
           <!-- Seam -->
           <listener>
           <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
           </listener>
          
           <!-- Propagate conversations across redirects -->
           <filter>
           <filter-name>Seam Redirect Filter</filter-name>
           <filter-class>org.jboss.seam.servlet.SeamRedirectFilter</filter-class>
           </filter>
          
           <!-- ajax4jsf -->
           <filter>
           <display-name>Ajax4jsf Filter</display-name>
           <filter-name>ajax4jsf</filter-name>
           <filter-class>org.ajax4jsf.Filter</filter-class>
           </filter>
           <filter-mapping>
           <filter-name>ajax4jsf</filter-name>
           <url-pattern>*.seam</url-pattern>
           </filter-mapping>
          
           <filter-mapping>
           <filter-name>Seam Redirect Filter</filter-name>
           <url-pattern>*.seam</url-pattern>
           </filter-mapping>
           <filter>
           <filter-name>Seam Exception Filter</filter-name>
           <filter-class>org.jboss.seam.servlet.SeamExceptionFilter</filter-class>
           </filter>
           <filter-mapping>
           <filter-name>Seam Exception Filter</filter-name>
           <url-pattern>*.jsf</url-pattern>
           </filter-mapping>
          
           <!-- JSF -->
           <context-param>
           <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
           <param-value>client</param-value>
           </context-param>
           <context-param>
           <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
           <param-value>com.sun.facelets.FaceletViewHandler</param-value>
           </context-param>
           <context-param>
           <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
           <param-value>.xhtml</param-value>
           </context-param>
           <context-param>
           <param-name>facelets.REFRESH_PERIOD</param-name>
           <param-value>2</param-value>
           </context-param>
           <context-param>
           <param-name>facelets.DEVELOPMENT</param-name>
           <param-value>true</param-value>
           </context-param>
           <context-param>
           <param-name>com.sun.faces.validateXml</param-name>
           <param-value>true</param-value>
           </context-param>
           <context-param>
           <param-name>com.sun.faces.verifyObjects</param-name>
           <param-value>true</param-value>
           </context-param>
           <context-param>
           <param-name>org.ajax4jsf.SKIN</param-name>
           <param-value>DEFAULT</param-value>
           </context-param>
           <servlet>
           <servlet-name>Faces Servlet</servlet-name>
           <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
           <load-on-startup>1</load-on-startup>
           </servlet>
           <servlet>
           <servlet-name>Seam Resource Servlet</servlet-name>
           <servlet-class>org.jboss.seam.servlet.ResourceServlet</servlet-class>
           </servlet>
           <!-- Faces Servlet Mapping -->
           <servlet-mapping>
           <servlet-name>Faces Servlet</servlet-name>
           <url-pattern>*.seam</url-pattern>
           </servlet-mapping>
           <servlet-mapping>
           <servlet-name>Seam Resource Servlet</servlet-name>
           <url-pattern>/seam/resource/*</url-pattern>
           </servlet-mapping>
          
           <!-- MyFaces -->
           <listener>
           <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
           </listener>
          </web-app>
          


          • 2. Re: SuggestionBox not showing. ResourceNotFoundException sus
            damianharvey

            That has sorted out the problem with the ResourceNotFound, however the SuggestionBox is still not rendering in Firefox. It is however rendering in Safari but is not selectable and doesn't look right.

            Any ideas?

            Is this a Mac thing? Anyone else using this on a Mac?



            • 3. Re: SuggestionBox not showing. ResourceNotFoundException sus

               

              "damianharvey" wrote:
              That has sorted out the problem with the ResourceNotFound, however the SuggestionBox is still not rendering in Firefox. It is however rendering in Safari but is not selectable and doesn't look right.
              Any ideas?
              Is this a Mac thing? Anyone else using this on a Mac?


              ResourceNotFound would not be a primary reason the suggestionBox does not work, but can cause the trouble with look-n-feel

              Most likely, the problem with resources happens because of the filters configuration when some request comes through the filter, but others do not.

              Could you look at livedemo example:
              http://livedemo.exadel.com/richfaces-demo/richfaces/suggestionBox.jsf?c=suggestionBox

              Do you have some problems with suggestionBox there working on Mac?

              • 4. Re: SuggestionBox not showing. ResourceNotFoundException sus
                james_hays

                You don't have a width and height on your SuggestionBox component. Those seem to be required. I wish they would just default...

                As far as Safari, I had the same issue last night. There are a lot of components that don't render correctly in Safari. Sliders are another.

                • 5. Re: SuggestionBox not showing. ResourceNotFoundException sus
                  damianharvey

                  Nice one! That did it. Thanks James. You seem to be a step ahead.

                  Do you know how to get the row selector showing up in the SuggestionBox? I can click on the required item but can't traverse with the keyboard (or can't see it anyway). Tried setting selectedClass but didn't work.

                  Cheers,

                  Damian.

                  • 6. Re: SuggestionBox not showing. ResourceNotFoundException sus
                    damianharvey

                    On the plus side it's rendering even better in Safari. Still can't see the row highlight move with the keyboard though.

                    • 7. Re: SuggestionBox not showing. ResourceNotFoundException sus
                      damianharvey

                       

                      "SergeySmirnov" wrote:
                      Most likely, the problem with resources happens because of the filters configuration when some request comes through the filter, but others do not.

                      Could you look at livedemo example:
                      http://livedemo.exadel.com/richfaces-demo/richfaces/suggestionBox.jsf?c=suggestionBox

                      Do you have some problems with suggestionBox there working on Mac?


                      Thanks Sergey. When Seam generates an Eclipse project it puts the ajax4jsf entries first in the web.xml with the comment "Ajax4jsf (must come first!)". In the RichFaces docs it doesn't specify any further configuration for RichFaces other than adding the jar. However in order to get around the ResourceNotFoundException I had to change the web.xml putting the Seam Listener first.

                      What is the reccomended approach for RichFaces with Seam?

                      And the example works fine in FF on the mac but in Safari the rendered box does not show underneath the inputText field. It appears about 300px to the left.

                      Cheers,

                      Damian.

                      • 8. Re: SuggestionBox not showing. ResourceNotFoundException sus

                        the missing highlighting is about missing of the resources. Try to override the style for it like that:

                        <style>
                        .mysb .dr-sb-int-sel {
                         background-image: url();
                        }
                        </style>
                        ....
                        <rich:suggestionbox styleClass="mysb" .....


                        • 9. Re: SuggestionBox not showing. ResourceNotFoundException sus

                           

                          "james_hays" wrote:
                          You don't have a width and height on your SuggestionBox component. Those seem to be required. I wish they would just default...


                          The width and height are required according to tld. However, facelets do not care about tld, so they do not pay attention on this requirement either.

                          So, I will put the default size there 200x200px for further builds

                          • 10. Re: SuggestionBox not showing. ResourceNotFoundException sus
                            damianharvey

                            That didn't change it. The CSS style that you refer to is already referenced on the page. Using the Firefox WebDeveloper ext I can see that suggestionbox.xcss is part of the page.

                            Is there any other reason why this would not be referenced?

                            Thanks,

                            Damian.

                            • 11. Re: SuggestionBox not showing. ResourceNotFoundException sus

                              the style class for selection comes from suggestionbox.xcss defines both background-color and background image. The background image references to generated resource (gradient image). Normally, if background references to non-existing image, the background-color starts to work. I used to thing that Mac does it otherwise somehow.

                              P.S. I used to use Firefox WebDeveloper in the past, but switched to FireBug. It is 10x time better. From the style point of view it allows not only see the styles. but shows how styles override each other.

                              • 12. Re: SuggestionBox not showing. ResourceNotFoundException sus
                                damianharvey

                                The Seam CSS (theme.css) was the culprit, however I couldn't find out why. Didn't seem to be because of any expected element. I'll selectively add styles back in until I find it.

                                I didn't realise Firebug could analyse the CSS like that. Much appreciated. Still nice to have WebDeveloper if only for when you get stuck on CSS Block madness.

                                One further question - the onselect attribute of the SuggestionBox calls some client-side javascript when an item is selected from the suggestion list. Can you think of anyway that I can call a Bean method instead (or as well as)?

                                Thanks very much for the help.

                                Regards,

                                Damian.

                                • 13. Re: SuggestionBox not showing. ResourceNotFoundException sus

                                  I think you can add <a4j:support event="onselect" .... /> to initiate the Ajax Request and invoke bean method there (action listener or action method) and even re-render something when the response comes back.

                                  At the same time, speaking about invoking bean method from the javascript, the a4j:jsFunction is available exactly for this purpose. This component allows to make the Ajax request, invoke the beam method of the server side, serialize the returned data as an JSON object, send back to the client and call any javascript function with returned data as a parameter(s)

                                  The Google Map component example shows how to use jsFunction om practice. See the source in the source frame there:
                                  http://livedemo.exadel.com/richfaces-demo/richfaces/gmap.jsf?c=gmap