6 Replies Latest reply on Apr 5, 2011 4:56 PM by kshanth

    richfaces 4 jQuery built in

    xilosh

      Hi all,

       

      I am trying to migrate a RF3 application to RF4. On RF3 application iRF3 application is usig jQuery library that comes with RF, it  is loadesd using a4j:loadScript

       

      <a4j:loadScript src="resource://jQuery.js />

       

      Questions.

       

      ¿has RF 4 builtin jquery library or I have to use external jquery?

      if RF 4 come with jquery inside ¿ how I can load it?

       

       

      Regards

        • 1. richfaces 4 jQuery built in
          mp911de

          Hi Silvestre,

          RF4 contains jQuery. It's loaded automatically when you use some JavaScripted componets (i.e. rich:calendar). You can initialize jQuery on you Page (when you don't have any JavaScripted RichFaces-Components) with rich:jQuery:

           

          This is a small sample:

            <h:head>

                 <rich:jQuery />

            </h:head>

            <body>

                 <h:form>

                      <h:outputLink value="javascript:alert($('.dummy'));">Test</h:outputLink>

                 </h:form>

            </body>

           

           

          And then it just goes $('something')....

           

          Best regards,

          Mark

          • 2. Re: richfaces 4 jQuery built in
            xilosh

            Hi Mark

             

            Thanks for the repply. it does not work for me I've created a simple 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"
                  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>
            
                   <rich:jQuery />
            
              </h:head>
            
              <h:body>
                <p id="p_test">hello world</p>
            
                        <a href="#" onclick="javascript:alert(jQuery('#p_test'))">Test</a>
            
            </h:body>
            
            </html>
            

             

             

            When I try to load the page it has javascript errors

             

            Error: RichFaces is not defined

            Archivo de origen: http://localhost:8080/media/common/test.jsf#

            Línea: 3

            Error: jQuery is not defined

            Archivo de origen: http://localhost:8080/media/javax.faces.resource/jquery.component.js.jsf?ln=org.richfaces

            Línea: 78

             

            if I try with $ instead of jQuery same error occurs

             

            i'm using richfaces version 4.0.0.20110209-M6, I was looking for jquery library inside the jars but I cant find it. I version 3.3.2 there is a jquery.js file inside org.richfaces.renderkit.html.scripts.

             

            Kind regards

            • 3. richfaces 4 jQuery built in
              boy18nj
              • 4. richfaces 4 jQuery built in
                xilosh

                Thanks aman.

                 

                a4j:loadScript is not available on RF 4, there is similar feature in JSF 2 h:ouputScript but is not exactly the same.

                • 5. richfaces 4 jQuery built in
                  xilosh

                  Solved!!!

                   

                  I was not including richfaces-core-impl library.

                   

                   

                  Thank you.

                  • 6. richfaces 4 jQuery built in
                    kshanth

                    Add the following lines, hope it resolves in RF 4

                     

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

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