2 Replies Latest reply on Dec 6, 2011 6:40 AM by kevin 2

    problem with resource loading in CR1 release

    Brendan Healey Master

      I've just been trying the resource loading functionality in the CR1 release, and have added the following

      lines to web.xml:

       

      <context-param>

              <param-name>org.richfaces.resourceMapping.enabled</param-name>

              <param-value>true</param-value>

          </context-param>

          <context-param>

              <param-name>org.richfaces.resourceMapping.compressedPhases</param-name>

              <param-value>All</param-value>

          </context-param>

          <context-param>

              <param-name>org.richfaces.resourceMapping.packedPhases</param-name>

              <param-value>All</param-value>

      </context-param>

       

      When I run the application I see the following messages in the server log:

       

      WARNING: JSF1091: No mime type could be found for file org.richfaces.staticResource/4.1.0.20111111-CR1/PackedCompressed/myskin/packed/packed.css&v=23.  To resolve this, add a mime-type mapping to the applications web.xml.

       

      I get a 404 error trying to load packed.css:

       

      https://localhost:8181/uk.co.myproj_MyProj_war_1.0.0/org.richfaces.resources/javax.faces.resource/org.richfaces.staticResource/4.1.0.20111111-CR1/PackedCompressed/myskin/packed/packed.css&v=23

       

      The project has it's own resource handler (i.e. extends ResourceWrapper) which just appends a build version number

      to a static resource (shown as &v=23 above), so that I can force a refresh of the browser cache when I redeploy, but I've

      tried disabling this with no success.

       

      Am I missing some configuration here? I saw this text in the dev guide, but I not entirely sure what it means:

       

      >Resource loading strategies are just special case of resource mapping, thus

      >once you will provide custom resource mapping configuration or location, bundled

      >default resources won't be referenced correctly.

      >For using compressed/packed resources you will need to copy properties from

      >one of files located in richfaces-components-ui.jar:/META-INF/richfaces/

      >staticResourceMapping/.

       

      Thanks,

      Brendan.

        • 1. Re: problem with resource loading in CR1 release
          kevin 2 Newbie

          For my part, I tried the folowing configuration and it works in a simple application:

           

            <context-param>

              <param-name>org.richfaces.resourceMapping.enabled</param-name>

              <param-value>true</param-value>

            </context-param>

            <context-param>

                <param-name>org.richfaces.resourceMapping.compressedStages</param-name>

                <param-value>All</param-value>

            </context-param>

            <context-param>

                <param-name>org.richfaces.resourceMapping.packedStages</param-name>

                <param-value>All</param-value>

            </context-param>

              <servlet>

                  <servlet-name>Resource Servlet</servlet-name>

                  <servlet-class>org.richfaces.webapp.ResourceServlet</servlet-class>

                  <load-on-startup>1</load-on-startup>

              </servlet>

              <servlet-mapping>

                  <servlet-name>Resource Servlet</servlet-name>

                  <url-pattern>/org.richfaces.resources/*</url-pattern>

              </servlet-mapping>

           

          However, I'm still having issues (JavaScript errors) which depend on the components declaration order.

          If I put a JSF component first, jsf.js will be loaded before packed.js (RichFaces library) and there is no error.

          But if I put a RichFaces component first, jsf.js is loaded after and the page loading generates many JavaScript errors (jsf is undefined, RichFaces.ui is undefined).

          I'm going to create a new thread for this and a Jira issue.

          • 2. Re: problem with resource loading in CR1 release
            kevin 2 Newbie

            Finally, I added a comment to the issue RF-11764.

             

            To complete the description of the issue, here is the code of the working page:

             

            <!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">
            <f:view xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:a4j="http://richfaces.org/a4j"
                xmlns:rich="http://richfaces.org/rich">
                <h:head>
                    <title>Test</title>
                </h:head>
                <h:body>
                    <h:form>
                        <a4j:commandButton value="Button"/>
                        <rich:toolbar binding="#{toolbar.toolBar}"></rich:toolbar>
                    </h:form>
                </h:body>
            </f:view>
            </html>
            

             

            The #{toolbar.toolBar} getter creates a simple toolbar:

             

              public UIToolbar getToolBar()
              {
                if(toolBar == null)
                {
                  toolBar = new UIToolbar();
                  UIDropDownMenu ddm = new UIDropDownMenu();
            
                  UIMenuItem item1 = new UIMenuItem();
                  item1.setLabel("Item 1");
                  UIMenuItem item2 = new UIMenuItem();
                  item2.setLabel("Item 2");
                  
                  ddm.setLabel("Menu 1");
                  
                  ddm.getChildren().add(item1);
                  ddm.getChildren().add(item2);
                  
                  toolBar.getChildren().add(ddm);
                }
                return toolBar;
              }
            

             

            Here is the head part of the generated page:

             

            <head>
              <link type="text/css" rel="stylesheet"
              href="/testJSF/org.richfaces.resources/javax.faces.resource/org.richfaces.staticResource/4.1.0.20111111-CR1/PackedCompressed/DEFAULT/skinning.css" />
              <script type="text/javascript"
              src="/testJSF/javax.faces.resource/jsf.js.xhtml?ln=javax.faces">
              </script>
              <script type="text/javascript"
              src="/testJSF/org.richfaces.resources/javax.faces.resource/org.richfaces.staticResource/4.1.0.20111111-CR1/PackedCompressed/packed/packed.js">
              </script>
              <title>Test</title>
            </head>
            

             

            There is no JS errors.

             

            Now, if add remove the a4j:commandButton on line 13, the generated head part becomes the following:

             

            <head>
              <link type="text/css" rel="stylesheet"
              href="/testJSF/org.richfaces.resources/javax.faces.resource/org.richfaces.staticResource/4.1.0.20111111-CR1/PackedCompressed/DEFAULT/skinning.css" />
              <title>Test</title>
            </head>
            

             

            The Toolbar is badly rendered, and this produces the following JavaScript errors:

             

            RichFaces is not defined
            [Stopper sur une erreur] <table border="0" cellpadding="0" cell...iv><script type="text/javascript">new
            RichFaces is not defined
            [Stopper sur une erreur] <table border="0" cellpadding="0" cell...iv><script type="text/javascript">new
            RichFaces is not defined
            [Stopper sur une erreur] RichFaces.ui.Menu(...87677944472842" autocomplete="off" />
            toolbarHandlers is not defined
            [Stopper sur une erreur] RichFaces.ui.Menu(...87677944472842" autocomplete="off" />