1 2 Previous Next 21 Replies Latest reply on Jan 12, 2012 2:35 PM by undermanager Go to original post
      • 15. Re: RF 4.1.0.Final - javascript error when resource mapping enabled
        healeyb

        Hi Lukas, I'm not clear where I need to add the a4j:jsFunction in my template. I've tried it pretty much everywhere

        but nothing seems to work. Does it need to be:

         

        - in it's own form   - before any other richfaces components are used   - in the body ?

         

        I've managed to get a page containing some extendedDataTables to render with resourceMapping enabled, but

        they're not responsive (i.e. I can't select a row or scroll - due to the javascript errors surely). I've had to make three

        changes to the application to get this to work:

         

        1. Change the application to use prefix mapping instead of suffix mapping.

         

        2. Not use my own org.richfaces.skin (context param). When I use my own skin it doesn't work.

         

        3. I've had to ensure that my custom ResourceHandler (http://137.254.16.27/rlubke/entry/jsf_2_0_new_feature)

            specifically excludes richfaces resources, which is fair enough. I use this to add a version string to jsf static

           resources so that I can invalidate the browser cache on redeployment.

         

        So thanks for replying, some good progress today, now I just need to nail the jsf.js problem and perhaps a few

        jiras to log.

         

        Regards,

        Brendan.

        • 16. Re: RF 4.1.0.Final - javascript error when resource mapping enabled
          mcmurdosound

          ah, sorry, weekend and no access to my computer at work ;-)

           

          from my web.xml

           

          (working with eclipse, jboss 7 etc)

            <servlet-mapping>

              <servlet-name>Faces Servlet</servlet-name>

              <url-pattern>*.xhtml</url-pattern>

            </servlet-mapping>

           

          (working with netbeans 7.0.1 glassfish etc)

          <servlet-mapping>
              <servlet-name>Faces Servlet</servlet-name>
              <url-pattern>/faces/*</url-pattern>
          </servlet-mapping>

           

          hmmm

          • 17. Re: RF 4.1.0.Final - javascript error when resource mapping enabled
            healeyb

            The problem I'm seeing with glassfish/mojarra is that it is appending .xhtml to all my static resources

            when using suffix mapping. So if I have <h:outputScript name="jquery.js"/> in the page source this

            translates to <script src="jquery.js.xhtml" type="text/javascript"/> - but it still works ok, the

            FacesServlet is handling the situation. Another effect I'm seeing is that to reference a resource from a

            stylesheet when using suffix mapping you have to use EL syntax, i.e.:

             

            background-image: url("#{resource['images:background265.png']}");

             

            ...but it transpires that this is not brilliant from a performance perspective.

             

            I can reproduce this behavior in a template NetBeans web project, so that rules out any configuration issues

            at the application level, but perhaps there's something I've got set in the server configuration? Until I can

            resolve this I've gone back to prefix mapping, but I think it (the unexpected appending of .xhtml) maybe related

            to the problem I'm seeing with richfaces resource loading.

             

            Regards,

            Brendan.

            • 18. Re: RF 4.1.0.Final - javascript error when resource mapping enabled
              lfryc

              Brendan Healey wrote:

               

              Hi Lukas, I'm not clear where I need to add the a4j:jsFunction in my template.

              The goal is to force JSF to load jsf.js before packed.js is loaded.

              You can achieve it by placing component which requires jsf.js just before any other component (specifically any other RichFaces component).

               

               

              Brendan Healey wrote:

               

              1. Change the application to use prefix mapping instead of suffix mapping.

              For resource mapping handler it should not matter if you use prefix/suffix mapping.

               

               

              Brendan Healey wrote:

               

              2. Not use my own org.richfaces.skin (context param). When I use my own skin it doesn't work.

               

              Resource mapping is prepared for all the RichFaces skins, but when you are using custom skin, you need either to:

               

              • disable mapping for resource-depenent resources [1]
                • basically you need to derive own configuration for resource mapping, you can use current one based in richfaces-components-ui.jar and copy it to your classpath and remove all lines which contains %skin%
              • or generate static resources from your skin configuration [2]

               

              [1] http://docs.jboss.org/richfaces/latest_4_X/Developer_Guide/en-US/html/chap-Developer_Guide-Advanced_features.html#sect-Developer_Guide-Advanced_features-Resource_mapping

              [2] https://community.jboss.org/docs/DOC-17377

              • 19. Re: RF 4.1.0.Final - javascript error when resource mapping enabled
                lfryc

                Brendan Healey wrote:

                 

                The problem I'm seeing with glassfish/mojarra is that it is appending .xhtml to all my static resources

                when using suffix mapping. So if I have <h:outputScript name="jquery.js"/> in the page source this

                translates to <script src="jquery.js.xhtml" type="text/javascript"/> - but it still works ok, the

                FacesServlet is handling the situation.

                 

                Yes, as you said, ResourceHandler does not have any other choice than use mapping you setup for FacesServlet (any other requests won't be handled by FacesServlet).

                 

                 

                Brendan Healey wrote:

                 

                Another effect I'm seeing is that to reference a resource from a

                stylesheet when using suffix mapping you have to use EL syntax, i.e.:

                 

                background-image: url("#{resource['images:background265.png']}");

                 

                ...but it transpires that this is not brilliant from a performance perspective.

                Yeah, this is JSF issue, Jakob Korherr are going to address that in project relative-resource-handler:

                http://code.google.com/a/apache-extras.org/p/relative-resource-handler/

                 

                 

                Brendan Healey wrote:

                 

                I can reproduce this behavior in a template NetBeans web project, so that rules out any configuration issues

                at the application level, but perhaps there's something I've got set in the server configuration? Until I can

                resolve this I've gone back to prefix mapping, but I think it (the unexpected appending of .xhtml) maybe related

                to the problem I'm seeing with richfaces resource loading.

                 

                Regards,

                Brendan.

                Some of problems are indeed caused by RF resource loading and its configuration (while custom skin plays significan't role here).

                If I could be of any help, just connect to irc.freenode.net #richfaces channel, discussing it in persona may help a lot.

                • 20. Re: RF 4.1.0.Final - javascript error when resource mapping enabled
                  healeyb

                  Lukas, the "jsf is undefined" error was caused by the fact that the loading of packed.js wasn't being

                  triggered by using a richfaces component (I removed them all), but by using the richfaces packaged

                  version of jquery (it's inside packed.js of course), so in my template I had:

                   

                  <h:head>

                    <h:outputScript name="jquery.js"/>

                    <h:outputScript name="jsf.js" library="javax.faces"/>

                   

                  Simply by swapping the two outputScript lines fixes the problem. I had been a bit confused by the

                  whole issue because I was including jsf.js in the template anyway.

                   

                  Regarding prefix/suffix mapping: I certainly can't get suffix mapping to work in a mojarra/glassfish

                  configuration, but it doesn't matter to me. I've reverted to prefix mapping as suffix mapping was causing

                  me problems in other ways.

                   

                  One final thing to look out for is that if you manually include jquery-ui then note that this is already

                  included in packed.js. So if you use any RF components on your page, or just use the RF packaged

                  jquery.js and you also import jquery-ui-....js then you'll probably hit some javascript errors like

                  'no method 'propAttr'. If you're using some jquery-ui plugins that are not included in the RF packed.js

                  then build a custom jquery ui download and pick out the required modules from development-bundle/ui

                  in the zip file.

                   

                  I will try and try and figure out how to handle the custom skin scenario.

                   

                  Thanks very much for your help.

                   

                  Brendan.

                   

                  p.s. this is a dead link

                  : http://community.jboss.org/docs/DOC-17377

                  • 21. Re: RF 4.1.0.Final - javascript error when resource mapping enabled
                    undermanager

                    For what it's worth:

                     

                    The workaround mentioned by @Lucas (JIRA RF-11739) got me 85% of what I needed - i.e. RichFaces resources are now getting packed (I chose to use "org.richfaces.resourceMapping.packedStages" in my web.xml).

                     

                    I still cannot pack my own resources (using org.richfaces.resourceMapping.mappingFile and org.richfaces.resourceMapping.location) - can't get that piece right yet.  Will revisit at some point.

                    1 2 Previous Next